21.1 Algorithms and Equations

The Cosmology unit makes several assumptions about the interpretation of physical quantities that enable any hydrodynamics or materials units written for a non-expanding universe to work unmodified in a cosmological context. All calculations are assumed to take place in comoving coordinates $ {\bf x} = {\bf r}/a$, where $ {\bf r}$ is a proper position vector and $ a(t)$ is the time-dependent cosmological scale factor. The present epoch is defined to correspond to $ a=1$; in the following discussion we use $ t=t_0$ to refer to the age of the Universe at the present epoch. The gas velocity $ {\bf v}$ is taken to be the comoving peculiar velocity $ {\dot {\bf x}}$. The comoving gas density, pressure, temperature, and internal energy are defined to be

$\displaystyle \rho$ $\displaystyle \equiv$ $\displaystyle a^3{\tilde \rho}$  
$\displaystyle p$ $\displaystyle \equiv$ $\displaystyle a{\tilde p}$ (21.1)
$\displaystyle T$ $\displaystyle \equiv$ $\displaystyle {{\tilde T}\over a^2}$  
$\displaystyle \rho\epsilon$ $\displaystyle \equiv$ $\displaystyle a{\tilde\rho}{\tilde\epsilon} .$  

The quantities marked with a tilde, such as $ {\tilde\rho}$, are the corresponding “proper” or physical quantities. Note that, in terms of comoving quantities, the equation of state has the same form as for the proper quantities in noncomoving coordinates. For example, the perfect-gas equation of state is

$\displaystyle \rho\epsilon = {p\over{\gamma-1}} = {\rho k T\over (\gamma-1)\mu} .$ (21.2)

With these definitions, the Euler equations of hydrodynamics can be written in the form

$\displaystyle {\partial\rho\over\partial t} + \nabla\cdot(\rho{\bf v}) = 0$ (21.3)

$\displaystyle {\partial\rho{\bf v}\over\partial t} + \nabla\cdot(\rho{\bf vv}) + \nabla p + 2{{\dot a}\over a}\rho{\bf v} + \rho\nabla\phi = 0$ (21.4)

$\displaystyle {\partial\rho E\over\partial t} + \nabla\cdot[(\rho E + p){\bf v}...
...}\over a}[(3\gamma-1)\rho\epsilon + 2\rho v^2] + \rho{\bf v}\cdot\nabla\phi = 0$ (21.5)

$\displaystyle {\partial\rho\epsilon\over\partial t} + \nabla\cdot[(\rho\epsilon...
...\bf v}] -{\bf v}\cdot\nabla p + {{\dot a}\over a}(3\gamma-1)\rho\epsilon = 0 .$ (21.6)

Here $ E$ is the specific total energy, $ \epsilon + {1\over 2}v^2$, and $ \gamma$ is the effective ratio of specific heats. The Cosmology unit applies the terms involving $ {\dot a}$ via the Cosmology_redshiftHydro routine.

The comoving potential $ \phi$ in the above equations is the solution to the Poisson equation in the form

$\displaystyle \nabla^2\phi= {4\pi G\over a^3}(\rho - {\bar \rho}) ,$ (21.7)

where $ {\bar \rho}$ is the comoving mean matter density. Note that, because of the presence of $ a$ in (21.7), the gravity units must explicitly divide their source terms by $ a^3$.

Units like the Gravity unit, which require the scale factor or the redshift $ z$ ( $ a = (1+z)^{-1}$), can obtain the redshift via Cosmology_getRedshift, and use the previous relation to obtain the scaling factor. The time represented by a cosmological redshift can be obtained by a call to Cosmology_redshiftToTime and passing it a cosmological redshift. Note also that if a collisionless matter component (e.g.particles) is also present, its density must be added to the gas density on the right-hand side of (21.7). Accounting for particle masses in density is handled by the Gravity unit.

The comoving mean matter density is defined in terms of the critical density $ \rho_{\rm crit}$ by

$\displaystyle {\bar \rho}$ $\displaystyle \equiv$ $\displaystyle \Omega_m\rho_{\rm crit}$  
$\displaystyle \rho_{\rm crit}$ $\displaystyle \equiv$ $\displaystyle {3H^2\over 8\pi G} .$ (21.8)

The Hubble parameter $ H(t)$ [to be distinguished from the Hubble “constant” $ H_0\equiv H(t_0)$] is given by the Friedman equation

$\displaystyle H^2(t) \equiv \left({{\dot a}\over a}\right)^2 = H_0^2\left( {\Om...
...er a^3} + {\Omega_r\over a^4} + \Omega_\Lambda - {\Omega_c\over a^2} \right) .$ (21.9)

Here $ \Omega_m$, $ \Omega_r$, and $ \Omega_\Lambda$ are the present-day densities, respectively, of matter, radiation, and cosmological constant, divided by $ \rho_{\rm crit}$. The contribution of the overall spatial curvature of the universe is given by

$\displaystyle \Omega_c \equiv \Omega_m+\Omega_r+\Omega_\Lambda - 1 .$ (21.10)

The Cosmology_solveFriedmannEqn routine numerically solves the Friedmann equation to obtain the scale factor and its rate of change as functions of time. In principle, any good ODE integrator can be used; the csm_integrateFriedman subroutine uses a fourth-order Runge-Kutta method to integrate the Friedmann equation under the assumption that $ \Omega_r = 0$. Subunits can also use analytic solutions where appropriate.

Redshift terms for particles are handled separately by the appropriate time integration subunits of the Particles unit. For an example, see the LeapfrogCosmo implementation of the ParticlesMain subunit in Sec:Active Partices Integration.