Quickstart#

DISCO-CMB computes CMB angular power spectra for batches of cosmologies on the GPU. It builds on the Einstein-Boltzmann solver of DISCO-EB and adds line-of-sight integration, the unlensed TT, TE and EE spectra, the lensing potential and the lensed TT, TE, EE and BB spectra.

A single GPU launch evolves every wave mode of every cosmology in a batch, with the line-of-sight sources evaluated inside the solver’s kernel. The unlensed TT spectrum agrees with CLASS to 0.25 percent for multipoles 2 to 1200, and JAX can differentiate the spectra with respect to the cosmological parameters.

Installation#

DISCO-CMB needs an NVIDIA GPU. Install it from PyPI, which also installs DISCO-EB:

pip install "disco-cmb[cuda13]"   # or [cuda12], which Python 3.10 needs

Your first spectra#

This example computes the spectra of three flat LCDM cosmologies that differ in their spectral index. A cosmology is an instance of a DISCO-EB model, and a batch of cosmologies is a list of such instances. Grid holds the wave modes, save times and multipoles, shaped by a fiducial cosmology, with the tables the projection needs. solve_cmb computes the unlensed spectra of a batch on it:

from discoeb import LCDM
from discocmb import Grid, solve_cmb

planck = LCDM.from_density_parameters(
    Omega_m=0.3144,
    Omega_b=0.04939,
    H_0=67.32,
    A_s=2.1e-9,
    n_s=0.966,
    T_cmb=2.7255,
    Y_He=0.2454,
    N_eff=3.046,
)
batch = [planck.replace(n_s=n_s) for n_s in (0.95, 0.966, 0.98)]

grid = Grid.from_fiducial(planck)
ells, cl, dl = solve_cmb(batch, grid=grid)
dl.tt  # (3, 3401) in muK^2, from l = 0

cl and dl are Spectra with the tt, te, ee and lensing potential pp spectra, each of shape (n_cosmologies, lmax + 1) from \(\ell = 0\). cl is dimensionless and dl is \(\ell(\ell+1)C_\ell/2\pi\) in \(\mu\mathrm{K}^2\). lensed_spectra(cl, grid) lenses them.

Where to go next?#

Computing a batch of spectra

The three steps, solve_cmb and the grid.

Computing a batch of spectra
Comparison with CLASS

The unlensed, lensed and lensing potential spectra against CLASS.

Comparison with CLASS