# \[ANN & RFC\] New package: PhysicalConstants.jl

**URL:** <https://discourse.julialang.org/t/ann-rfc-new-package-physicalconstants-jl/14737>\
**Category:** Community\
**Tags:** unitful\
**Created:** [September 9, 2018, 3:50pm UTC](https://discourse.julialang.org/t/ann-rfc-new-package-physicalconstants-jl/14737 "2018-09-09T15:50:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [April 4, 2019, 10:13pm UTC](https://discourse.julialang.org/t/ann-rfc-new-package-physicalconstants-jl/14737/4 "2019-04-04T22:13:19Z")

</div>

A few days ago, the first official version of [`PhysicalConstants.jl`](https://github.com/JuliaPhysics/PhysicalConstants.jl) has been released 🎉

### Features

- physical constants with physical units (from [`Unitful.jl`](https://github.com/ajkeller34/Unitful.jl)) and optionally with uncertainty (from [`Measurements.jl`](https://github.com/JuliaPhysics/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-auto
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

```

---

_[View the full topic](https://discourse.julialang.org/t/ann-rfc-new-package-physicalconstants-jl/14737)._
