Einstein-Boltzmann Solver
Simulating cosmic perturbations and the CMB power spectrum from inflationary initial conditions in ΛCDM
I implemented a simple Einstein-Boltzmann as a project in the cosmology course AST5220 at the University of Oslo during the Spring semester 2026. It is based upon the template made by Hans A. Winther template made by Hans A. Winther, the guide made by Petter Callin, as well as the lectures by Winther.
The code assumes a flat FLRW background and adiabatic inflationary initial condition and evolves the linear scalar perturbation equations from deep in the radiation dominated era until today. To get around the stiffness problem of the perturbation system in the Thomson scattering-dominated era, we solve it using the tight coupling approximation, and to recover the higher order moments of temperature multipoles we use the line-of-sight integral,
$$\Theta_\ell(k, x=0) = \int_{-\infty}^{0} \tilde{S}(k,x) j_\ell[k(\eta_0-\eta)] \text{d} x$$
with the source function
$$\tilde{S}(k,x) = \tilde{g}\left[ \Theta_0 + \Psi + \frac{1}{4}\Pi\right] + e^{-\tau} \left[\Psi^\prime-\Phi^\prime\right] \\ -\frac{1}{ck}\frac{\text{d}}{\text{d}x}(\mathcal{H}\tilde{g}v_b) + \frac{3}{4c^2k^2} \frac{\text{d}}{\text{d}x} \left[\mathcal{H}\frac{\text{d}}{\text{d}x} (\mathcal{H}\tilde{g}\Pi)\right],$$
taken from Seljak and Zaldarriaga (1996).
The solver includes helium, neutrinos and polarisation, with the possibility of turning each one of these parameters on or off, and can model the late-stage reionisation of hydrogen and helium. It solves the recombination history of the Universe using the Saha approximation and Peebles ODE method, and the background is evolved according to the regular Friedmann equations
\begin{align*} H^2(a) \equiv \bigg(\frac{\dot{a}}{a}\bigg)^2 = \frac{8\pi G}{3}\sum_i \rho_i,\\ \frac{\ddot{a}}{a} = -\frac{4\pi G}{3}\sum_i (\rho_i + 3p_i). \end{align*}
Despite its simplifications, the solver is built on first principles with most of its governing equation accesible to master students. I have thus found the solver's merits to lie in the intuition it builds through first principles, while still producing results in impressive agreement with Planck 2018, SDSS, and Lyα observations.