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/data/DTMixMucfData.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <string>
0010 #include <utility>
0011 
0012 #include "corecel/Macros.hh"
0013 #include "corecel/cont/EnumArray.hh"
0014 #include "corecel/grid/NonuniformGridData.hh"
0015 #include "corecel/io/Join.hh"
0016 #include "celeritas/Types.hh"
0017 #include "celeritas/mucf/Types.hh"
0018 #include "celeritas/phys/ParticleParams.hh"
0019 
0020 namespace celeritas
0021 {
0022 //---------------------------------------------------------------------------//
0023 /*!
0024  * ParticleIds used by the \c DTMixMucfModel .
0025  */
0026 struct MucfParticleIds
0027 {
0028     //! Primary
0029     ParticleId mu_minus;
0030 
0031     //!@{
0032     //! Elementary particles and nuclei
0033     ParticleId proton;
0034     ParticleId triton;
0035     ParticleId neutron;
0036     ParticleId alpha;
0037     ParticleId he3;
0038     //!@}
0039 
0040     //!@{
0041     //! Muonic atoms
0042     ParticleId muonic_hydrogen;
0043     ParticleId muonic_deuteron;
0044     ParticleId muonic_triton;
0045     ParticleId muonic_alpha;
0046     ParticleId muonic_he3;
0047     //!@}
0048 
0049     //! Check whether all particles are assigned
0050     CELER_FUNCTION explicit operator bool() const
0051     {
0052         return mu_minus && proton && triton && neutron && alpha && he3
0053                && muonic_hydrogen && muonic_deuteron && muonic_triton
0054                && muonic_alpha && muonic_he3;
0055     }
0056 };
0057 
0058 //---------------------------------------------------------------------------//
0059 /*!
0060  * Particle masses used by the \c DTMixMucfModel .
0061  */
0062 struct MucfParticleMasses
0063 {
0064     //! Primary
0065     units::MevMass mu_minus;
0066 
0067     //!@{
0068     //! Elementary particles and nuclei
0069     units::MevMass proton;
0070     units::MevMass triton;
0071     units::MevMass neutron;
0072     units::MevMass alpha;
0073     units::MevMass he3;
0074     //!@}
0075 
0076     //!@{
0077     //! Muonic atoms
0078     units::MevMass muonic_hydrogen;
0079     units::MevMass muonic_deuteron;
0080     units::MevMass muonic_triton;
0081     units::MevMass muonic_alpha;
0082     units::MevMass muonic_he3;
0083     //!@}
0084 
0085     //! Check whether all data are assigned
0086     CELER_FUNCTION explicit operator bool() const
0087     {
0088         return mu_minus > zero_quantity() && proton > zero_quantity()
0089                && triton > zero_quantity() && neutron > zero_quantity()
0090                && alpha > zero_quantity() && he3 > zero_quantity()
0091                && muonic_hydrogen > zero_quantity()
0092                && muonic_deuteron > zero_quantity()
0093                && muonic_triton > zero_quantity()
0094                && muonic_alpha > zero_quantity()
0095                && muonic_he3 > zero_quantity();
0096     }
0097 };
0098 
0099 //---------------------------------------------------------------------------//
0100 /*!
0101  * Data for for the \c DTMixMucfModel .
0102  */
0103 template<Ownership W, MemSpace M>
0104 struct DTMixMucfData
0105 {
0106     template<class T>
0107     using Items = Collection<T, W, M>;
0108     template<class T>
0109     using MaterialItems = Collection<T, W, M, MuCfMatId>;
0110     using GridRecord = NonuniformGridRecord;
0111     using CycleTimesArray = EnumArray<MucfMuonicMolecule, Array<real_type, 2>>;
0112     using MaterialFractionsArray = EnumArray<MucfIsotope, real_type>;
0113 
0114     //! Particles
0115     MucfParticleIds particle_ids;
0116     MucfParticleMasses particle_masses;
0117 
0118     //! Muon CDF energy grid for sampling outgoing muCF muons
0119     //! X-axis range is [0, 1) and y-axis is the outgoing muon energy in MeV
0120     GridRecord muon_energy_cdf;
0121     Items<real_type> reals;
0122 
0123     //!@{
0124     //! Material-dependent data calculated at model construction
0125     //! \c PhysMatId indexed by \c MuCfMatId
0126     MaterialItems<PhysMatId> mucfmatid_to_matid;
0127     //! Isotopic fractions per material: [mat_comp_id][isotope]
0128     MaterialItems<MaterialFractionsArray> isotopic_fractions;
0129     //! Cycle times per material: [mat_comp_id][muonic_molecule][spin_index]
0130     MaterialItems<CycleTimesArray> cycle_times;  //!< In [s]
0131     //! \todo Add mean atom spin flip times
0132     //! \todo Add mean atom transfer times
0133     //!@}
0134 
0135     //! Check whether the data are assigned
0136     explicit CELER_FUNCTION operator bool() const
0137     {
0138         return particle_ids && particle_masses && muon_energy_cdf
0139                && !reals.empty() && !mucfmatid_to_matid.empty()
0140                && !isotopic_fractions.empty() && !cycle_times.empty();
0141     }
0142 
0143     //! Assign from another set of data
0144     template<Ownership W2, MemSpace M2>
0145     DTMixMucfData& operator=(DTMixMucfData<W2, M2> const& other)
0146     {
0147         CELER_EXPECT(other);
0148 
0149         //! \todo Finish implementation
0150         this->particle_ids = other.particle_ids;
0151         this->particle_masses = other.particle_masses;
0152         this->muon_energy_cdf = other.muon_energy_cdf;
0153         this->reals = other.reals;
0154         this->mucfmatid_to_matid = other.mucfmatid_to_matid;
0155         this->isotopic_fractions = other.isotopic_fractions;
0156         this->cycle_times = other.cycle_times;
0157 
0158         return *this;
0159     }
0160 };
0161 
0162 //---------------------------------------------------------------------------//
0163 }  // namespace celeritas