Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:19

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