Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:36

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/em/xs/LivermorePEMicroXsCalculator.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/math/Algorithms.hh"
0012 #include "corecel/math/PolyEvaluator.hh"
0013 #include "corecel/math/Quantity.hh"
0014 #include "celeritas/Quantities.hh"
0015 #include "celeritas/Types.hh"
0016 #include "celeritas/em/data/LivermorePEData.hh"
0017 #include "celeritas/grid/NonuniformGridCalculator.hh"
0018 
0019 namespace celeritas
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Calculate photoelectric effect cross sections using the Livermore data.
0024  */
0025 class LivermorePEMicroXsCalculator
0026 {
0027   public:
0028     //!@{
0029     //! \name Type aliases
0030     using ParamsRef = LivermorePERef;
0031     using Energy = RealQuantity<LivermoreSubshell::EnergyUnits>;
0032     using BarnXs = units::BarnXs;
0033     //!@}
0034 
0035   public:
0036     // Construct with shared and state data
0037     inline CELER_FUNCTION
0038     LivermorePEMicroXsCalculator(ParamsRef const& shared, Energy energy);
0039 
0040     // Compute cross section
0041     inline CELER_FUNCTION BarnXs operator()(ElementId el_id) const;
0042 
0043   private:
0044     // Shared constant physics properties
0045     LivermorePERef const& shared_;
0046     // Incident gamma energy
0047     Energy const inc_energy_;
0048 };
0049 
0050 //---------------------------------------------------------------------------//
0051 // INLINE DEFINITIONS
0052 //---------------------------------------------------------------------------//
0053 /*!
0054  * Construct with shared and state data.
0055  */
0056 CELER_FUNCTION LivermorePEMicroXsCalculator::LivermorePEMicroXsCalculator(
0057     ParamsRef const& shared, Energy energy)
0058     : shared_(shared), inc_energy_(energy.value())
0059 {
0060 }
0061 
0062 //---------------------------------------------------------------------------//
0063 /*!
0064  * Compute cross section.
0065  */
0066 CELER_FUNCTION
0067 auto LivermorePEMicroXsCalculator::operator()(ElementId el_id) const -> BarnXs
0068 {
0069     CELER_EXPECT(el_id);
0070     LivermoreElement const& el = shared_.xs.elements[el_id];
0071     auto const& shells = shared_.xs.shells[el.shells];
0072 
0073     // In Geant4, if the incident gamma energy is below the lowest binding
0074     // energy, it is set to the binding energy so that the photoelectric cross
0075     // section is constant rather than zero for low energy gammas.
0076     Energy energy = max(inc_energy_, shells.back().binding_energy);
0077     real_type inv_energy = 1. / energy.value();
0078 
0079     real_type result = 0.;
0080     if (energy >= el.thresh_lo)
0081     {
0082         // Fit parameters from the final shell are used to calculate the cross
0083         // section integrated over all subshells
0084         auto const& param = shells.back().param[energy < el.thresh_hi ? 0 : 1];
0085         PolyEvaluator<real_type, 5> eval_poly(param);
0086 
0087         // Use the parameterization of the integrated subshell cross sections
0088         result = inv_energy * eval_poly(inv_energy);
0089     }
0090     else if (energy >= shells.front().binding_energy)
0091     {
0092         // Use tabulated cross sections above K-shell energy but below energy
0093         // limit for parameterization
0094         NonuniformGridCalculator calc_xs(el.xs_hi, shared_.xs.reals);
0095         result = ipow<3>(inv_energy) * calc_xs(energy.value());
0096     }
0097     else
0098     {
0099         CELER_ASSERT(el.xs_lo);
0100         // Use tabulated cross sections below K-shell energy
0101         NonuniformGridCalculator calc_xs(el.xs_lo, shared_.xs.reals);
0102         result = ipow<3>(inv_energy) * calc_xs(energy.value());
0103     }
0104     return BarnXs{result};
0105 }
0106 
0107 //---------------------------------------------------------------------------//
0108 }  // namespace celeritas