Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:07

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/mat/IsotopeView.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "celeritas/Quantities.hh"
0011 #include "celeritas/Types.hh"
0012 #include "celeritas/phys/AtomicNumber.hh"
0013 
0014 #include "MaterialData.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Access amalgamated data for a nuclide (isotope of an element).
0021  *
0022  * This encapsulates general data specific to a single nuclide.
0023  *
0024  * \todo This will be renamed to NuclideView.
0025  */
0026 class IsotopeView
0027 {
0028   public:
0029     //!@{
0030     //! \name Type aliases
0031     using MaterialParamsRef = NativeCRef<MaterialParamsData>;
0032     using MevEnergy = units::MevEnergy;
0033     using MevMass = units::MevMass;
0034     using AtomicMassNumber = AtomicNumber;
0035     //!@}
0036 
0037   public:
0038     // Construct from shared material data and global isotope ID
0039     inline CELER_FUNCTION
0040     IsotopeView(MaterialParamsRef const& params, IsotopeId isot_id);
0041 
0042     // ID of this isotope
0043     CELER_FORCEINLINE_FUNCTION IsotopeId isotope_id() const;
0044 
0045     // Atomic number Z
0046     CELER_FORCEINLINE_FUNCTION AtomicNumber atomic_number() const;
0047 
0048     // Atomic number A
0049     CELER_FORCEINLINE_FUNCTION AtomicMassNumber atomic_mass_number() const;
0050 
0051     // Nuclear binding energy
0052     CELER_FORCEINLINE_FUNCTION MevEnergy binding_energy() const;
0053 
0054     // Nuclear binding energy difference for a proton loss
0055     CELER_FORCEINLINE_FUNCTION MevEnergy proton_loss_energy() const;
0056 
0057     // Nuclear binding energy difference for a neutron loss
0058     CELER_FORCEINLINE_FUNCTION MevEnergy neutron_loss_energy() const;
0059 
0060     // Sum of nucleons + binding energy
0061     CELER_FORCEINLINE_FUNCTION MevMass nuclear_mass() const;
0062 
0063   private:
0064     MaterialParamsRef const& params_;
0065     IsotopeId isotope_;
0066 
0067     // HELPER FUNCTIONS
0068 
0069     CELER_FORCEINLINE_FUNCTION IsotopeRecord const& isotope_def() const
0070     {
0071         return params_.isotopes[isotope_];
0072     }
0073 };
0074 
0075 //---------------------------------------------------------------------------//
0076 // INLINE DEFINITIONS
0077 //---------------------------------------------------------------------------//
0078 /*!
0079  * Construct from shared material data and global isotope ID.
0080  */
0081 CELER_FUNCTION
0082 IsotopeView::IsotopeView(MaterialParamsRef const& params, IsotopeId isot_id)
0083     : params_{params}, isotope_{isot_id}
0084 {
0085     CELER_EXPECT(isotope_ < params.isotopes.size());
0086 }
0087 
0088 //---------------------------------------------------------------------------//
0089 /*!
0090  * Isotope ID.
0091  */
0092 CELER_FUNCTION IsotopeId IsotopeView::isotope_id() const
0093 {
0094     return isotope_;
0095 }
0096 
0097 //---------------------------------------------------------------------------//
0098 /*!
0099  * Atomic number Z.
0100  */
0101 CELER_FUNCTION AtomicNumber IsotopeView::atomic_number() const
0102 {
0103     return isotope_def().atomic_number;
0104 }
0105 
0106 //---------------------------------------------------------------------------//
0107 /*!
0108  * Atomic number A.
0109  */
0110 CELER_FUNCTION IsotopeView::AtomicMassNumber
0111 IsotopeView::atomic_mass_number() const
0112 {
0113     return isotope_def().atomic_mass_number;
0114 }
0115 
0116 //---------------------------------------------------------------------------//
0117 /*!
0118  * Nuclear binding energy.
0119  */
0120 CELER_FUNCTION units::MevEnergy IsotopeView::binding_energy() const
0121 {
0122     return isotope_def().binding_energy;
0123 }
0124 
0125 //---------------------------------------------------------------------------//
0126 /*!
0127  * Nuclear binding energy difference for a proton loss.
0128  */
0129 CELER_FUNCTION units::MevEnergy IsotopeView::proton_loss_energy() const
0130 {
0131     return isotope_def().proton_loss_energy;
0132 }
0133 
0134 //---------------------------------------------------------------------------//
0135 /*!
0136  * Nuclear binding energy difference for a neutron loss.
0137  */
0138 CELER_FUNCTION units::MevEnergy IsotopeView::neutron_loss_energy() const
0139 {
0140     return isotope_def().neutron_loss_energy;
0141 }
0142 
0143 //---------------------------------------------------------------------------//
0144 /*!
0145  * Nuclear mass, the sum of the nucleons' mass and their binding energy.
0146  */
0147 CELER_FUNCTION units::MevMass IsotopeView::nuclear_mass() const
0148 {
0149     return isotope_def().nuclear_mass;
0150 }
0151 
0152 //---------------------------------------------------------------------------//
0153 }  // namespace celeritas