Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:11:35

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/mucf/executor/DTMixMucfExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "celeritas/global/CoreTrackView.hh"
0011 #include "celeritas/mat/ElementView.hh"
0012 #include "celeritas/mucf/data/DTMixMucfData.hh"
0013 #include "celeritas/mucf/interactor/DDMucfInteractor.hh"
0014 #include "celeritas/mucf/interactor/DTMucfInteractor.hh"
0015 #include "celeritas/mucf/interactor/TTMucfInteractor.hh"
0016 
0017 #include "detail/DDChannelSelector.hh"
0018 #include "detail/DTChannelSelector.hh"
0019 #include "detail/DTMixMuonicMoleculeSelector.hh"
0020 #include "detail/MuonicAtomSelector.hh"
0021 #include "detail/MuonicAtomSpinSelector.hh"
0022 #include "detail/MuonicMoleculeSpinSelector.hh"
0023 #include "detail/TTChannelSelector.hh"
0024 
0025 namespace celeritas
0026 {
0027 //---------------------------------------------------------------------------//
0028 struct DTMixMucfExecutor
0029 {
0030     inline CELER_FUNCTION Interaction operator()(
0031         celeritas::CoreTrackView const& track);
0032 
0033     NativeCRef<DTMixMucfData> data;
0034 };
0035 
0036 //---------------------------------------------------------------------------//
0037 /*!
0038  * Execute muon-catalyzed fusion for muonic dd, dt, or tt molecules.
0039  */
0040 CELER_FUNCTION Interaction DTMixMucfExecutor::operator()(
0041     celeritas::CoreTrackView const& track)
0042 {
0043     auto phys_step_view = track.physics_step();
0044     auto elcomp_id = phys_step_view.element();
0045     CELER_ASSERT(elcomp_id);
0046 
0047     auto element = track.material().material_record().element_record(elcomp_id);
0048     CELER_ASSERT(element.atomic_number() == AtomicNumber{1});  // Must be H
0049 
0050     auto rng = track.rng();
0051 
0052     // Muon decay may compete against other "actions" in this executor
0053     real_type const decay_len{};  //! \todo Set muon decay interaction length
0054 
0055     // Find muCF material ID from PhysMatId
0056     // Make this a View if ever used beyond this executor
0057     auto find = [&](PhysMatId matid) -> MuCfMatId {
0058         CELER_EXPECT(matid);
0059         for (auto i : range(data.mucfmatid_to_matid.size()))
0060         {
0061             if (auto const comp_id = MuCfMatId{i};
0062                 data.mucfmatid_to_matid[comp_id] == matid)
0063             {
0064                 return comp_id;
0065             }
0066         }
0067         // MuCF material ID not found
0068         return MuCfMatId{};
0069     };
0070     auto const mucf_matid = find(track.material().material_id());
0071     CELER_ASSERT(mucf_matid);
0072 
0073     // Form d or t muonic atom
0074     detail::MuonicAtomSelector form_atom(
0075         data.isotopic_fractions[mucf_matid][MucfIsotope::deuterium]);
0076     auto muonic_atom = form_atom(rng);
0077 
0078     // Select atom spin via a helper class
0079     detail::MuonicAtomSpinSelector select_atom_spin(muonic_atom);
0080 
0081     // {
0082     // Competing at-rest processes which add to the total track time
0083     //! \todo Muonic atom transfer
0084     //! \todo Muonic atom spin flip
0085     // }
0086 
0087     // Form dd, dt, or tt muonic molecule
0088     detail::DTMixMuonicMoleculeSelector form_muonic_molecule;
0089     auto muonic_molecule = form_muonic_molecule(rng);
0090 
0091     // Select molecule spin
0092     detail::MuonicMoleculeSpinSelector select_molecule_spin(muonic_molecule);
0093     auto const molecule_spin = select_molecule_spin(rng);
0094 
0095     // Load cycle time for the selected molecule
0096     auto const cycle_time
0097         = data.cycle_times[mucf_matid][muonic_molecule][molecule_spin];
0098     CELER_ASSERT(cycle_time > 0);
0099 
0100     // Check if muon decays before fusion happens
0101     real_type const mucf_len = cycle_time * track.sim().step_length();
0102     if (decay_len < mucf_len)
0103     {
0104         // Muon decays and halts the interaction
0105         //! \todo Update track time and return muon decay interactor
0106     }
0107 
0108     //! \todo Correct track time update? Or should be done in Interactors?
0109     track.sim().add_time(cycle_time);
0110 
0111     // Fuse molecule and generate secondaries
0112     //! \todo Maybe move the channel selectors into the interactors
0113     auto allocate_secondaries = phys_step_view.make_secondary_allocator();
0114     Interaction result;
0115     switch (muonic_molecule)
0116     {
0117         case MucfMuonicMolecule::deuterium_deuterium: {
0118             // Return DD interaction
0119             DDMucfInteractor interact(
0120                 data, detail::DDChannelSelector()(rng), allocate_secondaries);
0121             result = interact(rng);
0122             break;
0123         }
0124         case MucfMuonicMolecule::deuterium_tritium: {
0125             // Return DT interaction
0126             DTMucfInteractor interact(
0127                 data, detail::DTChannelSelector()(rng), allocate_secondaries);
0128             result = interact(rng);
0129             break;
0130         }
0131         case MucfMuonicMolecule::tritium_tritium: {
0132             // Return TT interaction
0133             TTMucfInteractor interact(
0134                 data, detail::TTChannelSelector()(rng), allocate_secondaries);
0135             result = interact(rng);
0136             break;
0137         }
0138         default:
0139             CELER_ASSERT_UNREACHABLE();
0140     }
0141 
0142     //! \todo Muon stripping: strip muon from muonic atom secondaries
0143     // May be added as a separate discrete process in the stepping loop
0144 
0145     return result;
0146 }
0147 
0148 //---------------------------------------------------------------------------//
0149 }  // namespace celeritas