Physical Constants
Some useful constants for Julia.
NOTE There is no test for this at the moment, since most of the codes are just bindings. But I will add some unit test in the future versions.
Pkg.add("PhysConsts")
Use import to import certain constant's alias input the scope. And you can access some property by the following commands.
# import atomic unit of charge
julia> import Constants: e
julia> e.quantity
"atomic unit of charge"
julia> e.uncertainty
9.8e-28
julia> e.unit
"C"
julia> e.value
1.6021766208e-19
All the constants overload most of the interface of Number
and constant types are subtypes of Number
. Therefore, you can just use them like native numbers
julia> e * 2
3.2043532416e-19
julia> e + 2
2.0
All constants is stored in a Dict
called DATA
, Constants
will export
this dict, you can access it by
julia> import Constants
julia> Constants.DATA
or
julia> using Constants
julia> DATA
Constants
will download a JSON file from NIST CODATA automatically when you install the package. All constants in this JSON file is included. This part can be access from DATA
by
julia> Constants.DATA["NIST"]["YOUR CONSTANT NAME"]
e.g
julia> Constants.DATA["NIST"]["standard atmosphere"]
101325.0
Some constants is defined in theory, like magnetic constant (vacuum permeability), they are also supported, currently we have:
c
: speed of light in vacuumc0
: speed of light in vacuumG
: Newtonian constant of gravitationg
: standard acceleration of gravityh
: Planck constantħ
: Planck constant over 2 pie
: atomic unit of charge (useeu
for mathematical constante
)a0
: Bohr radiusα
: fine-structure constantk
: Boltzmann constantNA
: Avogadro constantatm
: standard atmosphereμ0
: magnetic constant (vacuum permeability)ε0
: electric constant (vacuum permittivity)