[ANN & RFC] New package: PhysicalConstants.jl

A few days ago, the first official version of PhysicalConstants.jl has been released :tada:

Features

  • physical constants with physical units (from Unitful.jl) and optionally with uncertainty (from Measurements.jl)
  • support for any AbstractFloat type that can be converted from Float64, and for BigFloat. This could be particularly useful for exact constants (like speed of light, and more coming in next CODATA 2018 dataset!), they’ll be always exact!
  • the package is modular in the sense that you can import the dataset that you want to use. The idea is that the package will provide different dataset (e.g., different versions of CODATA constants), but the user will load only the one they are interested in
  • informative printing of constants in the REPL
  • constants can be readily used in any mathematical operations supported by AbstractQuantity (the type in terms of which are defined the operations in Unitful.jl)

Example

julia> using PhysicalConstants.CODATA2014

julia> SpeedOfLightInVacuum
Speed of light in vacuum (c_0)
Value                         = 2.99792458e8 m s^-1
Standard uncertainty          = (exact)
Relative standard uncertainty = (exact)
Reference                     = CODATA 2014

julia> NewtonianConstantOfGravitation
Newtonian constant of gravitation (G)
Value                         = 6.67408e-11 m^3 kg^-1 s^-2
Standard uncertainty          = 3.1e-15 m^3 kg^-1 s^-2
Relative standard uncertainty = 4.6e-5
Reference                     = CODATA 2014

julia> import PhysicalConstants.CODATA2014: c_0, ε_0, μ_0, ħ, h

julia> 2 * ε_0
1.7708375635240778e-11 F m^-1

julia> ε_0 - 1 / (μ_0 * c_0 ^ 2)
0.0 A^2 s^4 kg^-1 m^-3

julia> big(ε_0) - inv(big(μ_0) * big(c_0)^2)
0.0 A^2 s^4 kg^-1 m^-3

julia> using Measurements

julia> ħ
Planck constant over 2pi (ħ)
Value                         = 1.0545718001391127e-34 J s
Standard uncertainty          = 1.2891550390443523e-42 J s
Relative standard uncertainty = 1.2e-8
Reference                     = CODATA 2014

julia> measurement(ħ)
1.0545718001391127e-34 ± 1.2891550390443523e-42 J s

julia> measurement(Float32, ħ)
1.0545718e-34 ± 1.289e-42 J s

julia> measurement(BigFloat, ħ)
1.054571800139112651153941068725066773746246506229852090971714108355028066256094e-34 ± 1.289155039044352219727958483317366332479123130497697234856105486877064060837251e-42 J s

julia> measurement(BigFloat, ħ) / (measurement(BigFloat, h) / (2 * big(pi)))
1.0 ± 0.0
10 Likes