Back to home page

EIC code displayed by LXR

 
 

    


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

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/model/detail/MucfMaterialInserter.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <map>
0010 
0011 #include "corecel/data/CollectionBuilder.hh"
0012 #include "celeritas/inp/MucfPhysics.hh"
0013 #include "celeritas/mat/MaterialView.hh"
0014 #include "celeritas/mucf/Types.hh"
0015 #include "celeritas/mucf/data/DTMixMucfData.hh"
0016 
0017 #include "EquilibrateDensitiesSolver.hh"
0018 #include "InterpolatorHelper.hh"
0019 
0020 namespace celeritas
0021 {
0022 namespace detail
0023 {
0024 //---------------------------------------------------------------------------//
0025 /*!
0026  * Helper class to calculate and insert muCF material-dependent data into
0027  * \c DTMixMucfData . If the material does not contain deuterium and/or
0028  * tritium the operator will return false.
0029  *
0030  * This is designed to work with the user's material definition being either:
0031  * - Single element, multiple isotopes (H element, with H, d, and t isotopes);
0032  * or
0033  * - Multiple elements, single isotope each (separate H, d, and t elements).
0034  *
0035  * The \c inp:: data has cycle \em rate (\f$\lambda\f$) tables, while the
0036  * host/device cached data is the cycle \em time \f$\tau = 1/\lambda\f$.
0037  */
0038 class MucfMaterialInserter
0039 {
0040   public:
0041     // Construct with muCF host data
0042     explicit MucfMaterialInserter(HostVal<DTMixMucfData>* host_data,
0043                                   inp::MucfPhysics const& data);
0044 
0045     // Insert material if it is a valid d-t mixture
0046     bool operator()(MaterialView const& material);
0047 
0048   private:
0049     using MoleculeCycles = Array<real_type, 2>;
0050     using CycleTimesArray = EnumArray<MucfMuonicMolecule, MoleculeCycles>;
0051     using EquilibriumArray = EquilibrateDensitiesSolver::EquilibriumArray;
0052     using MaterialFractionsArray = EnumArray<MucfIsotope, real_type>;
0053     using AtomicMassNumber = AtomicNumber;
0054     using InterpolatorsMap
0055         = std::map<std::pair<inp::CycleTableType, units::HalfSpinInt>,
0056                    InterpolatorHelper>;
0057 
0058     //// DATA ////
0059 
0060     // DTMixMucfModel host data references populated by operator()
0061     CollectionBuilder<PhysMatId, MemSpace::host, MuCfMatId> mucfmatid_to_matid_;
0062     CollectionBuilder<MaterialFractionsArray, MemSpace::host, MuCfMatId>
0063         isotopic_fractions_;
0064     CollectionBuilder<CycleTimesArray, MemSpace::host, MuCfMatId> cycle_times_;
0065     // Const data
0066     std::map<AtomicMassNumber, MucfIsotope> const mass_isotope_map_{
0067         {AtomicMassNumber{1}, MucfIsotope::protium},
0068         {AtomicMassNumber{2}, MucfIsotope::deuterium},
0069         {AtomicMassNumber{3}, MucfIsotope::tritium},
0070     };
0071     inp::MucfPhysics const& data_;
0072     InterpolatorsMap interpolators_;
0073 
0074     //// HELPER FUNCTIONS ////
0075 
0076     // Calculate mean fusion cycle times for dd muonic molecules
0077     Array<real_type, 2> calc_dd_cycle(EquilibriumArray const& eq_dens,
0078                                       real_type const temperature);
0079 
0080     // Calculate mean fusion cycle times for dt muonic molecules
0081     Array<real_type, 2> calc_dt_cycle(EquilibriumArray const& eq_dens,
0082                                       real_type const temperature);
0083 
0084     // Calculate mean fusion cycle times for tt muonic molecules
0085     Array<real_type, 2> calc_tt_cycle(EquilibriumArray const& eq_dens,
0086                                       real_type const temperature);
0087 
0088     // Get interpolator for given cycle type and spin
0089     InterpolatorHelper const& interpolator(inp::CycleTableType type,
0090                                            units::HalfSpinInt spin) const;
0091 };
0092 
0093 //---------------------------------------------------------------------------//
0094 }  // namespace detail
0095 }  // namespace celeritas