Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-03 10:18:54

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/Constants.hh
0006 //! \brief Mathematical, numerical, and physical constants
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Config.hh"
0011 
0012 #include "corecel/Constants.hh"
0013 
0014 #include "Units.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Mathematical, numerical, and physical constants.
0021  *
0022  * Some of the physical
0023  * constants listed here are *exact* numerical values: see \citet{si-2019,
0024  * https://www.bipm.org/en/publications/si-brochure} for definition of
0025  * constants and how they relate to the different units.
0026  *
0027  * Celeritas            | CLHEP                   | Notes
0028  * -------------------- | ---------------------   | ------------
0029  * a0_bohr              | Bohr_radius             | Bohr radius
0030  * alpha_fine_structure | fine_structure_const    | |
0031  * atomic_mass          | amu                     | Not the same as 1/avogadro
0032  * eps_electric         | epsilon0                | Vacuum permittivity
0033  * h_planck             | h_Planck                | |
0034  * k_boltzmann          | k_Boltzmann             | |
0035  * mu_magnetic          | mu0                     | Vacuum permeability
0036  * na_avogadro          | Avogadro                | [1/mol]
0037  * r_electron           | classic_electr_radius   | Classical electron radius
0038  * kcd_luminous         | [none]                  | Lumens per Watt
0039  * lambdabar_electron   | electron_Compton_length | Reduced Compton wavelength
0040  * stable_decay_constant| [none]                  | Decay for a stable particle
0041  *
0042  * In the CLHEP unit system, the value of the constant \c e_electron is defined
0043  * to be 1 and \c coulomb is derivative from that. To avoid floating point
0044  * arithmetic issues that would lead to the "units" and "constants" having
0045  * different values for it, a special case redefines the value for CLHEP.
0046  *
0047  * Some experimental physical constants are derived from the other physical
0048  * constants, but for consistency and clarity they are presented numerically
0049  * with the units provided in the CODATA 2018 or 2022 datasets. The
0050  * \c CELERITAS_CODATA cmake variable determines which of the two datasets is
0051  * "inlined" into the \c celeritas namespace, allowing fine-grain transition
0052  * for classes that require it.
0053  * The \c Constants.test.cc
0054  * unit tests compare the numerical value against the derivative values inside
0055  * the celeritas unit system. All experimental values include the final
0056  * (usually two) imprecise digits; their precision is usually on the order of
0057  * \f$ 10^{-11} \f$.
0058  */
0059 namespace constants
0060 {
0061 //---------------------------------------------------------------------------//
0062 
0063 #define CELER_ICC inline constexpr Constant
0064 
0065 //!@{
0066 //! \name Physical constants with exact value as defined by SI
0067 CELER_ICC c_light = Constant{299792458.} * units::meter / units::second;
0068 CELER_ICC h_planck = Constant{6.62607015e-34} * units::joule * units::second;
0069 #if CELERITAS_UNITS != CELERITAS_UNITS_CLHEP
0070 CELER_ICC e_electron = Constant{1.602176634e-19} * units::coulomb;
0071 #endif
0072 CELER_ICC k_boltzmann = Constant{1.380649e-23} * units::joule / units::kelvin;
0073 CELER_ICC na_avogadro{6.02214076e23};
0074 CELER_ICC kcd_luminous{683};
0075 //!@}
0076 
0077 #if CELERITAS_UNITS == CELERITAS_UNITS_CLHEP
0078 //!@{
0079 //! \name Special cases for CLHEP
0080 //! Electron charge is unity by definition
0081 CELER_ICC e_electron{1};
0082 //!@}
0083 #endif
0084 
0085 //!@{
0086 //! \name Exact derivative constants
0087 CELER_ICC hbar_planck{h_planck / (2 * pi)};
0088 //!@}
0089 
0090 //! Experimental physical constants from CODATA 2006
0091 #if CELERITAS_CODATA == CELERITAS_CODATA_2006
0092 inline
0093 #endif
0094     namespace codata2006
0095 {
0096 CELER_ICC a0_bohr = Constant{5.2917720859e-11} * units::meter;
0097 CELER_ICC alpha_fine_structure = Constant{7.2973525376e-3};
0098 CELER_ICC atomic_mass = Constant{1.660538782e-24} * units::gram;
0099 CELER_ICC electron_mass = Constant{9.10938215e-28} * units::gram;
0100 CELER_ICC proton_mass = Constant{1.672621637e-24} * units::gram;
0101 CELER_ICC eps_electric = Constant{8.854187817e-12} * units::farad
0102                          / units::meter;
0103 CELER_ICC mu_magnetic = Constant{1.2566370614e-6} * units::newton
0104                         / (units::ampere * units::ampere);
0105 CELER_ICC r_electron = Constant{2.8179402894e-15} * units::meter;
0106 CELER_ICC rinf_rydberg = Constant{10973731.568527} / units::meter;
0107 CELER_ICC eh_hartree = Constant{4.35974394e-18} / units::meter;
0108 CELER_ICC lambdabar_electron = Constant{3.8615926459e-13} * units::meter;
0109 }
0110 
0111 //! Experimental physical constants from CODATA 2018
0112 #if CELERITAS_CODATA == CELERITAS_CODATA_2018
0113 inline
0114 #endif
0115     namespace codata2018
0116 {
0117 CELER_ICC a0_bohr = Constant{5.29177210903e-11} * units::meter;
0118 CELER_ICC alpha_fine_structure = Constant{7.2973525693e-3};
0119 CELER_ICC atomic_mass = Constant{1.66053906660e-24} * units::gram;
0120 CELER_ICC electron_mass = Constant{9.1093837015e-28} * units::gram;
0121 CELER_ICC proton_mass = Constant{1.67262192369e-24} * units::gram;
0122 CELER_ICC eps_electric = Constant{8.8541878128e-12} * units::farad
0123                          / units::meter;
0124 CELER_ICC mu_magnetic = Constant{1.25663706212e-6} * units::newton
0125                         / (units::ampere * units::ampere);
0126 CELER_ICC r_electron = Constant{2.8179403262e-15} * units::meter;
0127 CELER_ICC rinf_rydberg = Constant{10973731.568160} / units::meter;
0128 CELER_ICC eh_hartree = Constant{4.3597447222071e-18} / units::meter;
0129 CELER_ICC lambdabar_electron = Constant{3.8615926796e-13} * units::meter;
0130 }
0131 
0132 //! Experimental physical constants from CODATA 2022
0133 #if CELERITAS_CODATA == CELERITAS_CODATA_2022
0134 inline
0135 #endif
0136     namespace codata2022
0137 {
0138 CELER_ICC a0_bohr = Constant{5.29177210544e-11} * units::meter;
0139 CELER_ICC alpha_fine_structure = Constant{7.2973525643e-3};
0140 CELER_ICC atomic_mass = Constant{1.66053906892e-24} * units::gram;
0141 CELER_ICC electron_mass = Constant{9.1093837139e-28} * units::gram;
0142 CELER_ICC proton_mass = Constant{1.67262192595e-24} * units::gram;
0143 CELER_ICC eps_electric = Constant{8.8541878188e-12} * units::farad
0144                          / units::meter;
0145 CELER_ICC mu_magnetic = Constant{1.25663706127e-6} * units::newton
0146                         / (units::ampere * units::ampere);
0147 CELER_ICC r_electron = Constant{2.8179403205e-15} * units::meter;
0148 CELER_ICC rinf_rydberg = Constant{10973731.568157} / units::meter;
0149 CELER_ICC eh_hartree = Constant{4.3597447222060e-18} / units::meter;
0150 CELER_ICC lambdabar_electron = Constant{3.8615926744e-13} * units::meter;
0151 }
0152 
0153 //!@{
0154 //! \name Other constants with physical meaning
0155 inline constexpr int stable_decay_constant{0};
0156 //!@}
0157 
0158 #undef CELER_ICC
0159 
0160 //---------------------------------------------------------------------------//
0161 }  // namespace constants
0162 }  // namespace celeritas