Physical Constants

O2scl

Constant contents

Constant introduction

In order to avoid confusing numerical differences when using multiprecision arithmetic, physical constants are template functions which return a value given a user-specified floating-point type. Physical constants are promoted to higher precision by adding zeros in the base-10 representation. The constants are in the namespace o2scl_const. The numerical values are periodically updated with CODATA, the Particle Data Book, and other databases. A handful of constants have a short name for their values in double precision, see below.

The find_constants class contains a simple constant database which can be searched at compiled time and also provides the constant database to acol -constants (see The acol Command Line Utility).

These physical constants can also be used to create unit conversion factors, described in Unit Conversions.

Namespace o2scl_const

Top

namespace o2scl_const

Constants.

Previous versions contained constants from [Luzum11] and [Mohr12] .

CODATA 2022 values are from physics.nist.gov/constants. IAU 2015 values are the nominal values from arXiv:1510.07674 and arXiv:1605.09788 .

Unit prefixes

const double quetta = 1e30
const double ronna = 1e27
const double yotta = 1e24
const double zetta = 1e21
const double exa = 1e18
const double peta = 1e15
const double tera = 1e12
const double giga = 1e9
const double mega = 1e6
const double kilo = 1e3
const double milli = 1e-3
const double micro = 1e-6
const double nano = 1e-9
const double pico = 1e-12
const double femto = 1e-15
const double atto = 1e-18
const double zepto = 1e-21
const double yocto = 1e-24
const double ronto = 1e-27
const double quecto = 1e-30

Unit systems

static const size_t o2scl_mks = 1

MKS units.

static const size_t o2scl_cgs = 2

CGS units.

Mathematical constants

template<class fp_t>
fp_t pi_f()

\( \pi \)

template<class fp_t>
fp_t pi2_f()

\( \pi^2 \)

template<class fp_t>
fp_t root_pi_f()

\( \sqrt{\pi} \)

template<class fp_t>
fp_t zeta2_f()

\( \zeta(2) \)

template<class fp_t>
fp_t zeta3_f()

\( \zeta(3) \)

template<class fp_t>
fp_t euler_f()

The Euler-Mascheroni constant.

Physical constants

template<class fp_t>
fp_t fine_structure_f()

Fine structure constant (CODATA 2022 value)

template<class fp_t>
fp_t avogadro_f()

Avogadro’s number (exact)

template<class fp_t>
fp_t speed_of_light_f(size_t system = o2scl_mks)

Speed of light (exact)

template<class fp_t>
fp_t planck_f(size_t system = o2scl_mks)

Planck constant (exact)

template<class fp_t>
fp_t hbar_f(size_t system = o2scl_mks)

Reduced Planck constant (derived; exact)

template<class fp_t>
fp_t hbarc_f(size_t system = o2scl_mks)

Reduced Planck’s constant times speed of light \( \hbar c \) (derived; exact)

template<class fp_t>
fp_t boltzmann_f(size_t system = o2scl_mks)

Boltzmann’s constant (exact)

template<class fp_t>
fp_t gravitational_constant_f(size_t system = o2scl_mks)

Gravitational constant (CODATA 2022 value)

template<class fp_t>
fp_t elem_charge_f()

Elementary charge in C (exact)

template<class fp_t>
fp_t electron_volt_f(size_t system = o2scl_mks)

Electron volt (exact)

template<class fp_t>
fp_t hc_mev_fm_f()

Reduced Planck constant times speed of light in \( \mathrm{MeV}~\mathrm{fm} \) (derived; exact)

template<class fp_t>
fp_t stefan_boltz_cons_f(size_t system = o2scl_mks)

Stefan-Boltzmann constant ( \( \mathrm{kg} / \mathrm{K}^4 \mathrm{s}^3 \) in MKS and \( \mathrm{g} / \mathrm{K}^4 \mathrm{s}^3 \) in CGS; derived; exact)

template<class fp_t>
fp_t sin2_theta_weak_f()

\( \sin^2 \theta_W \) (unitless; PDG 2024 value)

template<class fp_t>
fp_t gfermi_gev2_f()

Fermi coupling constant in \( \mathrm{GeV}^{-2} \) (PDG 2024 value)

template<class fp_t>
fp_t gfermi_f(size_t system = o2scl_mks)

Fermi coupling constant in ( \( \mathrm{s}^4 / \mathrm{m}^4 \mathrm{kg}^2 \) in MKS and \( \mathrm{s}^4 / \mathrm{cm}^4 \mathrm{g}^2 \) in CGS; derived from gfermi_gev2_f())

Astrophysical constants

template<class fp_t>
fp_t astronomical_unit_f(size_t system = o2scl_mks)

Astronomical unit (IAU 2009 value; now exact)

template<class fp_t>
fp_t parsec_f(size_t system = o2scl_mks)

Parsec (derived; exact)

template<class fp_t>
fp_t grav_accel_f(size_t system = o2scl_mks)

Acccleration due to gravity ( \( \mathrm{m} / \mathrm{s}^2 \) in MKS and \( \mathrm{cm} / \mathrm{s}^2 \) in CGS ) (CODATA 2018; now exact)

template<class fp_t>
fp_t sidereal_year_f(size_t system = o2scl_mks)

Sidereal year in s (PDG 2024 value)

template<class fp_t>
fp_t tropical_year_f(size_t system = o2scl_mks)

Tropical year in s (PDG 2024 value)

template<class fp_t>
fp_t julian_year_f(size_t system = o2scl_mks)

Julian year in s (exact)

template<class fp_t>
fp_t light_year_f(size_t system = o2scl_mks)

Light year in \( \mathrm{cm} \) (derived; exact)

Particle masses

template<class fp_t>
fp_t mass_neutron_f(size_t system = o2scl_mks)

Neutron mass (CODATA 2022 value)

template<class fp_t>
fp_t mass_proton_f(size_t system = o2scl_mks)

Proton mass (CODATA 2022 value)

template<class fp_t>
fp_t mass_proton_amu_f()

Proton mass in AMU (CODATA 2022 value)

template<class fp_t>
fp_t mass_electron_f(size_t system = o2scl_mks)

Electron mass (CODATA 2022 value)

template<class fp_t>
fp_t mass_muon_f(size_t system = o2scl_mks)

Muon mass (CODATA 2022 value)

template<class fp_t>
fp_t mass_tau_f(size_t system = o2scl_mks)

Tau mass (CODATA 2022 value)

Nuclear masses

template<class fp_t>
fp_t mass_deuteron_f(size_t system = o2scl_mks)

Deuteron mass (CODATA 2022 value)

template<class fp_t>
fp_t mass_triton_f(size_t system = o2scl_mks)

Triton mass (CODATA 2022 value)

template<class fp_t>
fp_t mass_helion_f(size_t system = o2scl_mks)

Helion mass (CODATA 2022 value)

template<class fp_t>
fp_t mass_alpha_f(size_t system = o2scl_mks)

Alpha mass (CODATA 2022 value)

template<class fp_t>
fp_t unified_atomic_mass_f(size_t system = o2scl_mks)

Unified atomic mass (CODATA 2018 value)

template<class fp_t>
fp_t bohr_radius_f(size_t system = o2scl_mks)

Bohr radius (CODATA 2022 value)

template<class fp_t>
fp_t thomson_csec_f(size_t system = o2scl_mks)

Thomson cross section (MKS in \( m^2 \) and CGS in \( cm^2 \) ; CODATA 2022 value)

Chemical constants

template<class fp_t>
fp_t rydberg_f(size_t system = o2scl_mks)

Rydberg constant ( \( \mathrm{kg} \mathrm{m}^2 / \mathrm{s}^2 \) in MKS and \( \mathrm{g} \mathrm{cm}^2 / \mathrm{s}^2 \) in CGS; CODATA 2022 value)

This is referred to as the “Rydberg constant” by GSL and is equal to \( h c R_{\infty} \). The value \( R_{\infty} \) is the inverse Rydberg wavelength (also sometimes referred to as the Rydberg constant).

template<class fp_t>
fp_t molar_gas_f(size_t system = o2scl_mks)

Molar gas constant, \( R\) , ( \( \mathrm{kg} \mathrm{m}^2 / \mathrm{K} \mathrm{mol} \mathrm{s}^2 \) in MKS \( \mathrm{g} \mathrm{cm}^2 / \mathrm{K} \mathrm{mol} \mathrm{s}^2 \) in CGS; derived; exact)

template<class fp_t>
fp_t std_gas_volume_f(size_t system = o2scl_mks)

Molar volume of ideal gas at standard T and P ( \( \mathrm{m}/\mathrm{mol} \) in MKS and ( \( \mathrm{cm}/\mathrm{mol} \) in CGS; CODATA 2022 value)

Electromagnetic constants

template<class fp_t>
fp_t electron_mag_mom_f(size_t system = o2scl_mks)

Electron magnetic moment ( \( \mathrm{J}/\mathrm{T} \) in MKS; CODATA 2022 value)

Note

This quantity is defined without a minus sign.

template<class fp_t>
fp_t proton_mag_mom_f(size_t system = o2scl_mks)

Proton magnetic moment ( \( \mathrm{J}/\mathrm{T} \) in MKS; CODATA 2022 value)