Back to home page

EIC code displayed by LXR

 
 

    


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

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