Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:11:41

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/neutron/xs/NeutronElasticMicroXsCalculator.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/Quantity.hh"
0013 #include "celeritas/Quantities.hh"
0014 #include "celeritas/Types.hh"
0015 #include "celeritas/grid/NonuniformGridCalculator.hh"
0016 #include "celeritas/neutron/data/NeutronElasticData.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Calculate neutron elastic cross sections from NeutronElasticXsData
0023  */
0024 class NeutronElasticMicroXsCalculator
0025 {
0026   public:
0027     //!@{
0028     //! \name Type aliases
0029     using ParamsRef = NeutronElasticRef;
0030     using Energy = units::MevEnergy;
0031     using BarnXs = units::BarnXs;
0032     //!@}
0033 
0034   public:
0035     // Construct with shared and state data
0036     inline CELER_FUNCTION
0037     NeutronElasticMicroXsCalculator(ParamsRef const& shared, Energy energy);
0038 
0039     // Compute cross section
0040     inline CELER_FUNCTION BarnXs operator()(ElementId el_id) const;
0041 
0042   private:
0043     // Shared constant physics properties
0044     NeutronElasticRef const& shared_;
0045     // Incident neutron energy
0046     real_type const inc_energy_;
0047 };
0048 
0049 //---------------------------------------------------------------------------//
0050 // INLINE DEFINITIONS
0051 //---------------------------------------------------------------------------//
0052 /*!
0053  * Construct with shared and state data.
0054  */
0055 CELER_FUNCTION NeutronElasticMicroXsCalculator::NeutronElasticMicroXsCalculator(
0056     ParamsRef const& shared, Energy energy)
0057     : shared_(shared), inc_energy_(energy.value())
0058 {
0059 }
0060 
0061 //---------------------------------------------------------------------------//
0062 /*!
0063  * Compute microscopic (element) cross section
0064  */
0065 CELER_FUNCTION
0066 auto NeutronElasticMicroXsCalculator::operator()(ElementId el_id) const -> BarnXs
0067 {
0068     CELER_EXPECT(el_id < shared_.micro_xs.size());
0069 
0070     // Calculate micro cross section at the given energy
0071     NonuniformGridCalculator calc_xs(shared_.micro_xs[el_id], shared_.reals);
0072     real_type result = calc_xs(inc_energy_);
0073 
0074     return BarnXs{result};
0075 }
0076 
0077 //---------------------------------------------------------------------------//
0078 }  // namespace celeritas