Some Useful Constants for Julia



Build Status Coverage Status codecov.io

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.


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

julia> e.unit

julia> e.value

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

julia> e + 2

A list of included constants

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


julia> using Constants

julia> DATA

NIST CODATA Fundamental Physical Constants

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"]


julia> Constants.DATA["NIST"]["standard atmosphere"]

Defined Constants

Some constants is defined in theory, like magnetic constant (vacuum permeability), they are also supported, currently we have:

List of Bindings

  • c: speed of light in vacuum
  • c0: speed of light in vacuum
  • G: Newtonian constant of gravitation
  • g: standard acceleration of gravity
  • h: Planck constant
  • ħ : Planck constant over 2 pi
  • e: atomic unit of charge (use eu for mathematical constant e)
  • a0 : Bohr radius
  • α : fine-structure constant
  • k: Boltzmann constant
  • NA: Avogadro constant
  • atm: standard atmosphere
  • μ0: magnetic constant (vacuum permeability)
  • ε0: electric constant (vacuum permittivity)

First Commit


Last Touched

about 3 years ago


6 commits

Used By: