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/neutron/data/NeutronElasticData.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/math/Quantity.hh"
0014 #include "celeritas/Quantities.hh"
0015 #include "celeritas/Types.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Parameters for sampling the momentum transfer of CHIPS neutron-nucleus
0022  * elastic scattering.
0023  */
0024 struct ExchangeParameters
0025 {
0026     using Real4 = Array<real_type, 4>;
0027 
0028     // Momentum-dependent parameters in G4ChipsNeutronElasticXS
0029     real_type ss{};  // square slope of the first diffractive maximum
0030     Real4 slope{0, 0, 0, 0};  //!< slope of CHIPS diffractive maxima
0031     Real4 expnt{0, 0, 0, 0};  //!< mantissa of CHIPS diffractive maxima
0032 };
0033 
0034 //---------------------------------------------------------------------------//
0035 /*!
0036  * A-dependent data for the differential cross section (momentum transfer) of
0037  * the CHIPS neutron-nucleus elastic model.
0038  */
0039 struct ChipsDiffXsCoefficients
0040 {
0041     using ChipsArray = Array<real_type, 42>;
0042 
0043     // Coefficients
0044     ChipsArray par{};  //!< Coefficients as a function of atomic mass numbers
0045 };
0046 
0047 //---------------------------------------------------------------------------//
0048 /*!
0049  * Device data for creating an interactor.
0050  */
0051 template<Ownership W, MemSpace M>
0052 struct NeutronElasticData
0053 {
0054     using XsUnits = units::Native;  // [len^2]
0055 
0056     template<class T>
0057     using Items = Collection<T, W, M>;
0058     template<class T>
0059     using ElementItems = Collection<T, W, M, ElementId>;
0060     template<class T>
0061     using IsotopeItems = Collection<T, W, M, IsotopeId>;
0062 
0063     //// MEMBER DATA ////
0064 
0065     //! ID of a neutron
0066     ParticleId neutron;
0067 
0068     //! Particle mass * c^2 [MeV]
0069     units::MevMass neutron_mass;
0070 
0071     //! Microscopic (element) cross section data (G4PARTICLEXS/neutron/elZ)
0072     ElementItems<NonuniformGridRecord> micro_xs;
0073 
0074     //! A-dependent coefficients for the momentum transfer of the CHIPS model
0075     IsotopeItems<ChipsDiffXsCoefficients> coeffs;
0076 
0077     // Backend data
0078     Items<real_type> reals;
0079 
0080     //// MEMBER FUNCTIONS ////
0081 
0082     //! Model's minimum and maximum energy limit [MeV]
0083     static CELER_CONSTEXPR_FUNCTION units::MevEnergy min_valid_energy()
0084     {
0085         return units::MevEnergy{1e-5};
0086     }
0087 
0088     static CELER_CONSTEXPR_FUNCTION units::MevEnergy max_valid_energy()
0089     {
0090         return units::MevEnergy{2e+4};
0091     }
0092 
0093     //! Whether the data are assigned
0094     explicit CELER_FUNCTION operator bool() const
0095     {
0096         return neutron && neutron_mass > zero_quantity() && !micro_xs.empty()
0097                && !coeffs.empty() && !reals.empty();
0098     }
0099 
0100     //! Assign from another set of data
0101     template<Ownership W2, MemSpace M2>
0102     NeutronElasticData& operator=(NeutronElasticData<W2, M2> const& other)
0103     {
0104         CELER_EXPECT(other);
0105         neutron = other.neutron;
0106         neutron_mass = other.neutron_mass;
0107         micro_xs = other.micro_xs;
0108         coeffs = other.coeffs;
0109         reals = other.reals;
0110         return *this;
0111     }
0112 };
0113 
0114 using NeutronElasticHostRef = HostCRef<NeutronElasticData>;
0115 using NeutronElasticDeviceRef = DeviceCRef<NeutronElasticData>;
0116 using NeutronElasticRef = NativeCRef<NeutronElasticData>;
0117 
0118 //---------------------------------------------------------------------------//
0119 }  // namespace celeritas