File indexing completed on 2025-09-15 08:54:46
0001
0002
0003
0004
0005
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
0023
0024 class NucleonNucleonXsCalculator
0025 {
0026 public:
0027
0028
0029 using ParamsRef = NeutronInelasticRef;
0030 using Energy = units::MevEnergy;
0031 using BarnXs = units::BarnXs;
0032
0033
0034 public:
0035
0036 inline CELER_FUNCTION NucleonNucleonXsCalculator(ParamsRef const& shared);
0037
0038
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
0054 NeutronInelasticRef const& shared_;
0055 };
0056
0057
0058
0059
0060
0061
0062
0063 CELER_FUNCTION
0064 NucleonNucleonXsCalculator::NucleonNucleonXsCalculator(ParamsRef const& shared)
0065 : shared_(shared)
0066 {
0067 }
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
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
0092
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
0109 NonuniformGridRecord grid = shared_.nucleon_xs[ch_id];
0110
0111
0112 NonuniformGridCalculator calc_xs(grid, shared_.reals);
0113 result = calc_xs(energy.value());
0114 }
0115
0116 return BarnXs{result};
0117 }
0118
0119
0120 }