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”):
other fundamental constants, whose values are derived from measurements:
name(s)
description
symbol
measured value
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
CODATAset):name(s)
description
symbol
definition
reduced Planck constant
\(\hbar\)
\(h / (2\pi)\)
vacuum magnetic permeability
\(\mu_0\)
\(4\pi \, \alpha \hbar / (c e^2)\)
vacuum electric permittivity
\(\varepsilon_0\)
\(1 / (\mu_0 c^2)\)
Bohr magneton
\(\mu_B\)
\(e \hbar / (2 m_e)\)
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)\)
Thomson cross section
\(\sigma_e\)
\((8\pi/3) \, \alpha^4 a_0^2\)
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
Earth mass
\(M_⊕\)
\(5.972 \times 10^{24}\ \mathrm{kg}\)
Earth equatorial radius
\(R_⊕\)
\(6.378 \times 10^{6}\ \mathrm{m}\)
Jupiter mass
\(M_♃\)
\(1.898 \times 10^{27}\ \mathrm{kg}\)
Jupiter equatorial radius
\(R_♃\)
\(7.149 \times 10^{7}\ \mathrm{m}\)
solar mass
\(M_☉\)
\(1.988 \times 10^{30}\ \mathrm{kg}\)
solar radius
\(R_☉\)
\(6.957 \times 10^{8}\ \mathrm{m}\)
solar luminosity
\(L_☉\)
\(3.828 \times 10^{26}\ \mathrm{W}\)
Footnotes
API¶
Classes¶
A |
Modules¶
- phytorch.constants.astro: module¶
A module that defines some astronomical constants, which are exported to
phytorch.constantsin the same way as those fromdefault.
- 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
constantsmodule will attempt to look the variable up ondefault, which allows accessing the default constants directly fromphytorch.constants.
Helper classes¶
A collection of values for the defined constants of a |
- class phytorch.constants.codata.CODATA¶
A
modulethat represents a set of CODATA constants.It is instantiated with a set of
CODATA_valsfor the defined constants. It can then automatically calculates derived constants (on demand) and caches them.