Back to home page

EIC code displayed by LXR

 
 

    


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

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/em/model/detail/LivermoreXsInserter.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/data/CollectionBuilder.hh"
0011 #include "celeritas/em/data/LivermorePEData.hh"
0012 #include "celeritas/grid/GenericGridBuilder.hh"
0013 #include "celeritas/io/ImportLivermorePE.hh"
0014 #include "celeritas/io/ImportPhysicsVector.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace detail
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Construct Livermore Photoelectric cross section data from imported data.
0023  */
0024 class LivermoreXsInserter
0025 {
0026   public:
0027     //!@{
0028     //! \name Type aliases
0029     using Data = HostVal<LivermorePEXsData>;
0030     //!@}
0031 
0032   public:
0033     // Construct with pointer to host data
0034     explicit inline LivermoreXsInserter(Data* data);
0035 
0036     // Construct cross section data for a single element
0037     inline void operator()(ImportLivermorePE const& inp);
0038 
0039   private:
0040     GenericGridBuilder build_grid_;
0041 
0042     CollectionBuilder<LivermoreSubshell> shells_;
0043     CollectionBuilder<LivermoreElement, MemSpace::host, ElementId> elements_;
0044 };
0045 
0046 //---------------------------------------------------------------------------//
0047 // INLINE DEFINITIONS
0048 //---------------------------------------------------------------------------//
0049 /*!
0050  * Construct with data.
0051  */
0052 LivermoreXsInserter::LivermoreXsInserter(Data* data)
0053     : build_grid_{&data->reals}
0054     , shells_{&data->shells}
0055     , elements_{&data->elements}
0056 {
0057     CELER_EXPECT(data);
0058 }
0059 
0060 //---------------------------------------------------------------------------//
0061 /*!
0062  * Construct cross section data for a single element.
0063  */
0064 void LivermoreXsInserter::operator()(ImportLivermorePE const& inp)
0065 {
0066     CELER_EXPECT(!inp.shells.empty());
0067     if constexpr (CELERITAS_DEBUG)
0068     {
0069         CELER_EXPECT(inp.thresh_lo <= inp.thresh_hi);
0070         for (auto const& shell : inp.shells)
0071         {
0072             CELER_EXPECT(shell.param_lo.size() == 6);
0073             CELER_EXPECT(shell.param_hi.size() == 6);
0074             CELER_EXPECT(shell.binding_energy <= inp.thresh_lo);
0075         }
0076     }
0077     using units::MevEnergy;
0078 
0079     LivermoreElement el;
0080 
0081     // Add tabulated total cross sections
0082     if (inp.xs_lo)
0083     {
0084         // Z < 3 have no low-energy cross sections
0085         el.xs_lo = build_grid_(inp.xs_lo);
0086     }
0087     el.xs_hi = build_grid_(inp.xs_hi);
0088 
0089     // Add energy thresholds for using low and high xs parameterization
0090     el.thresh_lo = MevEnergy(inp.thresh_lo);
0091     el.thresh_hi = MevEnergy(inp.thresh_hi);
0092 
0093     // Allocate subshell data
0094     std::vector<LivermoreSubshell> shells(inp.shells.size());
0095 
0096     // Add subshell data
0097     for (auto i : range(inp.shells.size()))
0098     {
0099         // Ionization energy
0100         shells[i].binding_energy = MevEnergy(inp.shells[i].binding_energy);
0101 
0102         // Tabulated subshell cross section
0103         shells[i].xs = build_grid_(make_span(inp.shells[i].energy),
0104                                    make_span(inp.shells[i].xs));
0105 
0106         // Subshell cross section fit parameters
0107         std::copy(inp.shells[i].param_lo.begin(),
0108                   inp.shells[i].param_lo.end(),
0109                   shells[i].param[0].begin());
0110         std::copy(inp.shells[i].param_hi.begin(),
0111                   inp.shells[i].param_hi.end(),
0112                   shells[i].param[1].begin());
0113 
0114         CELER_ASSERT(shells[i]);
0115     }
0116     el.shells = shells_.insert_back(shells.begin(), shells.end());
0117 
0118     // Add the elemental data
0119     CELER_ASSERT(el);
0120     elements_.push_back(el);
0121 
0122     CELER_ENSURE(el.shells.size() == inp.shells.size());
0123 }
0124 
0125 //---------------------------------------------------------------------------//
0126 }  // namespace detail
0127 }  // namespace celeritas