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/NeutronElasticMicroXsCalculator.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/NeutronElasticData.hh"
0018 
0019 namespace celeritas
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Calculate neutron elastic cross sections from NeutronElasticXsData
0024  */
0025 class NeutronElasticMicroXsCalculator
0026 {
0027   public:
0028     //!@{
0029     //! \name Type aliases
0030     using ParamsRef = NeutronElasticRef;
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     NeutronElasticMicroXsCalculator(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     NeutronElasticRef 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 NeutronElasticMicroXsCalculator::NeutronElasticMicroXsCalculator(
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 NeutronElasticMicroXsCalculator::operator()(ElementId el_id) const -> BarnXs
0068 {
0069     CELER_EXPECT(el_id < shared_.micro_xs.size());
0070 
0071     // Calculate micro cross section at the given energy
0072     GenericCalculator calc_xs(shared_.micro_xs[el_id], shared_.reals);
0073     real_type result = calc_xs(inc_energy_);
0074 
0075     return BarnXs{result};
0076 }
0077 
0078 //---------------------------------------------------------------------------//
0079 }  // namespace celeritas