Skip to main content

DISCO-EB logo

DISCO-EB

tests coverage lint types PyPI Downloads Python JAX arXiv Conventional Commits License: MIT

Installation • Quickstart • Documentation • Paper • Citation

DISCO-EB is a differentiable linear Einstein-Boltzmann solver for cosmology, and the Einstein-Boltzmann module of the DISCO-DJ framework (DIfferentiable Simulations for COsmology, Done with Jax). It evolves the background, the recombination history and the linear perturbations of every wave mode of a batch of cosmologies in one GPU launch.

The solve runs as a modax Rodas5P kernel. RECFAST and the optical depth step alongside the perturbation hierarchy in the same kernel, so the solve needs no tables. You choose which quantities to keep at which times, and the kernel evaluates them as it goes. The results are JAX arrays, differentiable in the cosmological parameters by forward sensitivities. DISCO-EB supports flat or curved ΛCDM, a CPL dark-energy fluid $(w_0, w_a)$, massive neutrinos and reionization.

The documentation covers the API and how to use it. The paper describes the method and its accuracy against CLASS.

Installation

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

You need a GPU to run a solve, but not to import the package. modax brings the CUDA compiler stack with it. The CMB spectra live in a separate package, DISCO-CMB, which builds on this one.

Quickstart

A cosmology is an instance of a model, with the model's parameters as keyword arguments. This example keeps the comoving curvature perturbation $\mathcal{R}$ and the CDM density contrast of flat LCDM, for 64 wave modes at 100 scale factors:

import numpy as np
from discoeb import LCDM, solve_eb

planck = LCDM.from_density_parameters(
    Omega_m=0.3142, Omega_b=0.0494, 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,
)
k = np.geomspace(1e-4, 1.0, 64)      # 1/Mpc
a = np.geomspace(1e-6, 1.0, 100)     # scale factors, the last one today

values = solve_eb([planck, planck.replace(omega_c=0.125)], k, a, keep=("R", "delta_c"))
R = values[:, 0]  # (2, 64, 100): cosmologies, wave modes, scale factors

A model's own parameters are physical densities, omega_b, omega_c and omega_de ($\omega = \Omega h^2$), and planck.H_0 is what they sum to. from_density_parameters takes $\Omega_m$, $\Omega_b$ and $H_0$ and finds the dark-energy density that closes the budget. The solve integrates in the scale factor, so nothing runs before it and every cosmology ends at a = 1. Keep tau for the conformal time.

discoeb.models has LCDM, W0WACDM (a CPL dark-energy fluid) and their massive-neutrino variants LCDM_MNU and W0WACDM_MNU. Each takes exactly its own parameters, so a type checker flags a missing or unknown one. The notebook examples/flat_lcdm_power_spectrum.ipynb computes and times the matter power spectrum of 128 flat LCDM cosmologies about Planck 2018 in one jitted function.

Development

The repository uses uv:

git clone https://github.com/cosmo-sims/DISCO-EB.git && cd DISCO-EB
uv sync --extra cuda13  # or --extra cuda12

uv run pytest tests -rs   # needs a GPU, and -rs shows skipped CLASS comparisons
uv run pytest tests -m "not gpu" -n auto   # the host tests, on every core
uv run ruff format && uv run ruff check --fix
uv run ty check
uv run pre-commit install   # the checks above, and a commit-message check

The documentation (Sphinx with MyST and autodoc) builds in an environment of its own, the package's CPU install plus the docs group:

export UV_PROJECT_ENVIRONMENT=.venv-docs
uv sync --no-default-groups --group docs
uv run --no-sync sphinx-autobuild docs docs/_build/html   # live preview
uv run --no-sync sphinx-build -W docs docs/_build/html    # what CI runs

Citation

If you use DISCO-EB in your research, please cite the JCAP article:

@article{DISCO-EB:2024,
    author = "Hahn, Oliver and List, Florian and Porqueres, Natalia",
    title = "{DISCO-DJ I: a differentiable Einstein-Boltzmann solver for cosmology}",
    eprint = "2311.03291",
    archivePrefix = "arXiv",
    primaryClass = "astro-ph.CO",
    doi = "10.1088/1475-7516/2024/06/063",
    journal = "JCAP",
    volume = "06",
    pages = "063",
    year = "2024"
}

License

DISCO-EB uses the MIT License. The recombination module adapts code from Recfast, whose UBC license its file header reproduces.

Metadata

Release files for disco-eb 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for disco-eb 2.1.0
File Size Uploaded Provenance Actions
disco_eb-2.1.0.tar.gz 110.2 kB With provenance Details for disco_eb-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for disco-eb 2.1.0
File Interpreter ABI Platform Actions
disco_eb-2.1.0-py3-none-any.whl Python 3 none any Details for disco_eb-2.1.0-py3-none-any.whl

Total release size: 187.2 kB

Release files / disco_eb-2.1.0.tar.gz

Download URL disco_eb-2.1.0.tar.gz
Size 110.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f55de2e061cbb093b34addb275c817589773da1d35e373a67b6818f9ec31434f
BLAKE2b-256 checksum
How to use checksums
eec3f59421ad7eb89a44dd638c5710a1272536483b9fda2fe7aa06dd3a83093f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / disco_eb-2.1.0-py3-none-any.whl

Download URL disco_eb-2.1.0-py3-none-any.whl
Size 77.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9dd6d33a4f4d42749e58cf87e0cca60b57920572fabdf22e0ecae1759a3763ee
BLAKE2b-256 checksum
How to use checksums
b56e339db83488a3112016d85174f83b7fdb28a44b3beb8641a25944fbd897d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for disco-eb 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for disco_eb-2.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page