Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

638 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AtomicAndPhysicalConstants.jl

Stable Dev Build Status

Installation

julia> using Pkg
julia> Pkg.add("AtomicAndPhysicalConstants.jl")

Quick Start

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

Supported Particle Species

Subatomic Particles

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 Species

Atomic numbers from 1 ("H") to 118 ("Og") are available with the Species() function.

Mass Number Formatting

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
true

Charge State Specification

Charge 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+++"))
3

Similarly, negative charges with magnitude less than 4_e_ may be given with repeated minus symbols, e.g.

julia> chargeof(Species("K---"))
-3

A 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")
true

Changing the CODATA Release Year

AtomicAndPhysicalConstants.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()

Directly Exported Constants

Masses with units [eV/c²]

  • M_ELECTRON
  • M_PROTON
  • M_NEUTRON
  • M_MUON
  • M_DEUTERON
  • M_HELION
  • M_TRITON
    • This constant is not available from the 2002 CODATA release
  • M_PION_0
  • M_PION_CHARGED

Both Pion masses are obtained from PDG, rather than CODATA.

Magnetic dipole moments with units [eV/T]

  • MU_ELECTRON
  • MU_PROTON
  • MU_NEUTRON
  • MU_MUON
  • MU_DEUTERON
  • MU_HELION
  • MU_TRITON

Dimensionless constants

  • AVOGADRO
  • FINE_STRUCTURE

Spin G-factors

  • G_ELECTRON
  • G_PROTON
  • G_NEUTRON
  • G_MUON
  • G_DEUTERON
  • G_HELION
    • This constant is not available from CODATA releases prior to 2010
  • G_TRITON

Gyromagnetic Anomalies

  • 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

Other Physical Constants

  • 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 as R_ELECTRON * M_ELECTRON
  • EPS_0: Permittivity of free space in [1/(eV⋅m)]
  • MU_0: Vacuum Permeability in [eV⋅s²/m]

Conversion Constants

  • KG_PER_AMU:
  • EV_PER_AMU
  • J_PER_EV
  • G_PER_EV
  • KG_PER_MEV_C2

About

Julia package for handling physical constants and particle properties (mass, spin, etc.) identification in simulations.

Topics

Resources

Stars

2 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages