Back to home page

EIC code displayed by LXR

 
 

    


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

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/em/detail/Utils.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <unordered_map>
0010 
0011 #include "corecel/Macros.hh"
0012 #include "corecel/Types.hh"
0013 #include "corecel/cont/Span.hh"
0014 #include "corecel/data/Collection.hh"
0015 #include "celeritas/Quantities.hh"
0016 #include "celeritas/Types.hh"
0017 
0018 #include "../data/AtomicRelaxationData.hh"
0019 
0020 namespace celeritas
0021 {
0022 namespace detail
0023 {
0024 //---------------------------------------------------------------------------//
0025 /*!
0026  * Helper class for calculating the maximum possible number of secondaries
0027  * produced in atomic relaxation for a given element and electron/photon
0028  * production threshold.
0029  */
0030 class MaxSecondariesCalculator
0031 {
0032   public:
0033     //!@{
0034     //! \name Type aliases
0035     using Energy = units::MevEnergy;
0036     using Values = HostCRef<AtomicRelaxParamsData>;
0037     //!@}
0038 
0039   public:
0040     // Construct with EADL transition data and production thresholds
0041     MaxSecondariesCalculator(Values const& data,
0042                              ItemRange<AtomicRelaxSubshell> const& shells,
0043                              Energy electron_cut,
0044                              Energy gamma_cut);
0045 
0046     // Calculate the maximum possible number of secondaries produced
0047     size_type operator()();
0048 
0049   private:
0050     Values const& data_;
0051     Span<AtomicRelaxSubshell const> shells_;
0052     Energy const electron_cut_;
0053     Energy const gamma_cut_;
0054     std::unordered_map<SubshellId, size_type> visited_;
0055 
0056     // HELPER FUNCTIONS
0057 
0058     size_type calc(SubshellId vacancy_shell, size_type count);
0059 };
0060 
0061 //---------------------------------------------------------------------------//
0062 /*!
0063  * Helper class for calculating the maximum size the stack of unprocessed
0064  * subshell vacancies can grow to for a given element while simulating the
0065  * cascade of photons and electrons in atomic relaxation.
0066  */
0067 class MaxStackSizeCalculator
0068 {
0069   public:
0070     //!@{
0071     //! \name Type aliases
0072     using Values = HostCRef<AtomicRelaxParamsData>;
0073     //!@}
0074 
0075   public:
0076     // Construct with EADL transition data
0077     MaxStackSizeCalculator(Values const& data,
0078                            ItemRange<AtomicRelaxSubshell> const& shells);
0079 
0080     // Calculate the maximum size of the stack
0081     size_type operator()();
0082 
0083   private:
0084     Values const& data_;
0085     Span<AtomicRelaxSubshell const> shells_;
0086     std::unordered_map<SubshellId, size_type> visited_;
0087 
0088     // HELPER FUNCTIONS
0089 
0090     size_type calc(SubshellId vacancy_shell);
0091 };
0092 
0093 //---------------------------------------------------------------------------//
0094 // Calculate the maximum possible secondaries produced in atomic relaxation
0095 size_type calc_max_secondaries(MaxSecondariesCalculator::Values const& data,
0096                                ItemRange<AtomicRelaxSubshell> const& shells,
0097                                units::MevEnergy electron_cut,
0098                                units::MevEnergy gamma_cut);
0099 
0100 // Calculate the maximum size of the vacancy stack in atomic relaxation
0101 size_type calc_max_stack_size(MaxStackSizeCalculator::Values const& data,
0102                               ItemRange<AtomicRelaxSubshell> const& shells);
0103 
0104 //---------------------------------------------------------------------------//
0105 }  // namespace detail
0106 }  // namespace celeritas