Introduction
Cosmology is an initial-value problem at astronomical scale. Specify a background expansion, seed it with primordial fluctuations, and evolve matter and radiation forward to the sky we observe. Computation is the connective tissue: Boltzmann solvers predict CMB spectra; N-body codes grow the cosmic web; radiation-hydrodynamics tracks baryons and feedback. This page blends the physics (expansion, perturbations, recombination) with the numerics (discretization, integrators, HPC) that turns the ΛCDM model into images, power spectra, and synthetic surveys.
Three themes recur. Scales: from sub-kpc star formation to Gpc boxes, multi-scale methods are essential. Statistics: we rarely solve for a single realization; we predict distributions and correlation functions. Structure preservation: symplecticity and conservation laws keep the numerics faithful over billions of years of simulated time.
Background Expansion & Initial Conditions
The homogeneous universe obeys the Friedmann equations \(H^2 = \frac{8\pi G}{3}\rho - \frac{k}{a^2} + \frac{\Lambda}{3}\). Given densities \((\Omega_m,\Omega_b,\Omega_r,\Omega_\Lambda)\), we integrate the scale factor \(a(t)\) and comoving distances \(\chi(z)\). Initial perturbations are drawn from a nearly scale-invariant power spectrum \(P_\mathcal{R}(k)\) motivated by inflation. To start a simulation at redshift \(z_{\rm init}\), we generate a Gaussian random field with spectrum \(P(k)\), displace particles using the Zel’dovich approximation or 2LPT, and imprint baryon acoustic oscillations in the phases.
Choices made here echo throughout: box size must contain long-wavelength modes that modulate formation; particle number and mesh resolution set the Nyquist limit; random seeds control cosmic variance across ensembles.
Linear Theory & Boltzmann Codes
At early times and on large scales, perturbations remain linear. We expand the distribution functions for photons and neutrinos in multipoles and integrate the coupled Einstein–Boltzmann system to obtain transfer functions \(T(k,\eta)\). Line-of-sight integration projects sources (Sachs–Wolfe, Doppler, polarization) onto spherical harmonics, yielding CMB power spectra \(C_\ell^{TT}, C_\ell^{TE}, C_\ell^{EE}\). Baryons and dark matter obey fluid/Poisson equations to produce the linear matter power \(P_{\rm lin}(k,z)\).
Numerically this is stiff: recombination introduces rapid transitions; tight-coupling demands asymptotic expansions; neutrino hierarchies require truncation schemes. Step controllers and implicit/explicit blends keep integration stable while preserving acoustic phases essential for BAO.
Nonlinear Growth: N-Body & Hydrodynamics
Beyond the linear regime, gravity collapses matter into halos and filaments. Collisionless dark matter is modeled by \(N\) particles moving under a potential \(\Phi\) from the Poisson equation. Particle–Mesh (PM) solvers compute \(\Phi\) on a grid via FFTs; Tree and TreePM methods add short-range force accuracy. Time stepping uses kick–drift–kick leapfrog schemes that are symplectic, preserving phase-space volume and minimizing secular energy drift over Gyrs.
Baryons require hydrodynamics. Finite-volume Godunov schemes with Riemann solvers (or Smoothed Particle Hydrodynamics) evolve mass, momentum, and energy while star-formation and feedback models inject sub-grid physics. Radiative cooling, metal enrichment, and UV backgrounds couple thermodynamics to structure formation, altering halo profiles and small-scale power.
CMB Anisotropies, Lensing & Secondary Effects
Primary temperature and polarization patterns originate at recombination, but large-scale structure lenses the CMB, remapping hot and cold spots and converting \(E\) into \(B\) modes. Quadratic estimators reconstruct the lensing potential from mode couplings; delensing sharpens acoustic peaks and primordial \(B\) searches. Secondary anisotropies — Sunyaev–Zel’dovich effects, integrated Sachs–Wolfe, kinetic SZ — require ray-tracing through simulated volumes with ionization and velocity fields.
Numerically, we sample lightcones through periodic boxes, accumulate deflections, and interpolate fields with conservative schemes to avoid smoothing peaks. Resolution and box stitching must preserve two-point and higher-order statistics targeted by surveys.
Algorithms, HPC & Inference
Cosmological runs are HPC showcases. Domain decomposition distributes particles and mesh slabs across nodes; FFTs leverage pencil or slab transposes; GPU kernels accelerate short-range forces and hydro. Checkpointing, reproducible RNGs, and mixed-precision arithmetic balance throughput with scientific integrity.
Connecting theory to data is a Bayesian inverse problem. Fast emulators interpolate between simulations; likelihoods compare mock observables (power spectra, correlation functions, mass functions) to survey data; MCMC and variational inference explore cosmological parameters \(\Theta=\{\Omega_m,\sigma_8,n_s, \ldots\}\). Forward-model pipelines include survey masks, noise, redshift-space distortions, and selection effects to avoid biased inference.