---
title: 'DM21cm: Inhomogeneous 21-cm Simulation'
url: https://www.emergentmind.com/topics/dm21cm
type: topic
---

# DM21cm: Inhomogeneous 21-cm Simulation

DM21cm is a public simulation framework for 21-cm cosmology that models the impact of spatially inhomogeneous, time-varying exotic energy injection into the intergalactic medium during cosmic dawn and reionization. It was introduced as a framework that combines **21cmFAST** and **DarkHistory** to account for local density dependence, local ionization and baryon density dependence, and the attenuation of propagating photons, yielding the first completely inhomogeneous treatment of exotic energy injection in the 21-cm power spectrum [2312.11608]. Later work extended the package to arbitrary continuous energy spectra with arbitrary spatial and temporal dependence, so that decays, annihilations, and primordial-black-hole scenarios could be treated within the same public code base [2509.22772].

## 1. Scientific background and antecedents

The scientific niche occupied by DM21cm emerged from a broader program in which the redshifted 21-cm signal was used as a probe of non-standard dark-sector physics. In one early example, D-photon mediated interactions between conventional matter and singlet fermions in D-foam were shown to affect baryon cooling, with observations of the hydrogen 21-cm line at redshifts \(z \ge 15\) constraining both the interaction strength and the density of D-matter [1810.05393]. In parallel, analyses of dark-matter decay used the existence of an absorption feature to place conservative, astrophysical-parameter-independent bounds on the decay rate, with limits stronger than CMB bounds in relevant regimes and competitive with indirect detection [1803.11169]. Related studies derived \(21\)-cm lifetime limits for decays to \(e^+e^-\), \(\gamma\gamma\), \(\mu^+\mu^-\), and \(b\bar b\), and also for primordial black holes, by requiring that energy injection not negate the absorption signal [1803.09390].

A complementary line of work examined annihilation rather than decay. In the Inert Doublet Model, fluctuations in the brightness temperature \(\delta T_{21}\) at the dark ages were found to be most sensitive in the dark-matter mass range \(70\)–\(80\) GeV, with derived bounds on \(\langle \sigma v \rangle\) over \(10\)–\(990\) GeV [2010.11007]. These earlier studies established the basic phenomenological principle that extra heating, ionization, excitation, or cooling can leave observable imprints in the 21-cm signal. DM21cm entered this landscape by addressing a specific limitation of many earlier treatments: the assumption that energy injection and deposition could be homogenized without materially affecting the predicted signal morphology [2312.11608].

## 2. Core architecture and scope

DM21cm is built by integrating **21cmFAST** with **DarkHistory**. In this arrangement, 21cmFAST supplies the semi-numerical structure-formation calculation, gas fields, and astrophysical source modeling, while DarkHistory computes the deposition of injected energy into heating, ionization, and Ly-\(\alpha\) excitation for arbitrary injected particle spectra [2312.11608]. The framework was designed for cosmic dawn and reionization, with the initial 2023 implementation targeting dark-matter decays to photons and to electron/positron pairs over redshifts \(z \sim 5\)–\(30\) [2312.11608].

The central physical premise is that dark-matter decay or annihilation is inherently inhomogeneous. The emission rate depends on the local density, and the deposited fraction depends on the local ionization fraction and baryon density; propagating photons also experience attenuation that depends on the intervening medium. DM21cm therefore does not merely rescale homogeneous thermal histories. It evolves three-dimensional fields in which the exotic source term is coupled to the evolving intergalactic medium, producing field-level 21-cm maps and power spectra with explicitly spatial structure [2312.11608].

This design places DM21cm in a distinct methodological category within 21-cm software. It is not primarily a global-signal code, nor only a Boltzmann-initialized semi-numerical code. Its specialization is the self-consistent propagation of exotic energy injection through a fluctuating medium, with deposition channels evaluated as local functions of the thermodynamic state [2312.11608].

## 3. Inhomogeneous injection, transport, and deposition

In the original decay implementation, the local injection rate is written as
\[
\frac{dN^\text{inj}}{dV dt}(\delta, m_\chi) = \frac{\bar{\rho}_\text{DM}(1+\delta)}{\tau m_\chi},
\]
where \(\bar{\rho}_\text{DM}\) is the mean dark-matter density, \(\delta\) is the density contrast, \(\tau\) is the lifetime, and \(m_\chi\) is the dark-matter mass [2312.11608]. For electrons, the deposited effects are encoded באמצעות transfer functions of overdensity, neutral fraction, and timestep,
\[
\begin{bmatrix}
\Delta T_k \\
\Delta x_e \\
J_\alpha
\end{bmatrix}
=
D_{ce}(\delta, x_\mathrm{HI} \mid \Delta z)\,
\frac{dN_e^\text{in}}{dE},
\]
while for photons the framework uses a lightcone construction,
\[
\frac{dN_X^\text{lightcone}}{dE}(z_i,\mathbf{x},E)
=
\sum_j
\bar{\epsilon}_X(\mathbf{x}\mid z_j, R(z_i,z_j), R(z_i,z_{j-1}))
\frac{dN_X}{dE}(z_i,E\mid z_j),
\]
so that the local deposition depends on emission history as well as spatial transport [2312.11608].

The code precomputes transfer functions \(D_{c\gamma}, D_{ce}, P_{\gamma\gamma}, T_{\gamma e}, T_{\gamma\gamma}\) from DarkHistory on a grid of redshift, overdensity, and ionization fraction [2312.11608]. Electrons and sufficiently short-lived particles are treated “on-the-spot,” while photons are separated into three regimes: instantaneously absorbed photons, locally propagating X-rays, and high-energy photons that form a homogenized bath [2312.11608]. The implementation uses redshift subcycling to balance temporal and spatial resolution and employs an efficient GPU/JAX strategy for handling deposition histories and photon baths [2312.11608].

The 2025 extension generalized the injection layer itself. Instead of assuming only narrow or simple injected spectra, DM21cm now accepts
\[
\frac{dN_{\gamma/e}}{dE\, dV\, dt}(z,\mathbf{x})
=
\frac{dN_{\text{inj}}}{dV dt}(z,\mathbf{x})
\times
\frac{dN_{\gamma/e}}{dE}(z),
\]
with \(dN_{\text{inj}}/dVdt\) allowed to depend on local properties and \(dN_{\gamma/e}/dE\) allowed to be a continuum and time-dependent spectrum [2509.22772]. Deposition is then propagated through transfer functions for outgoing photons and for gas response,
\[
\frac{dN_\gamma^{\text{out}}}{dE}
=
T_{\gamma e/\gamma}(\delta, x_{\mathrm{HI}}\mid z,\Delta z)
\frac{dN_{e/\gamma}^{\text{in}}}{dE},
\qquad
\begin{bmatrix}
\Delta T_k \\
\Delta x_e \\
J_\alpha
\end{bmatrix}
=
D_{c e/\gamma}(\delta, x_{\mathrm{HI}}\mid z,\Delta z)
\frac{dN_{e/\gamma}^{\text{in}}}{dE}.
\]
This formulation made it possible to model processes whose emissivity is intrinsically structure-aware, such as \(p\)-wave annihilation and PBH accretion [2509.22772].

## 4. Signal morphology and inference

The principal phenomenological result of DM21cm is that inhomogeneous injection produces field-level and power-spectrum signatures not present in homogenized models. For decays to electrons, which deposit energy nearly “on-the-spot,” the inhomogeneous treatment sharply enhances spatial fluctuations. For decays to photons, the effect is softer because the photon mean free path allows partial spatial averaging, although the local gas state still matters [2312.11608]. These features appear in both simulated 21-cm maps and the frequency-resolved 21-cm power spectrum.

The original forecast study used **21cmfish** together with realistic HERA sensitivity, foregrounds, and marginalized astrophysical uncertainties. It found that projected HERA constraints on decays to photons outperform Lyman-\(\alpha\) and CMB bounds for all considered masses and exceed X-ray line search constraints for \(m_\chi \lesssim 1\,\mathrm{keV}\), while for decays to electrons the 21-cm constraints surpass Ly-\(\alpha\) and CMB limits over all mass ranges and become the leading bounds for sub-GeV dark matter, reaching lifetimes of \(\sim 10^{28}\,\mathrm{s}\) [2312.11608]. The forecast statistic was written as
\[
\Delta \chi^2
=
\sum_{z,k}
\frac{\big[P_{21}^{\text{signal}}(z,k)-P_{21}^{\text{fid}}(z,k)\big]^2}
{\sigma_{P_{21}}^2(z,k)}.
\]

A common misunderstanding is that the main purpose of the inhomogeneous treatment is simply to tighten exclusion limits. The 2023 analysis states that the improved treatment does **not dramatically alter the absolute reach** compared to homogenized approaches, with differences at most \(\sim 10\%\). Its stronger claim is different: field-level predictions and the small-scale structure of the 21-cm power spectrum are qualitatively different, which matters for signal discrimination, model interpretation, and any future detection claim [2312.11608].

## 5. Extension to continuum spectra, annihilation, and primordial black holes

The 2025 upgrade broadened DM21cm from a decay-focused framework to a generic engine for spatially inhomogeneous energy injection with arbitrary spectra and arbitrary spatial and temporal dependence [2509.22772]. Three benchmark applications were emphasized: \(p\)-wave dark-matter annihilation, Hawking radiation from light primordial black holes, and energetic emission from accreting solar-mass primordial black holes. In all three cases, the morphology of the 21-cm response is jointly set by the time dependence of emission, the spatial dependence of the source, and the local-state dependence of absorption and deposition [2509.22772].

For \(p\)-wave annihilation, the luminosity is structure-tracing and velocity-sensitive, so the relevant emissivity peaks later than in \(s\)-wave scenarios and is well matched to the cosmic-dawn sensitivity of 21-cm measurements [2509.22772]. For Hawking radiation, HERA was projected to set the strongest constraints on PBHs with masses \(M_{\mathrm{PBH}} \sim 10^{14}\)–\(10^{14.5}\) g, with abundance down to \(f_{\mathrm{PBH}} \lesssim 10^{-8}\) [2509.22772]. For PBH accretion, the projected reach depends strongly on the accretion model and environmental assumptions, which motivated the addition of arbitrary continuum spectra and explicit coupling to local halo environments [2509.22772].

These extensions preserved the code’s original emphasis on feedback. Heating and ionization generated by exotic sources modify later absorption efficiencies, so the source term and the medium cannot be cleanly factorized. This suggests that DM21cm is best understood not as a library of static deposition kernels, but as a feedback-coupled semi-numerical framework for exotic radiative transfer in 21-cm cosmology [2509.22772].

## 6. Derived applications, ecosystem, and limitations

DM21cm has also been used as a simulation backend for downstream inference strategies. A 2025 SKA-Low study employed DM21cm-generated three-dimensional \(\delta T_b\) maps to train convolutional neural networks to distinguish spatially homogeneous from inhomogeneous dark-matter annihilation scenarios. For the \(e^+e^-\) channel, the inhomogeneous models remained distinguishable from homogeneous scenarios for \(m_{\rm DM}=1\) MeV and annihilation cross-sections \(\geq 5 \times 10^{-30}\,{\rm cm^3/sec}\), and for \(m_{\rm DM}=100\) MeV at \(\geq 5 \times 10^{-29}\,{\rm cm^3/sec}\), under moderate SKA-Low noise. For the \(\gamma\gamma\) channel, discrimination was weaker because the larger mean free path produces more uniform deposition [2508.08251].

Within the broader 21-cm software ecosystem, DM21cm is complementary to other public tools. **21cmFirstCLASS** was designed to start from recombination, evolve the signal through the dark ages, and correct the \(\delta_b=\delta_c\) and homogeneous-\(z=35\)-initialization approximations of standard 21cmFAST, reaching sub-percent agreement with CAMB at \(z \le 50\) on relevant scales [2309.03948; 2309.03942]. **Beyond21** is a fully open-source Python package for the global 21-cm signal, UV luminosity functions, ionization history, and the cosmic X-ray background, with a modular example implementation of millicharged dark matter [2603.04542]. A plausible implication is that DM21cm occupies the subdomain where three-dimensional, inhomogeneous exotic energy deposition is the dominant modeling challenge, whereas 21cmFirstCLASS emphasizes Boltzmann-consistent initial conditions and Beyond21 emphasizes rapid global evolution and source-population flexibility.

The current limitations of DM21cm are explicitly identified in the literature. The transfer-function interpolation grid is limited by GPU memory, producing interpolation errors at the few-percent level; photon propagation below \(10.2\) eV is not modeled; the code does not yet include DM annihilation in halos or scenarios requiring more subgrid structure; and the astrophysical modeling can be refined further as 21cmFAST and DarkHistory evolve [2312.11608]. Those constraints are methodological rather than conceptual. The framework’s core contribution is the demonstration that a fully inhomogeneous treatment of exotic energy injection is both computationally tractable and scientifically consequential for 21-cm cosmology [2312.11608].

Source: https://www.emergentmind.com/topics/dm21cm