julia> using Pkg
julia> Pkg.add("AtomicAndPhysicalConstants.jl")julia> using AtomicAndPhysicalConstants
julia> # Access physical constants directly
julia> C_LIGHT # in [m/s]
2.99792458e8
julia> H_PLANCK # in [eV⋅s]
4.135667696e-15
julia> M_ELECTRON # in [eV/c²]
510998.95069
julia> FINE_STRUCTURE # unitless
0.0072973525643
julia> # Create species objects
julia> e = Species("electron") # print the output for this one as an example
Species: electron
Charge: -1 e
Mass: 510998.95069 eV/c²
Spin: 0.5 ħ
Moment: -5.795094307320036e-5 eV/T
G-factor: 2.00231930436092
Kind: LEPTON
julia> p = Species("proton"); # suppress the output for the rest of the definitions
julia> h = Species("H"); # a neutral hydrogen atom
julia> he = Species("#3He"); # a neutral helium atom with mass number 3
julia> h_ion = Species("H+"); # a hydrogen atom with one less electron than usual
julia> anti_p = Species("anti-proton");
julia> # retrieve Species qualities with access functions
julia> nameof(anti_p)
"anti-proton"
julia> chargeof(p) # charge of the particle in [e]
1
julia> massof(e) # retrieve the mass of a particle in [eV/c²]
510998.95069
julia> massof(h, AMU=true) # or grab the mass of an atom in AMU (also called Daltons)
1.0079407540557772
julia> spinof(e) # spin projection of the particle in [ħ]
0.5
julia> gspin_of(e) # spin g-factor (dimensionless)
2.00231930436092
julia> gyromagnetic_anomaly(e)
0.0011596521804599913
julia> momentof(p) # magnetic dipole moment in [eV/T] - errors for atoms
8.804315113647238e-8
julia> iso_of(he) # mass number of the specified atom - errors for non-atoms
3
The following list of strings may be used as arguments to the Species() function.
"electron","positron""proton","anti-proton"`"neutron","anti-neutron""muon","anti-muon""pion0","pion+","pion-""deuteron","anti-deuteron""triton","anti-triton""helion","anti-helion""photon"
Atomic numbers from 1 ("H") to 118 ("Og") are available with the Species() function.
To access different isotopes of a particular atomic element, two different syntax options are available: a #-prefixed ASCII mass number, or a Unicode superscript mass number. A bare ASCII mass number (e.g. "5He") is not accepted.
julia> he = Species("#5He"); he5 = Species("⁵He");
julia> massof(he5, AMU=true)
5.012057
julia> he == he5
trueCharge state may be specified for atoms. Positive charges with magnitude less than 4_e_ may be given with repeated plus symbols, e.g.
julia> chargeof(Species("Li+++"))
3Similarly, negative charges with magnitude less than 4_e_ may be given with repeated minus symbols, e.g.
julia> chargeof(Species("K---"))
-3A single positive or negative sign followed by an integer may be used the same way, e.g.
julia> Species("Li+++") == Species("Li+3")
true
julia> Species("K---") == Species("K-3")
trueAtomicAndPhysicalConstants.jl supports CODATA releases beginning in 2002. The available releases are from: 2002, 2006, 2010, 2014, 2018, and 2022. Note that not all constants in this package are supported before the 2010 release.
To change your CODATA release year to e.g. 2014, run:
julia> using AtomicAndPhysicalConstants
julia> set_release(year = "2014")
[ Info: The default CODATA release is now 2014. Restart your Julia session for this change to take effect.This will change the base constants of AtomicAndPhysicalConstants to their recorded value in the specified CODATA release. The change is persistent, so to revert back to the default constants, run
julia> set_release()M_ELECTRONM_PROTONM_NEUTRONM_MUONM_DEUTERONM_HELIONM_TRITON- This constant is not available from the 2002 CODATA release
M_PION_0M_PION_CHARGED
Both Pion masses are obtained from PDG, rather than CODATA.
MU_ELECTRONMU_PROTONMU_NEUTRONMU_MUONMU_DEUTERONMU_HELIONMU_TRITON
AVOGADROFINE_STRUCTURE
G_ELECTRONG_PROTONG_NEUTRONG_MUONG_DEUTERONG_HELION- This constant is not available from CODATA releases prior to 2010
G_TRITON
ANOMALY_ELECTRON- This constant is not available from CODATA releases prior to 2010
ANOMALY_MUON- This constant is not available from CODATA releases prior to 2010
E_CHARGE- charge on the electron in [C]R_ELECTRON: classical electron radius in [m]R_PROTON: classical proton radius in [m]C_LIGHT: speed of light in [m/s]H_PLANCK: Planck's constant in [eV⋅s]H_BAR: Planck's reduced constant in [eV⋅s]CLASSICAL_RADIUS_FACTOR: classical radius factor e²/(4πε₀) = rₑmₑc² in [eV⋅m], derived asR_ELECTRON * M_ELECTRONEPS_0: Permittivity of free space in [1/(eV⋅m)]MU_0: Vacuum Permeability in [eV⋅s²/m]
KG_PER_AMU:EV_PER_AMUJ_PER_EVG_PER_EVKG_PER_MEV_C2