Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-05 10:27:48

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/ElectroNuclearMicroXsCalculator.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "celeritas/Quantities.hh"
0012 #include "celeritas/Types.hh"
0013 #include "celeritas/em/data/ElectroNuclearData.hh"
0014 #include "celeritas/grid/NonuniformGridCalculator.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Calculate electro-nuclear cross sections.
0021  */
0022 class ElectroNuclearMicroXsCalculator
0023 {
0024   public:
0025     //!@{
0026     //! \name Type aliases
0027     using ParamsRef = NativeCRef<ElectroNuclearData>;
0028     using Energy = units::MevEnergy;
0029     using BarnXs = units::BarnXs;
0030     //!@}
0031 
0032   public:
0033     // Construct with shared and state data
0034     inline CELER_FUNCTION ElectroNuclearMicroXsCalculator(
0035         ParamsRef const& shared, Energy energy);
0036 
0037     // Compute cross section
0038     inline CELER_FUNCTION BarnXs operator()(ElementId el_id) const;
0039 
0040   private:
0041     // Shared cross section data
0042     ParamsRef const& data_;
0043     // Incident particle energy
0044     real_type const inc_energy_;
0045 };
0046 
0047 //---------------------------------------------------------------------------//
0048 // INLINE DEFINITIONS
0049 //---------------------------------------------------------------------------//
0050 /*!
0051  * Construct with shared and state data.
0052  */
0053 CELER_FUNCTION ElectroNuclearMicroXsCalculator::ElectroNuclearMicroXsCalculator(
0054     ParamsRef const& data, Energy energy)
0055     : data_(data), inc_energy_(energy.value())
0056 {
0057 }
0058 
0059 //---------------------------------------------------------------------------//
0060 /*!
0061  * Compute microscopic electro-nuclear cross section at the given particle
0062  * energy.
0063  */
0064 CELER_FUNCTION auto ElectroNuclearMicroXsCalculator::operator()(
0065     ElementId el_id) const -> BarnXs
0066 {
0067     NonuniformGridRecord grid;
0068 
0069     // Use tabulated electro-nuclear micro cross sections
0070     CELER_EXPECT(el_id < data_.micro_xs.size());
0071     grid = data_.micro_xs[el_id];
0072 
0073     // Calculate micro cross section at the given energy
0074     NonuniformGridCalculator calc_micro_xs(grid, data_.reals);
0075     real_type result = calc_micro_xs(inc_energy_);
0076 
0077     return BarnXs{result};
0078 }
0079 
0080 //---------------------------------------------------------------------------//
0081 }  // namespace celeritas