SimpleConstants defines the values of some fundamental constants of physics in SI units. PhysicalConstants provides a complete set of fundamental constants with units, but in many cases of writing scientific code we care only about the values of the fundamental constants without units. SimpleConstants is a lightweight package defining those values.
SimpleConstants utilizes Unicode symbols as much as possible to define compact symbols to store the fundamental constants (e.g., ε₀
instead of eps_0
or ε_0
). It further promotes compactness by defining compound constants that are products of fundamental constants that frequently appear in equations. For example,
- the package defines
πc₀ = π * c₀
, with which the angular frequency of an electromagnetic wave of wavelengthλ
can be writtenω = 2πc₀ / λ
instead ofω = 2π * c₀ / λ
; - the package defines
i2π = im * 2π
, with which the complex exponential of an angle 120° can be writtenexp(i2π/3)
instead ofexp(im * 2π / 3)
; etc.
SimpleConstants also defines all the SI prefixes (e.g., kilo
and milli
). Unitful provides a complete set of those prefixes together with other units, but again, SimpleConstants is a lightweight package defining those prefixes. Here is a simple example to convert a wavelength of 1.55 µm to a nm-value:
using SimpleConstants
λ = 1.55micro
λunit = nano
println("λ = $(round(λ/λunit, sigdigits=3)) $(λunit)m.") # print out "λ = 1550.0 nm."