Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:24

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