## UnitfulAtomic.jl

An extension of Unitful.jl for working with atomic units
Author sostock
Popularity
7 Stars
Updated Last
1 Year Ago
Started In
September 2018

# UnitfulAtomic

This package extends the Unitful.jl package to facilitate working with atomic units.

## Functions

This package provides three functions that enable easy conversion from and to Hartree atomic units:

• `aunit(x)` returns the appropriate atomic unit for `x`, where `x` can be a `Unitful.Quantity`, `Unitful.Units`, or `Unitful.Dimensions`:
```julia> aunit(2.3u"cm")
a₀

julia> aunit(u"T")
ħ a₀^-2 e^-1```
• `auconvert` can be used to convert from and to atomic units. It has two methods:
• `auconvert(x::Unitful.Quantity)` converts a quantity to the appropriate atomic unit:
```julia> auconvert(13.6u"eV")
0.499790781587053 Eₕ

julia> auconvert(20u"nm")
377.94522492515404 a₀```
• `auconvert(u::Unitful.Units, x::Number)` interprets `x` as a quantity in atomic units and converts it to the unit `u`:
```julia> auconvert(u"eV", 1)  # convert 1 Eₕ to eV
27.211386246088992 eV

julia> auconvert(u"m", 1)   # convert 1 a₀ to m
5.29177210903e-11 m```
• `austrip(x::Unitful.Quantity)` converts a quantity to the appropriate atomic unit and then strips the units. This is equivalent to `Unitful.ustrip(auconvert(x))`:
```julia> austrip(13.6u"eV")
0.499790781587053

julia> austrip(20u"nm")
377.94522492515404```

## Defined units

The package defines the following atomic units (suffixed with `_au`), from which all other atomic units are derived:

• `me_au` (printed as `mₑ`): the electron rest mass.
• `e_au` (printed as `e`): the elementary charge.
• `ħ_au` (printed as `ħ`): the reduced Planck constant.
• `k_au` (printed as `k`): the Boltzmann constant.
• `a0_au` (printed as `a₀`): the Bohr radius. The alias `bohr` can be used instead of `a0_au`.
• `Eh_au` (printed as `Eₕ`): the Hartree energy. The alias `hartree` can be used instead of `Eh_au`.

Furthermore, this package defines some units that are not atomic units, but are common in atomic physics: