Skip to content

About

Defines Gaussian units with proper Gaussian unit system dimensions. Extension of Unitful.jl

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnitfulGauss

UnitfulGauss.jl is a small extension package for Unitful.jl that defines Gaussian electromagnetic units with proper dimensions.

Electromagnetic quantities have different dimensions in SI and Gauss unit systems. For example, the Charge has dimension 𝐈*𝐓 in SI system, while it has dimension sqrt(𝐌*𝐋^3)/𝐓 in Gaussian system.
Although Unitful.jl already defines the Gaussian units, they have the dimensions corresponding to the SI system. As a consequence, if you try to plug them in equations written in the Gaussian unit system, the result will be nonsensical.

Usage

UnitfulGauss.jl uses the same symbols for the Gaussian units as Unitful.jl but appends superscript g at the end. For example, the Coulomb unit of charge with Gaussian system dimension is UnitfulGauss.Cᵍ Since it is a hassle to remember which units have different dimensions between SI and Gaussian unit systems and need the superscript g at the end, UnitfulGauss.jl exports a string macro @ug_str that works identical to @u_str from Unitful.jl but "gaussifies" the electromagnetic units under the hood.

using UnitfulGauss

ug"C" === UnitfulGauss.Cᵍ            # Coulomb unit of charge with Gaussian system dimension 
ug"Gauss" === UnitfulGauss.Gaussᵍ    # Gauss unit of B-field with Gaussian system dimension

In addition to that, UnitfulGauss.jl also exports functions to_gauss and to_si that transform units and quantities from SI unit system into the Gaussian one and vice versa.

to_gauss(1.0u"V/cm") === 1.0*UnitfulGauss.Vᵍ/u"cm"
to_si(UnitfulGauss.Wbᵍ) === u"Wb"

This functionality can be used, for example, to convert physical constants from PhysicalConstants.jl into Gaussian unit system.

using UnitfulGauss, PhysicalConstants

import PhysicalConstants.CODATA2022: ε_0

ε₀ᵍ = uconvert(UnitfulGauss.NoUnits, ε_0 |> float |> to_gauss)

4π*ε₀ᵍ ≈ 1.0

As expected, in the Gaussian unit system, the Vacuum electric permittivity is a dimensionless constant equal to 1/4π.

Standalone usage

UnitfulGauss.jl is designed to be used as a standalone package. It reexports Unitful.jl together with its @u_str macro. It also explicitly imports the types associated with mechanical quantities (such as Area, AreaUnits and AreaFreeUnits) and makes them public. For the electromagnetic quantities, the new derived dimensions are defined, which includes the Current.

UnitfulGauss.jl is registered with Unitful.jl, so you can also access the gaussian Coulomb, for example, as u"Cᵍ".

Finally, the package also provides Gaussian versions of the physical constants defined in Unitful.jl, such as UnitfulGauss.c0, UnitfulGauss.q, UnitfulGauss.h, UnitfulGauss.μB, and UnitfulGauss.R∞.

About

Defines Gaussian units with proper Gaussian unit system dimensions. Extension of Unitful.jl

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages