Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:08

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/neutron/data/NeutronInelasticData.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/data/Collection.hh"
0012 #include "corecel/grid/NonuniformGridData.hh"
0013 #include "corecel/grid/TwodGridData.hh"
0014 #include "corecel/math/Quantity.hh"
0015 #include "celeritas/Quantities.hh"
0016 #include "celeritas/Types.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Scalar data for neutron-nucleus inelastic interactions.
0023  */
0024 struct NeutronInelasticScalars
0025 {
0026     // Particle IDs
0027     ParticleId neutron_id;
0028     ParticleId proton_id;
0029 
0030     // Particle mass * c^2 [MeV]
0031     units::MevMass neutron_mass;
0032     units::MevMass proton_mass;
0033 
0034     //! Number of nucleon-nucleon channels
0035     static CELER_CONSTEXPR_FUNCTION size_type num_channels() { return 2; }
0036 
0037     //! Model's maximum energy limit [MeV]
0038     static CELER_CONSTEXPR_FUNCTION units::MevEnergy max_valid_energy()
0039     {
0040         // Below the pion production threshold
0041         return units::MevEnergy{320};
0042     }
0043 
0044     //! Whether data are assigned
0045     explicit CELER_FUNCTION operator bool() const
0046     {
0047         return neutron_id && proton_id && neutron_mass > zero_quantity()
0048                && neutron_mass > zero_quantity();
0049     }
0050 };
0051 
0052 //---------------------------------------------------------------------------//
0053 /*!
0054  * Parameters of Stepanov's function to fit nucleon-nucleon cross sections
0055  * below 10 MeV.
0056  */
0057 struct StepanovParameters
0058 {
0059     real_type xs_zero;  //!< nucleon-nucleon cross section at the zero energy
0060     real_type slope;  //!< parameter used for the low energy threshold
0061     Real3 coeffs;  //!< coefficients of a second order Stepanov's function
0062 };
0063 
0064 //---------------------------------------------------------------------------//
0065 /*!
0066  * Components of nuclear zone properties of the Bertini cascade model.
0067  */
0068 struct ZoneComponent
0069 {
0070     using NucleonArray = Array<real_type, 2>;  //!< [proton, neutron]
0071 
0072     real_type radius{};  //!< radius of zones in [femtometer]
0073     real_type volume{};  //!< volume of zones in [femtometer^3]
0074     NucleonArray density{0, 0};  //!< nucleon densities [1/femtometer^3]
0075     NucleonArray fermi_mom{0, 0};  //!< fermi momenta in [MeV/c]
0076     NucleonArray potential{0, 0};  //!< nucleon potentials [MeV]
0077 };
0078 
0079 //---------------------------------------------------------------------------//
0080 /*!
0081  * Data characterizing the nuclear zones.
0082  */
0083 struct NuclearZones
0084 {
0085     ItemRange<ZoneComponent> zones;
0086 
0087     //! Whether all data are assigned and valid
0088     explicit CELER_FUNCTION operator bool() const { return !zones.empty(); }
0089 };
0090 
0091 //---------------------------------------------------------------------------//
0092 /*!
0093  * Device data for nuclear zone properties
0094  */
0095 template<Ownership W, MemSpace M>
0096 struct NuclearZoneData
0097 {
0098     template<class T>
0099     using Items = Collection<T, W, M>;
0100     template<class T>
0101     using IsotopeItems = Collection<T, W, M, IsotopeId>;
0102 
0103     //// MEMBER DATA ////
0104 
0105     // Nuclear zone data
0106     Items<ZoneComponent> components;
0107     IsotopeItems<NuclearZones> zones;
0108 
0109     //! Whether the data are assigned
0110     explicit CELER_FUNCTION operator bool() const
0111     {
0112         return !components.empty() && !zones.empty();
0113     }
0114 
0115     //! Assign from another set of data
0116     template<Ownership W2, MemSpace M2>
0117     NuclearZoneData& operator=(NuclearZoneData<W2, M2> const& other)
0118     {
0119         CELER_EXPECT(other);
0120         components = other.components;
0121         zones = other.zones;
0122 
0123         return *this;
0124     }
0125 };
0126 
0127 //---------------------------------------------------------------------------//
0128 /*!
0129  * Device data for creating an interactor.
0130  */
0131 template<Ownership W, MemSpace M>
0132 struct NeutronInelasticData
0133 {
0134     template<class T>
0135     using Items = Collection<T, W, M>;
0136     template<class T>
0137     using ElementItems = Collection<T, W, M, ElementId>;
0138     template<class T>
0139     using ChannelItems = Collection<T, W, M, ChannelId>;
0140 
0141     //// MEMBER DATA ////
0142 
0143     // Scalar data
0144     NeutronInelasticScalars scalars;
0145 
0146     // Microscopic (element) cross section data (G4PARTICLEXS/neutron/inelZ)
0147     ElementItems<NonuniformGridRecord> micro_xs;
0148 
0149     // Tabulated nucleon-nucleon cross section data
0150     ChannelItems<NonuniformGridRecord> nucleon_xs;
0151 
0152     // Parameters of necleon-nucleon cross sections below 10 MeV
0153     ChannelItems<StepanovParameters> xs_params;
0154 
0155     // Tabulated nucleon-nucleon angular distribution data
0156     ChannelItems<TwodGridData> angular_cdf;
0157 
0158     // Backend data
0159     Items<real_type> reals;
0160 
0161     // Nuclear zone data
0162     NuclearZoneData<W, M> nuclear_zones;
0163 
0164     //! Whether the data are assigned
0165     explicit CELER_FUNCTION operator bool() const
0166     {
0167         return scalars && !micro_xs.empty() && !nucleon_xs.empty()
0168                && !xs_params.empty() && !reals.empty() && nuclear_zones
0169                && !angular_cdf.empty();
0170     }
0171 
0172     //! Assign from another set of data
0173     template<Ownership W2, MemSpace M2>
0174     NeutronInelasticData& operator=(NeutronInelasticData<W2, M2> const& other)
0175     {
0176         CELER_EXPECT(other);
0177         scalars = other.scalars;
0178         micro_xs = other.micro_xs;
0179         nucleon_xs = other.nucleon_xs;
0180         xs_params = other.xs_params;
0181         reals = other.reals;
0182         nuclear_zones = other.nuclear_zones;
0183         angular_cdf = other.angular_cdf;
0184 
0185         return *this;
0186     }
0187 };
0188 
0189 using NeutronInelasticHostRef = HostCRef<NeutronInelasticData>;
0190 using NeutronInelasticDeviceRef = DeviceCRef<NeutronInelasticData>;
0191 using NeutronInelasticRef = NativeCRef<NeutronInelasticData>;
0192 
0193 //---------------------------------------------------------------------------//
0194 }  // namespace celeritas