Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 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/neutron/xs/NeutronInelasticMicroXsCalculator.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/grid/GenericCalculator.hh"
0017 #include "celeritas/neutron/data/NeutronInelasticData.hh"
0018 
0019 namespace celeritas
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Calculate neutron inelastic cross sections from NeutronInelasticData
0024  */
0025 class NeutronInelasticMicroXsCalculator
0026 {
0027   public:
0028     //!@{
0029     //! \name Type aliases
0030     using ParamsRef = NeutronInelasticRef;
0031     using Energy = units::MevEnergy;
0032     using BarnXs = units::BarnXs;
0033     //!@}
0034 
0035   public:
0036     // Construct with shared and state data
0037     inline CELER_FUNCTION
0038     NeutronInelasticMicroXsCalculator(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     NeutronInelasticRef const& shared_;
0046     // Incident neutron energy
0047     real_type const inc_energy_;
0048 };
0049 
0050 //---------------------------------------------------------------------------//
0051 // INLINE DEFINITIONS
0052 //---------------------------------------------------------------------------//
0053 /*!
0054  * Construct with shared and state data.
0055  */
0056 CELER_FUNCTION
0057 NeutronInelasticMicroXsCalculator::NeutronInelasticMicroXsCalculator(
0058     ParamsRef const& shared, Energy energy)
0059     : shared_(shared), inc_energy_(energy.value())
0060 {
0061 }
0062 
0063 //---------------------------------------------------------------------------//
0064 /*!
0065  * Compute microscopic (element) cross section
0066  */
0067 CELER_FUNCTION
0068 auto NeutronInelasticMicroXsCalculator::operator()(ElementId el_id) const -> BarnXs
0069 {
0070     CELER_EXPECT(el_id < shared_.micro_xs.size());
0071 
0072     // Get element cross section data
0073     GenericGridRecord grid = shared_.micro_xs[el_id];
0074 
0075     // Calculate micro cross section at the given energy
0076     GenericCalculator calc_xs(grid, shared_.reals);
0077     real_type result = calc_xs(inc_energy_);
0078 
0079     return BarnXs{result};
0080 }
0081 
0082 //---------------------------------------------------------------------------//
0083 }  // namespace celeritas