phytorch.constants

Constants are just regular Units with a memorable name and a description.

The primary set of constants comes from the CODATA recommended values. Since they change every few years, φtorch organises the values into submodules: codata2014, codata2018, and the special default, which points to the latest release. Constants can be accessed either from any of the CODATA modules, or from phytorch.constants directly (which will fetch them from default):

>>> from phytorch import constants as const
>>> const.default is const.codata2018
True
>>> const.c is const.default.c is const.codata2018.c
True
>>> const.codata2014.G, const.codata2018.G
(<Newtonian constant of gravitation: G = 6.67408e-11 (N m^(2) kg^(2)^(-1))>,
 <Newtonian constant of gravitation: G = 6.6743e-11 (N m^(2) kg^(2)^(-1))>)

CODATA constants

CODATA constants fall in several categories (here we list values from default):

  • fundamental defined constants with values set by defining the measurement system itself:

    name(s)

    description

    symbol

    definition

    c

    speed of light in vacuum

    \(c\)

    \(299\,792\,458\ \mathrm{m} / \mathrm{s}\)

    h

    Planck constant

    \(h\)

    \(6.626\,070\,15 \times 10^{-34}\ \mathrm{J}\,\mathrm{s}\)

    k

    Boltzman constant

    \(k\)

    \(1.380\,649 \times 10^{-23}\ \mathrm{J} / \mathrm{K}\)

    e

    elementary charge

    \(e\)

    \(1.602\,176\,634 \times 10^{-19}\ \mathrm{A}\,\mathrm{s}\)

    N_A

    Avogadro constant

    \(N_A\)

    \(6.022\,140\,76 \times 10^{23}\)

  • conventional Earth-related “constants” (these are also “exact”):

    name(s)

    description

    symbol

    value

    atm

    standard atmosphere

    \(\mathrm{atm}\)

    \(101\,325\ \mathrm{Pa}\)

    g

    standard acceleration of gravity

    \(g\)

    \(9.80665\ \mathrm{m} / \mathrm{s}^{2}\)

  • other fundamental constants, whose values are derived from measurements:

    name(s)

    description

    symbol

    measured value

    α
    alpha

    fine-structure constant

    \(\alpha\)

    \(7.297\,352\,5693(11) \times 10^{-3}\)

    G

    Newtonian constant of gravitation

    \(G\)

    \(6.674\,30(15) \times 10^{-11}\ \mathrm{kg}^{-1}\,\mathrm{m}^{3}\,\mathrm{s}^{-2}\)

    m_p

    proton mass

    \(m_p\)

    \(1.672\,621\,923\,69(51) \times 10^{-27}\ \mathrm{kg}\)

    m_n

    neutron mass

    \(m_n\)

    \(1.674\,927\,498\,04(95) \times 10^{-27}\ \mathrm{kg}\)

    m_e

    electron mass

    \(m_e\)

    \(9.109\,383\,7015(28) \times 10^{-31}\ \mathrm{kg}\)

    u

    atomic mass constant

    \(m_u\)

    \(1.660\,539\,066\,60(50) \times 10^{-27}\ \mathrm{kg}\)

  • derived constants, which are just convenient shorthand combinations of other constants (these are calculated dynamically and so are consistent within the CODATA set):

    name(s)

    description

    symbol

    definition

    ħ
    hbar

    reduced Planck constant

    \(\hbar\)

    \(h / (2\pi)\)

    μ_0
    mu_0

    vacuum magnetic permeability

    \(\mu_0\)

    \(4\pi \, \alpha \hbar / (c e^2)\)

    ε_0
    eps_0

    vacuum electric permittivity

    \(\varepsilon_0\)

    \(1 / (\mu_0 c^2)\)

    μ_B
    mu_B

    Bohr magneton

    \(\mu_B\)

    \(e \hbar / (2 m_e)\)

    μ_N
    mu_N

    nuclear magneton

    \(\mu_N\)

    \(e \hbar / (2 m_p)\)

    Ryd

    Rydberg constant

    \(R_{\infty}\)

    \(\alpha^2 m_e c / (2 h)\)

    a_0

    Bohr radius

    \(a_0\)

    \(\hbar / (\alpha m_e c)\)

    σ_e
    sigma_e

    Thomson cross section

    \(\sigma_e\)

    \((8\pi/3) \, \alpha^4 a_0^2\)

    σ
    sigma

    Stefan-Boltzmann constant

    \(\sigma\)

    \((\pi^2/60) \, k^4 / (\hbar^3 c^2)\)

    b

    Wien wavelength displacement law constant

    \(b\)

    \((h c / k) \,/\, 4.965\!\ldots\)

    b_prime

    Wien frequency displacement law constant

    \(b^\prime\)

    \(2.821\!\ldots \, (k / h)\)

Astronomical constants

  • Additionally, phytorch.constants[*] defines a limited set of “astronomical” constants:[]

    name(s)

    description

    symbol

    valuea, b

    M_earth
    earthMass

    Earth mass

    \(M_⊕\)

    \(5.972 \times 10^{24}\ \mathrm{kg}\)

    R_earth
    earthRad
    earthRadius

    Earth equatorial radius

    \(R_⊕\)

    \(6.378 \times 10^{6}\ \mathrm{m}\)

    M_jupiter
    jupiterMass

    Jupiter mass

    \(M_♃\)

    \(1.898 \times 10^{27}\ \mathrm{kg}\)

    R_jupiter
    jupiterRad
    jupiterRadius

    Jupiter equatorial radius

    \(R_♃\)

    \(7.149 \times 10^{7}\ \mathrm{m}\)

    M_sun
    solMass
    solarMass

    solar mass

    \(M_☉\)

    \(1.988 \times 10^{30}\ \mathrm{kg}\)

    R_sun
    solRad
    solarRadius

    solar radius

    \(R_☉\)

    \(6.957 \times 10^{8}\ \mathrm{m}\)

    L_sun
    solLum
    solarLuminosity

    solar luminosity

    \(L_☉\)

    \(3.828 \times 10^{26}\ \mathrm{W}\)

Footnotes

API

Classes

phytorch.constants.constant.Constant

A Unit that represents a universal constant.

class phytorch.constants.constant.Constant

A Unit that represents a universal constant.

A Constant is simply a Unit with a human-friendly name and optionally a description.

description: str

Free-text description of the constant.


Modules

phytorch.constants.astro

phytorch.constants.default

phytorch.constants.codata2014

phytorch.constants.codata2018

phytorch.constants.astro: module

A module that defines some astronomical constants, which are exported to phytorch.constants in the same way as those from default.

phytorch.constants.codata2014: CODATA = <module 'codata2014'>

CODATA 2014 release: https://pml.nist.gov/cuu/pdf/wall_2014.pdf.

phytorch.constants.codata2018: CODATA = <module 'codata2018'>

CODATA 2018 release: https://pml.nist.gov/cuu/pdf/wall_2018.pdf.

phytorch.constants.default: CODATA = <module 'codata2018'>

The default set of CODATA constants. Currently points to codata2018.

Attempting to access a variable on the top-level constants module will attempt to look the variable up on default, which allows accessing the default constants directly from phytorch.constants.


Helper classes

phytorch.constants.codata.CODATA

A module that represents a set of CODATA constants.

phytorch.constants.codata.CODATA_vals

A collection of values for the defined constants of a CODATA set.

class phytorch.constants.codata.CODATA

A module that represents a set of CODATA constants.

It is instantiated with a set of CODATA_vals for the defined constants. It can then automatically calculates derived constants (on demand) and caches them.

class phytorch.constants.codata.CODATA_vals

A collection of values for the defined constants of a CODATA set.