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