21cm IGM Evolution Example¶
This example demonstrates Monte Carlo uncertainty quantification for the global 21cm signal using a massively batched, uncoupled ODE solve. It draws uncertain astrophysical parameters for the first galaxies, evolves many independent IGM thermal histories, and plots the median plus 95% prior envelope of the sky-averaged brightness temperature.
Run it with:
The modax solve runs as a Numba-CUDA kernel, so this needs a CUDA GPU.
The scipy backend below is the CPU-only path.
The default run uses 50,000 trajectories. Tests use a much smaller batch.
Solver-backend benchmark¶
The batched ensemble solve can be timed across solver backends on identical
right-hand-side code with the --benchmark flag: modax Rodas5P (GPU), Diffrax
Kvaerno5 (GPU), and serial scipy.solve_ivp LSODA (the no-GPU baseline used by
codes such as ECHO21).
# head-to-head at N=2000 (scipy is the slow one)
uv run python examples/21cm_igm_evolution/main.py --benchmark --n 2000
# GPU backends at the full default ensemble size
uv run python examples/21cm_igm_evolution/main.py --benchmark --backends modax diffrax --n 50000
Model¶
The integration variable is
so redshift decreases monotonically from \(z=100\) to \(z=5\). The solver state is
where \(T_k\) is the gas kinetic temperature, \(x_e\) is the residual electron fraction in the bulk IGM, and \(Q\) is a volume-filling ionized fraction. The log/logit state keeps the evolved quantities in physical ranges.
Writing the dynamics in cosmic time \(t\), to which the integration variable is related by \(\mathrm{d}u = H\,\mathrm{d}t\), the three physical quantities obey
The thermal equation combines adiabatic cooling \(-2H\,T_k\), Compton coupling to the CMB at temperature \(T_\gamma = T_{\gamma,0}(1+z)\), X-ray heating, and a smaller Ly-alpha heating term. The free-electron equation balances case-B recombination against X-ray ionization, and the filling-fraction equation balances an ionizing emissivity against recombinations.
The astrophysical parameter dependence enters through a smooth star-formation history surrogate
where \(\sigma\) is the logistic function. The rate coefficients follow standard global-signal scalings, calibrated here for the surrogate (cgs units):
For numerical conditioning the solver advances \(\log T_k\) together with the logits of \(x_e\) and \(Q\) -- keeping the temperature positive and the two fractions within \([0, 1]\) -- and rescales each right-hand side by \(1/H\) to integrate against \(u\) rather than \(t\).
This is a calibrated surrogate for a batching demonstration, not a precision global-signal code.
Uncertain Parameters¶
Each trajectory samples
| Parameter | Prior |
|---|---|
| \(\log_{10} f_\star\) | Uniform \([-3, -0.5]\) |
| \(\log_{10} f_X\) | Uniform \([-2, 2]\) |
| \(\log_{10} T_\mathrm{vir}\) | Uniform \([3.5, 5.5]\) |
The analytic source history is a smooth stand-in for the star-formation rate density. Larger \(f_\star\) increases the Ly-alpha, X-ray, and ionizing emissivities. Larger \(T_\mathrm{vir}\) delays source turn-on because only rarer, more massive haloes can form stars.
Spin Temperature and Brightness¶
The spin temperature is derived algebraically using the Field equilibrium form, with collisional coupling and Ly-alpha Wouthuysen-Field coupling:
The global brightness temperature follows the usual mean-density approximation:
Observed frequency is
References¶
- S. Mittal, T. A. Voytek, G. Kulkarni, ECHO21: a tool for modelling global 21-cm signal from dark ages to reionization, arXiv:2503.11762; RASTI 5 (2026) rzag001. https://arxiv.org/abs/2503.11762
- ECHO21 code: https://github.com/shikharmittal04/echo21
- S. Furlanetto, S. P. Oh, F. Briggs, Cosmology at low frequencies: The 21 cm transition and the high-redshift Universe, Physics Reports 433, 181-301 (2006).
- J. Pritchard, A. Loeb, 21 cm cosmology in the 21st century, Reports on Progress in Physics 75, 086901 (2012).
- S. Wouthuysen, On the excitation mechanism of the 21-cm radio-frequency interstellar hydrogen emission line, AJ 57, 31 (1952).
- G. Field, Excitation of the hydrogen 21-cm line, Proceedings of the IRE 46, 240 (1958).