Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:41

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/io/ImportModel.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <string_view>
0010 #include <vector>
0011 
0012 #include "corecel/Types.hh"
0013 #include "corecel/cont/EnumArray.hh"
0014 
0015 #include "ImportPhysicsTable.hh"
0016 #include "ImportUnits.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Enumerator for the available physics models.
0023  *
0024  * This enum was created to safely access the many imported physics tables.
0025  *
0026  * \todo reorganize by physics list (major) and particle (minor) so that newly
0027  * supported models are appended cleanly to the end of the list.
0028  */
0029 enum class ImportModelClass
0030 {
0031     other,
0032     bragg_ion,
0033     bethe_bloch,
0034     urban_msc,
0035     icru_73_qo,
0036     wentzel_vi_uni,
0037     h_brems,
0038     h_pair_prod,
0039     e_coulomb_scattering,
0040     bragg,
0041     moller_bhabha,
0042     e_brems_sb,
0043     e_brems_lpm,
0044     e_plus_to_gg,
0045     livermore_photoelectric,
0046     klein_nishina,
0047     bethe_heitler,
0048     bethe_heitler_lpm,
0049     livermore_rayleigh,
0050     mu_bethe_bloch,
0051     mu_brems,
0052     mu_pair_prod,
0053     fluo_photoelectric,
0054     goudsmit_saunderson,
0055     size_
0056 };
0057 
0058 //---------------------------------------------------------------------------//
0059 /*!
0060  * Imported data for one material in a particular model.
0061  *
0062  * Microscopic cross-section data are stored in the element-selector physics
0063  * vector is in length^2. They will not be present for all model types, as some
0064  * models only do on-the-fly calculation (e.g., photoelectric effect) or don't
0065  * depend on elemental interactions (e.g., compton scattering). The \c
0066  * needs_micro_xs function indicates which models should store the cross
0067  * section data.
0068  *
0069  * The energy grid's boundaries determine the model's energy bounds and will
0070  * always be set.
0071  */
0072 struct ImportModelMaterial
0073 {
0074     //!@{
0075     //! \name Type aliases
0076     using VecGrid = std::vector<inp::UniformGrid>;
0077     using EnergyBound = EnumArray<Bound, double>;
0078     //!@}
0079 
0080     static constexpr auto energy_units{ImportUnits::mev};
0081     static constexpr auto xs_units{ImportUnits::len_sq};
0082 
0083     EnergyBound energy{};  //!< Energy bounds for the material
0084     VecGrid micro_xs;  //!< Cross section for each element
0085 };
0086 
0087 //---------------------------------------------------------------------------//
0088 /*!
0089  * Imported data for one model of a process.
0090  *
0091  * This is always for a particular particle type since we import Processes
0092  * as being for a particular particle.
0093  *
0094  * The materials vector must always be assigned since we want the lower cutoff
0095  * energy for each model.
0096  */
0097 struct ImportModel
0098 {
0099     ImportModelClass model_class{ImportModelClass::size_};
0100     std::vector<ImportModelMaterial> materials;
0101     double low_energy_limit{0};
0102     double high_energy_limit{0};
0103 
0104     explicit operator bool() const
0105     {
0106         return model_class != ImportModelClass::size_ && !materials.empty()
0107                && low_energy_limit < high_energy_limit;
0108     }
0109 };
0110 
0111 //---------------------------------------------------------------------------//
0112 /*!
0113  * Store imported data for multiple scattering.
0114  */
0115 struct ImportMscModel
0116 {
0117     //!@{
0118     //! \name Type aliases
0119     using PdgInt = int;
0120     //!@}
0121 
0122     PdgInt particle_pdg{0};
0123     ImportModelClass model_class{ImportModelClass::size_};
0124     ImportPhysicsTable xs_table;
0125 
0126     explicit operator bool() const
0127     {
0128         return particle_pdg != 0 && model_class != ImportModelClass::size_
0129                && xs_table;
0130     }
0131 };
0132 
0133 //---------------------------------------------------------------------------//
0134 // FREE FUNCTIONS
0135 //---------------------------------------------------------------------------//
0136 
0137 // Get the string form of one of the enumerations
0138 char const* to_cstring(ImportModelClass value);
0139 
0140 // Get the default Geant4 process name
0141 char const* to_geant_name(ImportModelClass value);
0142 
0143 // Convert a Geant4 process name to an IMC (throw RuntimeError if unsupported)
0144 ImportModelClass geant_name_to_import_model_class(std::string_view s);
0145 
0146 //---------------------------------------------------------------------------//
0147 }  // namespace celeritas