API Reference
Complete index of the exported symbols, followed by the internal types they refer to.
Species type and constructor
AtomicAndPhysicalConstants.Species — Type
Species(speciesname::String)
Species()Construct a particle species by name, or a null placeholder with no arguments.
The string format encodes particle identity, isotope (for atoms), and charge state in one expression: [mass_number] symbol [charge].
Subatomic particles
Pass the openPMD name exactly:
| Name | Particle |
|---|---|
"electron" / "positron" | electron / positron |
"proton" / "anti-proton" | proton / antiproton |
"neutron" / "anti-neutron" | neutron / antineutron |
"muon" / "anti-muon" | muon / antimuon |
"pion0" / "pion+" / "pion-" | pions |
"deuteron" / "anti-deuteron" | deuteron / antideuteron |
"triton" / "anti-triton" | triton / antitriton |
"helion" / "anti-helion" | helion / antihelion |
"photon" | photon |
Atomic species
Atomic symbols "H" (Z=1) through "Og" (Z=118) are supported.
Mass number — give it before the atomic symbol, either as ASCII digits prefixed with # or as Unicode superscript digits: "#4He" or "⁴He". A bare ASCII mass number such as "4He" is not accepted. Without a mass number the abundance-averaged mass is used; an element with no stable isotopes has no standard atomic weight, so for those (Tc, Pm, and Po onward, apart from Th, Pa, and U) a mass number is required and "Po" alone is an error.
Charge state — append after the symbol. Repeated signs ("++", "---") or "+n" / "-n" notation are both accepted.
Species("#4He") # helium-4, neutral (# prefix required for ASCII digits)
Species("⁴He") # same, Unicode superscript
Species("Li+3") # lithium, charge +3
Species("Li+++") # same
Species("K-2") # potassium, charge −2Anti-atoms: prepend "anti-" to any atomic symbol.
Species("anti-H") # antihydrogenNull species: Species(), or names "Null", "null", "".
Fields
| Field | Type | Description |
|---|---|---|
name | String | Particle name or atomic symbol |
charge | Float64 | Net charge in units of e |
mass | Float64 | Rest mass in eV/c² |
spin | Float64 | Spin in ħ; for an atom the nuclear spin, NaN if undefined |
gspin | Float64 | Signed spin g-factor (0 for atoms); g_spin returns its absolute value by default |
moment | Float64 | Magnetic dipole moment in eV/T (0 for atoms) |
iso | Int | Mass number; −1 for abundance average; 0 for subatomic particles |
kind | Kind.T | LEPTON, HADRON, PHOTON, ATOM, or NULL |
Direct field access is disabled. Use chargeof, massof, spinof, g_spin, momentof, iso_of, atomicnumberof, kindof, isnullspecies, Base.nameof.
Accessor functions
The Species page describes the unit conventions these follow and what each one returns for a species that does not carry the property.
Base.nameof — Method
nameof(species::Species) -> StringReturn the canonical name of species.
For subatomic particles the openPMD name is returned unchanged. For atomic species the name is assembled from the atomic symbol, mass number (if a specific isotope was requested), and charge state, using the #mAS±c convention:
julia> nameof(Species("electron"))
"electron"
julia> nameof(Species("#4He+2"))
"#4He+2"
julia> nameof(Species("Li+")) # the charge is always spelled out
"Li+1"
julia> nameof(Species("anti-#4He"))
"anti-#4He"AtomicAndPhysicalConstants.chargeof — Function
chargeof(species::Species; C::Bool = false) -> Float64Return the net charge of species.
By default the charge is returned as a (whole-numbered) multiple of the elementary charge e. Pass C = true to convert to coulombs using the active E_CHARGE constant.
Examples
julia> chargeof(Species("proton"))
1.0
julia> chargeof(Species("electron"))
-1.0
julia> chargeof(Species("Li+3"))
3.0
julia> chargeof(Species("proton"), C = true) # coulombs
1.602176634e-19AtomicAndPhysicalConstants.massof — Function
massof(species::Species; AMU::Bool = false) -> Float64Return the rest mass of species.
By default the mass is returned in eV/c². Pass AMU = true to return the mass in atomic mass units (daltons), which is particularly convenient for atomic species.
Examples
julia> massof(Species("electron")) # eV/c²
510998.95069
julia> massof(Species("proton"))
9.3827208943e8
julia> massof(Species("H"), AMU = true) # daltons
1.0079407540557772
julia> massof(Species("#4He"), AMU = true)
4.00260325413AtomicAndPhysicalConstants.spinof — Function
spinof(species::Species) -> Float64Return the spin of species in units of the reduced Planck constant ħ.
For an atomic species this is the nuclear spin, taken from the tabulated NUBASE2020 ground-state values. Electron spin is not included: the total angular momentum of an atom depends on its electronic state, which Species does not model. Ionisation therefore does not change the result, and an anti-nucleus has the same spin as its mirror.
Returns NaN when no spin is defined:
- for an atom given without a mass number (e.g.
Species("He")), because the abundance average runs over isotopes with differing spins; - for the handful of exotic isotopes to which NUBASE assigns no unambiguous ground-state spin.
Note that spin is not a function of the mass number — nucleons pair off with opposite spins, so every even-even nucleus has spin 0.
Examples
julia> spinof(Species("electron"))
0.5
julia> spinof(Species("photon"))
1.0
julia> spinof(Species("#4He")) # even-even nucleus
0.0
julia> spinof(Species("#3He+2")) # ionisation does not change the nucleus
0.5
julia> spinof(Species("He")) # abundance average, no single value
NaNAtomicAndPhysicalConstants.momentof — Function
momentof(species::Species) -> Float64Return the magnetic dipole moment of species in eV/T.
Returns 0 for atomic species and the null species (no moment is stored for these types).
Examples
julia> momentof(Species("electron")) # eV/T
-5.795094307747843e-5
julia> momentof(Species("proton"))
8.804315114297192e-8
julia> momentof(Species("H")) # atoms carry no moment
0.0AtomicAndPhysicalConstants.g_spin — Function
g_spin(species::Species; signed::Bool = false) -> Float64Return the spin g-factor of species.
By default the absolute value is returned. Pass signed = true to get the signed g-factor in the convention mu = g * (e / 2m) * S with e > 0, so the sign is that of the magnetic moment relative to the spin: negative for the electron, muon, neutron, and helion, and positive for their antiparticles.
Returns 0 for atomic species, for which no g-factor is stored.
Examples
julia> g_spin(Species("electron"))
2.00231930436092
julia> g_spin(Species("electron"), signed = true)
-2.00231930436092
julia> g_spin(Species("positron"), signed = true)
2.00231930436092
julia> g_spin(Species("proton"))
5.5856946893
julia> g_spin(Species("H")) # atoms carry no g-factor
0.0AtomicAndPhysicalConstants.gyromagnetic_anomaly — Function
gyromagnetic_anomaly(species::Species) -> Float64Compute and return the gyromagnetic anomaly
\[a = \frac{g_q - 2}{2}, \qquad g_q = g \, \frac{e}{q}\]
for charged leptons and hadrons, where $g$ is the signed g-factor (g_spin with signed = true) and $q$ the particle's charge. $g_q$ is the g-factor normalized to the particle's own charge, $\boldsymbol{\mu} = g_q \frac{q}{2m} \mathbf{S}$, which is the anomaly that enters the Thomas–BMT spin-precession equation. Returns NaN for neutral particles (neutron, anti-neutron, neutral pion), for which $g_q$ is undefined, and for photons, atoms, and null species.
Dividing by the charge takes care of the sign: the electron ($g < 0$, $q = -e$) gets the conventional +0.00115965…, the same as the positron ($g > 0$, $q = +e$). It also takes care of the doubly charged helion, whose anomaly is -4.1841537… rather than the value (|g| - 2)/2 would give.
The stored g-factors are all in the convention mu = g * (e / 2m) * S, where the particle's own mass sets the magneton. For the deuteron, helion, and triton this required renormalizing the NIST values, which are tabulated against the nuclear magneton e*hbar/(2*M_PROTON); G_DEUTERON, G_HELION, and G_TRITON carry the renormalized values (see the Physical Constants manual page).
Examples
julia> gyromagnetic_anomaly(Species("electron"))
0.0011596521804599913
julia> gyromagnetic_anomaly(Species("muon"))
0.0011659206150000934
julia> gyromagnetic_anomaly(Species("deuteron"))
-0.14298726968020148
julia> gyromagnetic_anomaly(Species("helion")) # doubly charged
-4.184153749832893
julia> gyromagnetic_anomaly(Species("neutron")) # neutral
NaNAtomicAndPhysicalConstants.iso_of — Function
iso_of(species::Species) -> IntReturn the mass number (isotope) of species.
- For atomic species: the mass number of the requested isotope, or
−1if the abundance-averaged atomic mass was used. - For subatomic particles: always
0.
Examples
julia> iso_of(Species("#3He"))
3
julia> iso_of(Species("He")) # abundance average
-1
julia> iso_of(Species("electron")) # not an atom
0AtomicAndPhysicalConstants.atomicnumberof — Function
atomicnumberof(species::Species) -> IntReturn the atomic number (number of protons) of species.
For an anti-atom, returns the negative of the atomic number (-Z), to distinguish it from the matter atom of the same symbol.
Throws an error if species is not of kind ATOM.
Examples
julia> atomicnumberof(Species("Fe"))
26
julia> atomicnumberof(Species("H+")) # ionisation does not change Z
1
julia> atomicnumberof(Species("anti-H"))
-1AtomicAndPhysicalConstants.kindof — Function
kindof(species::Species) -> Kind.TReturn the particle classification of species as a Kind.T enum value.
Possible values: Kind.LEPTON, Kind.HADRON, Kind.PHOTON, Kind.ATOM, Kind.NULL.
Examples
julia> kindof(Species("electron"))
Kind.LEPTON = 2
julia> kindof(Species("H"))
Kind.ATOM = 0
julia> kindof(Species())
Kind.NULL = 4AtomicAndPhysicalConstants.isnullspecies — Function
isnullspecies(species::Species) -> BoolReturn true if species is a null (placeholder) species, false otherwise.
julia> isnullspecies(Species())
true
julia> isnullspecies(Species("null"))
true
julia> isnullspecies(Species("proton"))
falseConfiguration
AtomicAndPhysicalConstants.set_release — Function
set_release(; year::Union{String,Nothing} = nothing)Persistently set the CODATA release year used by AtomicAndPhysicalConstants.jl.
The setting is stored via Preferences.jl in the active Julia environment and survives across sessions. A Julia restart is required for the new constants to take effect.
Valid values for year are the keys of CODATA_MAP, currently 2002, 2006, 2010, 2014, 2018, 2022, each given as a string. Calling with no arguments removes the setting, so the package uses its default: the most recent release it ships, which moves forward when a newer release is added.
Examples
set_release(year = "2014")
# [ Info: The default CODATA release is now 2014.
# Restart your Julia session for this change to take effect.
set_release() # follow the most recent release againSee also: RELEASE_YEAR.
Particle kind enum
AtomicAndPhysicalConstants.Kind — Module
KindClassification of a particle species.
| Value | Meaning |
|---|---|
Kind.LEPTON | leptons: electron, positron, muon, anti-muon |
Kind.HADRON | hadrons: proton, neutron, pions, deuteron, … |
Kind.PHOTON | photon |
Kind.ATOM | any atomic or ionic species |
Kind.NULL | null placeholder species |
The kind of a species is queried with kindof.
Particle data dictionaries
AtomicAndPhysicalConstants.SUBATOMIC_SPECIES — Constant
SUBATOMIC_SPECIES :: Dict{String, SubatomicSpecies}Dictionary of all supported subatomic particles, keyed by openPMD name.
Supported keys: "electron", "positron", "proton", "anti-proton", "neutron", "anti-neutron", "muon", "anti-muon", "pion0", "pion+", "pion-", "deuteron", "anti-deuteron", "triton", "anti-triton", "helion", "anti-helion", "photon".
AtomicAndPhysicalConstants.ATOMIC_SPECIES — Constant
ATOMIC_SPECIES :: Dict{String, AtomicSpecies}Dictionary of all supported atomic elements (Z = 1 … 118), keyed by atomic symbol (e.g. "H", "Fe", "Og"). Each value is an AtomicSpecies struct containing the atomic number, symbol, a dictionary of isotope masses in atomic mass units, and a dictionary of ground-state nuclear spins in units of ħ.
Isotope masses come from NIST; nuclear spins come from NUBASE2020. Regenerate them with update/update_isos.jl and update/update_spins.jl respectively.
CODATA release structs
AtomicAndPhysicalConstants.CODATA2002 — Constant
CODATA2002 :: CODATA_releaseFundamental constants from the 2002 CODATA release.
See NIST CODATA for the primary source values.
AtomicAndPhysicalConstants.CODATA2006 — Constant
CODATA2006 :: CODATA_releaseFundamental constants from the 2006 CODATA release.
See NIST CODATA for the primary source values.
AtomicAndPhysicalConstants.CODATA2010 — Constant
CODATA2010 :: CODATA_releaseFundamental constants from the 2010 CODATA release.
See NIST CODATA for the primary source values.
AtomicAndPhysicalConstants.CODATA2014 — Constant
CODATA2014 :: CODATA_releaseFundamental constants from the 2014 CODATA release.
See NIST CODATA for the primary source values.
AtomicAndPhysicalConstants.CODATA2018 — Constant
CODATA2018 :: CODATA_releaseFundamental constants from the 2018 CODATA release.
See NIST CODATA for the primary source values.
AtomicAndPhysicalConstants.CODATA2022 — Constant
CODATA2022 :: CODATA_releaseFundamental constants from the 2022 CODATA release.
See NIST CODATA for the primary source values.
Physical constants
AtomicAndPhysicalConstants.M_ELECTRON — Constant
M_ELECTRON::Float64Mass of the electron in eV/c² from the selected CODATA release.
AtomicAndPhysicalConstants.M_PROTON — Constant
M_PROTON::Float64Mass of the proton in eV/c² from the selected CODATA release.
AtomicAndPhysicalConstants.M_NEUTRON — Constant
M_NEUTRON::Float64Mass of the neutron in eV/c² from the selected CODATA release.
AtomicAndPhysicalConstants.M_MUON — Constant
M_MUON::Float64Mass of the muon in eV/c² from the selected CODATA release.
AtomicAndPhysicalConstants.M_DEUTERON — Constant
M_DEUTERON::Float64Mass of the deuteron in eV/c² from the selected CODATA release.
AtomicAndPhysicalConstants.M_HELION — Constant
M_HELION::Float64Mass of the helion in eV/c² from the selected CODATA release.
AtomicAndPhysicalConstants.M_TRITON — Constant
M_TRITON::Float64Mass of the triton in eV/c² from the selected CODATA release.
AtomicAndPhysicalConstants.M_PION_0 — Constant
M_PION_0::Float64Mass of the neutral pion in eV/c², from the Particle Data Group edition of the same year as the selected CODATA release.
AtomicAndPhysicalConstants.M_PION_CHARGED — Constant
M_PION_CHARGED::Float64Mass of a charged pion in eV/c², from the Particle Data Group edition of the same year as the selected CODATA release.
AtomicAndPhysicalConstants.MU_ELECTRON — Constant
MU_ELECTRON::Float64Magnetic moment of the electron in eV/T (converted) from the selected CODATA release.
AtomicAndPhysicalConstants.MU_PROTON — Constant
MU_PROTON::Float64Magnetic moment of the proton in eV/T (converted) from the selected CODATA release.
AtomicAndPhysicalConstants.MU_NEUTRON — Constant
MU_NEUTRON::Float64Magnetic moment of the neutron in eV/T (converted) from the selected CODATA release.
AtomicAndPhysicalConstants.MU_MUON — Constant
MU_MUON::Float64Magnetic moment of the muon in eV/T (converted) from the selected CODATA release.
AtomicAndPhysicalConstants.MU_DEUTERON — Constant
MU_DEUTERON::Float64Magnetic moment of the deuteron in eV/T (converted) from the selected CODATA release.
AtomicAndPhysicalConstants.MU_HELION — Constant
MU_HELION::Float64Magnetic moment of the helion in eV/T (converted) from the selected CODATA release.
AtomicAndPhysicalConstants.MU_TRITON — Constant
MU_TRITON::Float64Magnetic moment of the triton in eV/T (converted) from the selected CODATA release.
AtomicAndPhysicalConstants.G_ELECTRON — Constant
G_ELECTRON::Float64The electron spin g-factor per the selected CODATA release.
AtomicAndPhysicalConstants.G_PROTON — Constant
G_PROTON::Float64The proton spin g-factor per the selected CODATA release.
AtomicAndPhysicalConstants.G_NEUTRON — Constant
G_NEUTRON::Float64The neutron spin g-factor renormalized to the neutron magneton e*hbar/(2*M_NEUTRON), the convention in which the gyromagnetic anomaly a = (|g|-2)/2 holds.
AtomicAndPhysicalConstants.G_MUON — Constant
G_MUON::Float64The muon spin g-factor per the selected CODATA release.
AtomicAndPhysicalConstants.G_DEUTERON — Constant
G_DEUTERON::Float64The deuteron spin g-factor renormalized to the deuteron magneton e*hbar/(2*M_DEUTERON), the convention in which the gyromagnetic anomaly a = (|g|-2)/2 holds.
AtomicAndPhysicalConstants.G_HELION — Constant
G_HELION::Float64The helion spin g-factor renormalized to the helion magneton e*hbar/(2*M_HELION), the convention in which the gyromagnetic anomaly a = (|g|-2)/2 holds.
AtomicAndPhysicalConstants.G_TRITON — Constant
G_TRITON::Float64The triton spin g-factor renormalized to the triton magneton e*hbar/(2*M_TRITON), the convention in which the gyromagnetic anomaly a = (|g|-2)/2 holds.
AtomicAndPhysicalConstants.ANOMALY_ELECTRON — Constant
ANOMALY_ELECTRON::Float64The electron gyromagnetic anomaly per the selected CODATA release.
AtomicAndPhysicalConstants.ANOMALY_MUON — Constant
ANOMALY_MUON::Float64The muon gyromagnetic anomaly per the selected CODATA release.
AtomicAndPhysicalConstants.E_CHARGE — Constant
E_CHARGE::Float64Magnitude of the charge on the electron in C per the selected CODATA release.
AtomicAndPhysicalConstants.C_LIGHT — Constant
C_LIGHT::Float64Speed of light in m/s per the selected CODATA release.
AtomicAndPhysicalConstants.H_PLANCK — Constant
H_PLANCK::Float64Planck's constant $h$ in eV·s per the selected CODATA release.
AtomicAndPhysicalConstants.H_BAR — Constant
H_BAR::Float64Reduced Planck constant $\hbar$ in eV·s per the selected CODATA release.
AtomicAndPhysicalConstants.R_ELECTRON — Constant
R_ELECTRON::Float64Classical electron radius in m per the selected CODATA release.
AtomicAndPhysicalConstants.R_PROTON — Constant
R_PROTON::Float64Classical proton radius in m per the selected CODATA release.
AtomicAndPhysicalConstants.CLASSICAL_RADIUS_FACTOR — Constant
CLASSICAL_RADIUS_FACTOR::Float64Classical radius factor $e^2/(4 \pi \varepsilon_0) = r_e m_e c^2$ in eV·m.
Not a tabulated CODATA value: it is derived from the selected release as R_ELECTRON * M_ELECTRON, and so is not a field of CODATA_release. It is the same for all particles of charge ±1.
AtomicAndPhysicalConstants.K_BOLTZMANN — Constant
K_BOLTZMANN::Float64Boltzmann constant $k_B$ in eV/K per the selected CODATA release.
AtomicAndPhysicalConstants.EPS_0 — Constant
EPS_0::Float64Permittivity of free space in 1/(eV·m) per the selected CODATA release.
AtomicAndPhysicalConstants.MU_0 — Constant
MU_0::Float64Vacuum permeability in eV·s²/m per the selected CODATA release.
AtomicAndPhysicalConstants.AVOGADRO — Constant
AVOGADRO::Float64Avogadro's constant in mol⁻¹ (exact) from the selected CODATA release.
AtomicAndPhysicalConstants.FINE_STRUCTURE — Constant
FINE_STRUCTURE::Float64Fine-structure constant from the selected CODATA release.
AtomicAndPhysicalConstants.RELEASE_YEAR — Constant
RELEASE_YEAR::IntThe release year of the currently selected CODATA values.
AtomicAndPhysicalConstants.KG_PER_AMU — Constant
KG_PER_AMU::Float64Kilograms per dalton in the selected CODATA release.
Derived from the release's G_PER_AMU field (grams per dalton); there is no KG_PER_AMU field on CODATA_release.
AtomicAndPhysicalConstants.EV_PER_AMU — Constant
EV_PER_AMU::Float64eV/c² per dalton in the selected CODATA release.
AtomicAndPhysicalConstants.J_PER_EV — Constant
J_PER_EV::Float64Joules per eV in the selected CODATA release.
AtomicAndPhysicalConstants.EV_PER_J — Constant
EV_PER_J::Float64eV per Joule in the selected CODATA release.
AtomicAndPhysicalConstants.G_PER_EV — Constant
G_PER_EV::Float64Grams per eV/c² in the selected CODATA release.
AtomicAndPhysicalConstants.KG_PER_MEV_C2 — Constant
KG_PER_MEV_C2::Float64Kilograms per MeV/c².
Derived from G_PER_EV in the selected CODATA release, and so is not a field of CODATA_release.
Internal types
Not exported, and documented here only because the exported dictionaries and release structs are built from them. Unlike Species, these are plain structs with ordinary dot access.
AtomicAndPhysicalConstants.SubatomicSpecies — Type
SubatomicSpeciesInternal struct storing intrinsic data for a single subatomic particle. Instances are stored in SUBATOMIC_SPECIES.
Fields
speciesname::String— openPMD particle identifier.charge::Float64— charge in units of e.mass::Float64— mass in eV/c².moment::Float64— magnetic dipole moment in eV/T.spin::Float64— spin in ħ.gspin::Float64— spin g-factor.
AtomicAndPhysicalConstants.AtomicSpecies — Type
AtomicSpeciesInternal struct storing isotope data for a chemical element. Instances are stored in ATOMIC_SPECIES.
Fields
Z::Int— atomic number (number of protons).speciesname::String— standard atomic symbol (e.g."Fe").mass::Dict{Int,Float64}— isotope masses in atomic mass units (u), keyed by mass number. The special key−1holds the abundance-averaged atomic mass.spin::Dict{Int,Float64}— ground-state nuclear spins in units of ħ, keyed by mass number, taken from NUBASE2020.NaNmarks an isotope to which NUBASE assigns no unambiguous spin. There is deliberately no−1key: the abundance average has no meaningful spin, because different isotopes of an element have different ones.
AtomicAndPhysicalConstants.CODATA_release — Type
CODATA_releaseKeyword-argument struct holding all fundamental constants from one CODATA release year. Fields mirror the exported scalar constants (M_ELECTRON, C_LIGHT, etc.) but are grouped together so that multiple release years can coexist in memory simultaneously.
Pre-built instances are exported as CODATA2002, CODATA2006, CODATA2010, CODATA2014, CODATA2018, and CODATA2022.
CODATA2018.M_ELECTRON # electron mass from the 2018 release
CODATA2014.C_LIGHT # speed of light from the 2014 release