Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2020-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/data/AtomicRelaxationData.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Macros.hh"
0011 #include "corecel/Types.hh"
0012 #include "corecel/cont/Range.hh"
0013 #include "corecel/data/Collection.hh"
0014 #include "corecel/data/CollectionBuilder.hh"
0015 #include "celeritas/Quantities.hh"
0016 #include "celeritas/Types.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Atomic relaxation transition data. The transition probabilities describe
0023  * both radiative and non-radiative transitions.
0024  */
0025 struct AtomicRelaxTransition
0026 {
0027     SubshellId initial_shell;  //!< Index of the originating shell
0028     SubshellId auger_shell;  //!< Index of the Auger electron shell
0029     real_type probability;
0030     units::MevEnergy energy;
0031 };
0032 
0033 //---------------------------------------------------------------------------//
0034 /*!
0035  * Electron subshell data.
0036  */
0037 struct AtomicRelaxSubshell
0038 {
0039     ItemRange<AtomicRelaxTransition> transitions;
0040 };
0041 
0042 //---------------------------------------------------------------------------//
0043 /*!
0044  * Elemental atomic relaxation data.
0045  */
0046 struct AtomicRelaxElement
0047 {
0048     ItemRange<AtomicRelaxSubshell> shells;
0049     size_type max_secondary;  //!< Maximum number of secondaries possible
0050 
0051     //! Check whether the element is assigned (false for Z < 6).
0052     explicit CELER_FUNCTION operator bool() const
0053     {
0054         return !shells.empty() && max_secondary > 0;
0055     }
0056 };
0057 
0058 struct AtomicRelaxIds
0059 {
0060     ParticleId electron;
0061     ParticleId gamma;
0062 
0063     //! Check whether IDs are assigned
0064     explicit CELER_FUNCTION operator bool() const { return electron && gamma; }
0065 };
0066 
0067 //---------------------------------------------------------------------------//
0068 /*!
0069  * Electron subshell transition data for atomic relaxation.
0070  */
0071 template<Ownership W, MemSpace M>
0072 struct AtomicRelaxParamsData
0073 {
0074     template<class T>
0075     using Items = Collection<T, W, M>;
0076     template<class T>
0077     using ElementItems = Collection<T, W, M, ElementId>;
0078 
0079     //// MEMBER DATA ////
0080 
0081     AtomicRelaxIds ids;
0082     Items<AtomicRelaxTransition> transitions;
0083     Items<AtomicRelaxSubshell> shells;
0084     ElementItems<AtomicRelaxElement> elements;
0085     size_type max_stack_size{};
0086 
0087     //// MEMBER FUNCTIONS ////
0088 
0089     //! Check whether the data is assigned
0090     explicit CELER_FUNCTION operator bool() const
0091     {
0092         return ids && !transitions.empty() && !shells.empty()
0093                && !elements.empty() && max_stack_size > 0;
0094     }
0095 
0096     //! Assign from another set of data
0097     template<Ownership W2, MemSpace M2>
0098     AtomicRelaxParamsData& operator=(AtomicRelaxParamsData<W2, M2> const& other)
0099     {
0100         ids = other.ids;
0101         transitions = other.transitions;
0102         shells = other.shells;
0103         elements = other.elements;
0104         max_stack_size = other.max_stack_size;
0105         return *this;
0106     }
0107 };
0108 
0109 using AtomicRelaxParamsRef = NativeCRef<AtomicRelaxParamsData>;
0110 
0111 //---------------------------------------------------------------------------//
0112 /*!
0113  * Temporary data needed during interaction.
0114  */
0115 template<Ownership W, MemSpace M>
0116 struct AtomicRelaxStateData
0117 {
0118     template<class T>
0119     using Items = StateCollection<T, W, M>;
0120 
0121     //! Storage for the stack of vacancy subshell IDs
0122     Items<SubshellId> scratch;  // 2D array: [num states][max stack size]
0123     size_type num_states;
0124 
0125     //! Whether the interface is assigned
0126     explicit CELER_FUNCTION operator bool() const
0127     {
0128         return !scratch.empty() && num_states > 0;
0129     }
0130 
0131     //! State size
0132     CELER_FUNCTION size_type size() const { return num_states; }
0133 
0134     //! Assign from another set of states
0135     template<Ownership W2, MemSpace M2>
0136     AtomicRelaxStateData& operator=(AtomicRelaxStateData<W2, M2>& other)
0137     {
0138         scratch = other.scratch;
0139         num_states = other.num_states;
0140         return *this;
0141     }
0142 };
0143 
0144 using AtomicRelaxStateRef = NativeRef<AtomicRelaxStateData>;
0145 
0146 //---------------------------------------------------------------------------//
0147 /*!
0148  * Resize state data in host code.
0149  */
0150 template<MemSpace M>
0151 inline void resize(AtomicRelaxStateData<Ownership::value, M>* state,
0152                    HostCRef<AtomicRelaxParamsData> const& params,
0153                    size_type size)
0154 {
0155     CELER_EXPECT(size > 0);
0156     resize(&state->scratch, size * params.max_stack_size);
0157     state->num_states = size;
0158 }
0159 
0160 //---------------------------------------------------------------------------//
0161 }  // namespace celeritas