Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit Dalton #51

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.org
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* v0.4.3
- add ~Dalton~ as a unit
- add some more explanations for predefined constants
* v0.4.2
- minor fix to ~to~ such that we use exactly the type as given by the
user, instead of ~yCT.toNimType()~. This is to guarantee the
Expand Down
24 changes: 21 additions & 3 deletions src/unchained/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@ import si_units, units
## in the units of Unchained.

const
## The speed of light in vacuum.
c* = 299792458.0.Meter•Second⁻¹
## The vacuum permitivity / electric constant.
ε_0* = 8.8541878128e-12.A•s•V⁻¹•m⁻¹
## Charge of an electron.
e* = 1.602176634e-19.C
## Mass of an electron.
m_e* = 9.1093837015e-31.kg
m_e_c2* = 0.510998928.MeV
## Mass of a muon.
m_μ* = 1.883531627e-28.kg # 105.6583755e3 # MeV / c²
m_μ_eV* = 105.6583755e6.eV # / c²
## The Avogadro constant. The number of particles in one mole of substance, per definition.
N_A* = 6.02214076e23.mol⁻¹
## The 'molar mass constant'. Prior to redefinition in 2019 it was defined as exactly
## M_u = 1 g/mol. It relates the standard atomic weight of an element with its
## mas for one mole of substance.
M_u* = 0.99999999965e-3.kg•mol⁻¹
## The 'atomic mass constant', the "base mass" for atomic scale objects, defined as
## `m_u = 1/12 · m(¹²C) = 1 Dalton`
## i.e. the average mass of a single nucleon in a bound atom.
m_u* = M_u / N_A
m_μ_eV* = 105.6583755e6.eV # / c²
m_μ* = 1.883531627e-28.kg # 105.6583755e3 # MeV / c²
π* = PI
r_e* = e*e / (4 * π * ε_0 * m_e * c * c) # classical electron radius
## The classical electron radius.
r_e* = e*e / (4 * π * ε_0 * m_e * c * c)
#K = 4 * π * N_A * r_e * r_e * m_e_c2 * (100.0^2)# [MeV mol⁻¹ cm²]
## The Boltzmann constant
k_B* = 1.380649e-23.Joule•Kelvin⁻¹
## Planck's constant
hp* = 6.62607015e-34.Joule•Hertz⁻¹
## Reduced Planck's constant
hp_bar* = hp / (2 * π)
## Newton's constant. Note: We do not use the common variabl `G`, as it obviously conflicts
## with the `Giga` prefix in the general case. Feel free to locally define it as such.
G_Newton* = 6.6743e-11.N•m²•kg⁻²
5 changes: 5 additions & 0 deletions src/unchained/si_units.nim
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ declareUnits:
quantity: Length
conversion: 30856775814913673.0.m # 1 AU * 180° * 60 * 60 / π

Dalton: # unified atomic mass, m_u = 1/12 m(¹²C) = 1 Da.
short: Da
quantity: Mass
conversion: 1.66053906892e-27.kg # 1.66053906892(52)×10−27

# given that we have base units & derived base units defined, we can now just
# dump everything together. Everything that is referenced before, can now be
# used to define new units.
Expand Down
Loading