Units

Code Convention

We adopt the convention that:

\[\begin{split}G &= 1\\ H_0 &= \sqrt{\frac{8}{3}\pi}\end{split}\]

where \(G\) is the gravitational constant and \(H_0\) is the Hubble parameter. Given the definition of \(\rho_c\) (the critical density of the universe), it follows that:

\[\rho_{c} = \frac{3H_0^2}{8\pi G} = 1\]

Cosmological Units

For cosmological runs we adopt the usual comoving coordinates and periodic boundary conditions. We also adopt the convention:

\[L = 1\]

where \(L\) is the length of the periodic box centered on \(0,0,0\). The coordinates x, y and z have the range \(\left[-0.5,0.5\right)\). This also means that the volume of the box is \(1\), and thus the total matter (dark matter and baryons) in the box must be:

\[M_{box} = \Omega_m\times\rho_c\times V = \Omega_m\]

where \(\Omega_m\) is the matter density of the Universe.

Conversion to Physical Units

Summary

Unit

Multiply by

Units

Length

L

comoving \(h^{-1}\) Mpc

Mass

\(L^3\times 2.77536627208\times 10^{11}\)

\(h^{-1}M_\odot\)

Velocity

\(\sqrt{\frac{8\pi}{3}}\div({L\times a\times 100})\)

km/s

Where:

\(L\)

The physical length of the box in comoving \(h^{-1}\) Mpc.

\(a\)

The expansion factor.

Derivation

It is helpful to introduce the value of the gravitational constant.

\[G = 4.30091727063\times 10^{-9}~\text{Mpc}~M_\odot^{-1}\left(\text{km}/\text{s}\right)^2\]

Recall that:

\[\frac{1~\text{pc}}{1~\text{au}} = \frac{180\times 60\times 60}{\pi}\]

where:

pc

The length of a parsec.

au

The length of the astronomical unit which is defined to be exactly 149 597 870 700 meters.

This means that \(1\) Mpc is \(\pi^{-1}\times 9.69394202136\times 10^{19}\) km, so we can rewrite \(G\) as the product of a density and time squared.

\[\begin{split}G &= 4.30091727063\times 10^{-9}\frac{Mpc}{M_\odot}\left(\frac{\text{km}}{\text{s}}\right)^2 \times \left(\frac{\pi}{9.69394202136\times 10^{19}}\right)^2\left(\frac{\text{Mpc}}{\text{km}}\right)^2\\ &= \frac{4.30091727063\times 10^{-9}\times\pi^2}{9.69394202136^2\times 10^{38}} \frac{\text{Mpc}^3}{M_\odot}\frac{1}{s^2}\\ &= 4.51710305052\times 10^{-48}\frac{\text{Mpc}^3}{M_\odot}\frac{1}{s^2}\end{split}\]

Also recall that:

\[H_0 = 100h \left[\text{km}/\text{s}/\text{Mpc}\right]\]

Length

The length unit is simply the width of the cosmological box in \(L\) in \(h^{-1}\) Mpc.

Mass

The density unit is given by:

\[\begin{split}\rho_{unit} &= \rho_c\left[\frac{M_\odot}{\text{Mpc}^3}\right]\\ &= \frac{3H_0^2}{8\pi G}\left[\frac{M_\odot}{\text{Mpc}^3}\right]\\ &= \frac{3\times 100^2\times h^2}{8\pi G}\left[\frac{M_\odot}{\text{Mpc}^3}\right]\\ &= \frac{3\times 100^2\times h^2}{8\pi \times 4.30091727063\times 10^{-9}}\left[\frac{M_\odot}{\text{Mpc}^3}\right]\\ &= 2.77536627208\times 10^{11}~\left[\frac{h^2 M_\odot}{\text{Mpc}^3}\right]\end{split}\]

The mass unit is given by:

\[\begin{split}M_{box} &= L^3\left[h^{-3}\text{Mpc}^3\right]\times \rho_c\left[\frac{h^2 M_\odot}{\text{Mpc}^3}\right]\\ &= L^3\times 2.77536627208\times 10^{11}~h^{-1}M_\odot\end{split}\]

Velocity

The \(G=1\) criteria allows us to derive the velocity unit by factoring out the mass unit and the length unit.

\[\begin{split}\left(\frac{\text{km}}{\text{s}}\right)^2 &= G\times \frac{M_{box}}{L}\\ &= G\times \frac{M_{box}}{L}\times\rho_c\frac{L^3}{M_{box}}\\ &= G\times L^2\times\rho_c\\ &= G\times L^2\times \frac{3H_0^2}{8\pi G}\\ &= \frac{3}{8\pi}\times H_0^2\times L^2\\ \frac{\text{km}}{\text{s}} &= \sqrt{\frac{3}{8\pi}}\times H_0 \times L\\ &= \sqrt{\frac{3}{8\pi}}\times 100h \times L\\\end{split}\]

Thus when \(L\) is expressed in \(h^{-1}\) Mpc:

\[V_{unit} = \frac{\sqrt{\frac{8}{3}\pi}}{L\times 100}\]

Or in proper (non-comoving) units:

\[V_{unit} = \frac{\sqrt{\frac{8}{3}\pi}}{L\times a\times 100}\]

Time

The \(G=1\) criteria also allows us to derive the time unit by factoring out the density unit.

\[\begin{split}G &= 4.51710305052\times 10^{-48}\frac{\text{Mpc}^3}{M_\odot}\frac{1}{s^2}\\\end{split}\]

Multiplying by our density unit gives:

\[\begin{split}\frac{1}{t_{unit}^2} &= G\times\rho_{unit}\\ &= 4.51710305052\times 10^{-48}\frac{\text{Mpc}^3}{M_\odot}\frac{1}{s^2} \times 2.77536627208\times 10^{11}\frac{M_\odot}{\text{Mpc}^3}\\ &= 1.25366154539\times 10^{-36}\frac{1}{s^2}\\ \frac{1}{t_{unit}} &= \sqrt{1.25366154539\times 10^{-36}\frac{1}{s^2}}\\ &= 1.1196702842\times 10^{-18}\frac{1}{s}\\ t_{unit} &= 8.9312006765\times 10^{17} s\end{split}\]

Other Unit Systems

kpc & km/s

It is often convenient to fix the length unit to be kpc, and the velocity unit to be km/s. With \(G=1\) as before, we can calculate the mass unit:

\[\begin{split}G &= 4.30091727063\times 10^{-9}~\text{Mpc}~M_\odot^{-1}(\text{km}/\text{s})^2\\ &= 4.30091727063\times 10^{-6}~\text{kpc}~M_\odot^{-1}(\text{km}/\text{s})^2\\\end{split}\]

Thus, for \(G=1\), the mass unit must be:

\[M_{unit} = \frac{1}{4.30091727063\times 10^{-6}} = 2.32508541103\times 10^5~M_\odot\]

The length unit is kpc, so the density unit is:

\[\rho_{unit} = 2.32508541103\times 10^5\frac{M_\odot}{\text{kpc}^3}\]

Similarily the time unit must be:

\[\begin{split}\frac{1}{t_{unit}^2} &= G\times\rho_{unit}\\ &= 4.51710305052\times 10^{-48}\frac{\text{Mpc}^3}{M_\odot}\frac{1}{\text{s}^2} \times 2.32508541103\times 10^5\frac{M_\odot}{\text{kpc}^3}\\ &= 4.51710305052\times 10^{-48}\frac{\text{Mpc}^3}{M_\odot}\frac{1}{\text{s}^2} \times 2.32508541103\times 10^{14}\frac{M_\odot}{\text{Mpc}^3}\\ &= 1.05026504029\times 10^{-33}\frac{1}{\text{s}^2}\\ \frac{1}{t_{unit}} &= \sqrt{1.05026504029\times 10^{-33}\frac{1}{\text{s}^2}}\\ &= 3.24077928944\times 10^{-17}\frac{1}{\text{s}}\\ t_{unit} &= 3.08567758149\times 10^{16}~\text{s}\\ &\approx 0.978461942~\text{Gyrs}\end{split}\]

kpc & Gyrs

One can also fix the length unit to kpc, the time unit to Gyrs and thus the velocity unit to kpc/Gyr. The mass unit is then:

\[\begin{split}G &= 4.51710305052\times 10^{-48}\frac{Mpc^3}{M_\odot}\frac{1}{s^2}\\ &= 4.51710305052\times 10^{-39}\frac{kpc^3}{M_\odot}\frac{1}{s^2}\\\end{split}\]

With \(3.15581184\times 10^7\) seconds in a year and \(3.15581184\times 10^{16}\) seconds in a Gyr, we get:

\[\begin{split}G &= 4.51710305052\times 10^{-39}\frac{kpc^3}{M_\odot}\frac{1}{s^2} \times \left(3.15581184\times 10^{16}\frac{s}{Gyr}\right)^2\\ &= 4.49864994804\times 10^{-6}\frac{kpc^3}{M_\odot Gyr}\end{split}\]

This means that the mass unit is:

\[M_{unit} = \frac{1}{4.49864994804\times 10^{-6}}~M_\odot = 2.22288911462\times 10^5~M_\odot\]

Velocity

It should be noted that kpc/Gyr is very nearly km/s. This should be obvious because the time unit in the kpc and km/s unit system is very nearly 1 Gyr (but not exactly).

\[V = \frac{kpc}{Gyr} = \frac{\pi^{-1}\times 9.69394202136\times 10^{16}\frac{km}{kpc}}{3.15581184\times 10^{16}\frac{\text{s}}{\text{Gyr}}} = 0.97777615965~\text{km}/\text{s}\]

Units calculator

The file /tools/calculate_units.py provides a tool that allows to calculate the values for dKpcUnit and dMsolUnit that go into the parameter file. It provides six different modes, where any two of the four values mass unit, length unit, velocity unit and time unit can be provided.

Some sample sets of units relevant for planetary scale simulations are:

Length unit: 1 Earth radius, Velocity unit: 1 km/s
dKpcUnit = 2.064688206889847e-13
dMsolUnit = 4.8006351375833994e-08

Length unit: 1 Astronomical unit, Velocity unit: 1 km/s
dKpcUnit = 4.848101587970315e-09
dMsolUnit = 0.0011272388129170855

Length unit: 1 Astronomical unit, Mass unit: 1 Jupiter mass
dKpcUnit = 4.848101587970315e-09
dMsolUnit = 0.0009548380607523638