File indexing completed on 2025-02-22 10:31:19
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Assert.hh"
0011 #include "corecel/Macros.hh"
0012 #include "corecel/math/Algorithms.hh"
0013 #include "celeritas/Types.hh"
0014
0015 namespace celeritas
0016 {
0017 namespace detail
0018 {
0019
0020
0021
0022
0023 class UrbanPositronCorrector
0024 {
0025 public:
0026
0027 explicit inline CELER_FUNCTION UrbanPositronCorrector(real_type zeff);
0028
0029
0030 inline CELER_FUNCTION real_type operator()(real_type y) const;
0031
0032 private:
0033 real_type a_, b_, c_, d_, mult_;
0034 };
0035
0036
0037
0038
0039
0040
0041
0042 CELER_FUNCTION UrbanPositronCorrector::UrbanPositronCorrector(real_type zeff)
0043 {
0044 CELER_EXPECT(zeff >= 1);
0045 using PolyLin = PolyEvaluator<real_type, 1>;
0046 using PolyQuad = PolyEvaluator<real_type, 2>;
0047
0048 a_ = PolyLin(0.994, -4.08e-3)(zeff);
0049 b_ = PolyQuad(7.16, 52.6, 365)(1 / zeff);
0050 c_ = PolyLin(1, -4.47e-3)(zeff);
0051 d_ = real_type(1.21e-3) * zeff;
0052 mult_ = PolyQuad(1.41125, -1.86427e-2, 1.84035e-4)(zeff);
0053 }
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 CELER_FUNCTION real_type UrbanPositronCorrector::operator()(real_type y) const
0065 {
0066 CELER_EXPECT(y > 0);
0067 real_type corr = [this, y] {
0068 constexpr real_type xl = 0.6;
0069 constexpr real_type xh = 0.9;
0070 constexpr real_type e = 113;
0071
0072
0073 real_type x = std::sqrt(y * (y + 2) / ipow<2>(y + 1));
0074 if (x < xl)
0075 {
0076 return a_ * (1 - std::exp(-b_ * x));
0077 }
0078 if (x > xh)
0079 {
0080 return c_ + d_ * std::exp(e * (x - 1));
0081 }
0082 real_type yl = a_ * (1 - std::exp(-b_ * xl));
0083 real_type yh = c_ + d_ * std::exp(e * (xh - 1));
0084 real_type y0 = (yh - yl) / (xh - xl);
0085 real_type y1 = yl - y0 * xl;
0086 return y0 * x + y1;
0087 }();
0088
0089 return corr * mult_;
0090 }
0091
0092
0093 }
0094 }