Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:54:46

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/xs/NucleonNucleonXsCalculator.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/math/PolyEvaluator.hh"
0012 #include "corecel/math/Quantity.hh"
0013 #include "celeritas/Quantities.hh"
0014 #include "celeritas/Types.hh"
0015 #include "celeritas/grid/NonuniformGridCalculator.hh"
0016 #include "celeritas/neutron/data/NeutronInelasticData.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Calculate nucleon-nucleon (NN) cross sections from NeutronInelasticData
0023  */
0024 class NucleonNucleonXsCalculator
0025 {
0026   public:
0027     //!@{
0028     //! \name Type aliases
0029     using ParamsRef = NeutronInelasticRef;
0030     using Energy = units::MevEnergy;
0031     using BarnXs = units::BarnXs;
0032     //!@}
0033 
0034   public:
0035     // Construct with shared and state data
0036     inline CELER_FUNCTION NucleonNucleonXsCalculator(ParamsRef const& shared);
0037 
0038     // Compute cross section
0039     inline CELER_FUNCTION BarnXs operator()(ChannelId el_id,
0040                                             Energy energy) const;
0041 
0042     static CELER_CONSTEXPR_FUNCTION Energy high_otf_energy()
0043     {
0044         return Energy{10};
0045     }
0046 
0047     static CELER_CONSTEXPR_FUNCTION Energy low_otf_energy()
0048     {
0049         return Energy{1};
0050     }
0051 
0052   private:
0053     // Shared constant physics properties
0054     NeutronInelasticRef const& shared_;
0055 };
0056 
0057 //---------------------------------------------------------------------------//
0058 // INLINE DEFINITIONS
0059 //---------------------------------------------------------------------------//
0060 /*!
0061  * Construct with shared and state data.
0062  */
0063 CELER_FUNCTION
0064 NucleonNucleonXsCalculator::NucleonNucleonXsCalculator(ParamsRef const& shared)
0065     : shared_(shared)
0066 {
0067 }
0068 
0069 //---------------------------------------------------------------------------//
0070 /*!
0071  * Compute nucleon-nucleon (NN) cross section
0072  *
0073  * The parameterization of nucleon-nucleon cross sections below 10 MeV takes
0074  * the following functional form,
0075  * \f[
0076  *  SF(E) = coeffs[0] + coeffs[1]/E + coeffs[2]/E^{2}
0077  * \f]
0078  * where the kinetic energy of the incident nucleon, \em E is in [1, 10] MeV.
0079  * Below 1 MeV, \f$ SF(E) = slope/E \f$ down to \f$ E = slope/xs_zero \f$ while
0080  * \f$ SF(E) = xs_zero \f$ if \em E is in [0, slope/xs_zero] MeV.
0081  */
0082 CELER_FUNCTION
0083 auto NucleonNucleonXsCalculator::operator()(ChannelId ch_id,
0084                                             Energy energy) const -> BarnXs
0085 {
0086     CELER_EXPECT(ch_id < shared_.nucleon_xs.size());
0087     real_type result;
0088 
0089     if (energy < this->high_otf_energy())
0090     {
0091         // Calculate NN cross section according to the Stepanov's function
0092         // for the incident nucleon kinetic energy below 10 MeV
0093         StepanovParameters const& par = shared_.xs_params[ch_id];
0094 
0095         if (energy <= this->low_otf_energy())
0096         {
0097             result = celeritas::min(par.slope / energy.value(), par.xs_zero);
0098         }
0099         else
0100         {
0101             using StepanovFunction = PolyEvaluator<real_type, 2>;
0102             result
0103                 = StepanovFunction(par.coeffs)(real_type{1} / energy.value());
0104         }
0105     }
0106     else
0107     {
0108         // Get tabulated NN cross section data for the given channel
0109         NonuniformGridRecord grid = shared_.nucleon_xs[ch_id];
0110 
0111         // Calculate NN cross section at the given energy
0112         NonuniformGridCalculator calc_xs(grid, shared_.reals);
0113         result = calc_xs(energy.value());
0114     }
0115 
0116     return BarnXs{result};
0117 }
0118 
0119 //---------------------------------------------------------------------------//
0120 }  // namespace celeritas