Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-12 08:52:52

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/NeutronInelasticMicroXsCalculator.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/NeutronInelasticData.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Calculate neutron inelastic cross sections from NeutronInelasticData
0023  */
0024 class NeutronInelasticMicroXsCalculator
0025 {
0026   public:
0027     //!@{
0028     //! \name Type aliases
0029     using ParamsRef = NeutronInelasticRef;
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     NeutronInelasticMicroXsCalculator(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     NeutronInelasticRef 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
0056 NeutronInelasticMicroXsCalculator::NeutronInelasticMicroXsCalculator(
0057     ParamsRef const& shared, Energy energy)
0058     : shared_(shared), inc_energy_(energy.value())
0059 {
0060 }
0061 
0062 //---------------------------------------------------------------------------//
0063 /*!
0064  * Compute microscopic (element) cross section
0065  */
0066 CELER_FUNCTION
0067 auto NeutronInelasticMicroXsCalculator::operator()(ElementId el_id) const -> BarnXs
0068 {
0069     CELER_EXPECT(el_id < shared_.micro_xs.size());
0070 
0071     // Get element cross section data
0072     NonuniformGridRecord grid = shared_.micro_xs[el_id];
0073 
0074     // Calculate micro cross section at the given energy
0075     NonuniformGridCalculator calc_xs(grid, shared_.reals);
0076     real_type result = calc_xs(inc_energy_);
0077 
0078     return BarnXs{result};
0079 }
0080 
0081 //---------------------------------------------------------------------------//
0082 }  // namespace celeritas