abcmb.perturbations module

class abcmb.perturbations.PerturbationEvolver(species_list, species_dict, k_axis_perturbations=Array([1.00000000e-04, ..., 4.00000000e-01],      dtype=float64), specs={}, adjoint=<class 'diffrax._adjoint.ForwardMode'>)[source]

Bases: Module

Linear scalar perturbation evolution solver.

Evolves perturbations for all fluid species using Einstein-Boltzmann equations in synchronous gauge.

Attributes:

  • species_list tuple

    A list of all fluids in the cosmology

  • species_dict dict

    A dictionary containing the names of all fluids, in the same order as they appear in species_list.

  • k_axis_perturbations jnp.array

    A list of wavenumbers k at which to compute perturbations

  • specs dict

    A dictionary containing run options

  • adjoint diffrax.adjoint

    Adjoint mode for diffrax solves. Default is ForwardMode.

Methods:

  • full_evolution :

    Evolve perturbations for multiple k modes

  • evolution_one_k :

    Evolve perturbations for single k mode

  • get_tca_on_off :

    Determine tight coupling approximation times

  • initial_conditions_one_k :

    Compute initial perturbation conditions

  • get_derivatives :

    Compute perturbation time derivatives

  • make_output_table :

    Create interpolatable perturbation table

evolution_one_k(k, lna, args)[source]

Evolve perturbations for single wavenumber mode.

Integrates Einstein-Boltzmann equations from early times through recombination to late times using adaptive time stepping.

Parameters:

  • k float

    Wavenumber (units: Mpc^{-1})

  • lna array

    Logarithm of scale factor grid for output

  • args tuple

    Background cosmology and cosmological parameters (BG, params)

Returns:

diffrax.Solution

Dense solution object for interpolation

full_evolution(args)[source]

Evolve perturbations for multiple wavenumber modes.

Integrates perturbation equations for a range of k modes, then interpolates results onto common time grid.

Parameters:

  • k jnp.array

    1D axis of wavenumbers k. Perturbations are computed and stored at these values.

  • args tuple

    Background cosmology and cosmological parameters (BG, params)

Returns:

PerturbationTable

Interpolatable table of perturbation evolution

Notes:

Uses logarithmic k spacing from 10^-4 to ~0.5 Mpc^-1 with 100 points. Time integration runs from early times to z=1 (lna=-ln(2)).

get_derivatives(lna, y, args)[source]

Compute time derivatives for perturbation evolution.

Assembles the full system of Einstein-Boltzmann equations for metric and fluid perturbations in synchronous gauge.

Parameters:

  • lna float

    Logarithm of scale factor

  • y array

    Current perturbation state vector

  • args tuple

    Wavenumber k and background cosmology (k, BG, params)

Returns:

array

Time derivatives of perturbation state

get_starting_time(k, args)[source]

Determine tight coupling approximation time range.

Finds start and end times for tight coupling between photons and baryons by computing when Thomson scattering becomes ineffective relative to Hubble and horizon crossing time scales.

Parameters:

  • args tuple

    Background cosmology and cosmological parameters (BG, params)

Returns:

tuple

(lna_start, lna_end) for tight coupling period

Notes:

Uses thresholds: τc/τh < 0.0015 (start), τh/τk < 0.07 (start), τc/τh > 0.015 (end), τc/τk > 0.01 (end).

initial_conditions_one_k(k, lna_ini, args)[source]

Compute initial conditions for perturbation evolution.

Sets up initial values for metric and fluid perturbations at early times using adiabatic initial conditions.

Parameters:

  • k float

    Wavenumber (units: Mpc^{-1})

  • lna_ini float

    Initial logarithm of scale factor

  • args tuple

    Background cosmology and cosmological parameters (BG, params)

Returns:

array

Initial perturbation state vector

Notes:

Uses CLASS-style initial conditions with metric perturbations h and η. Assumes adiabatic initial conditions with vanishing isocurvature modes.

make_output_table(lna, modes, args)[source]

Create interpolatable perturbation table from evolution results.

Extracts key perturbation modes and computes derived quantities.

Parameters:

  • lna array

    Logarithm of scale factor grid

  • modes array

    Perturbation evolution results

  • args tuple

    Background cosmology and cosmological parameters (BG, params)

Returns:

PerturbationTable

Organized perturbation data for interpolation

class abcmb.perturbations.PerturbationTable(k: array, lna: array, delta_m: array, theta_b_prime: array, metric_eta: array, metric_h_prime: array, metric_eta_prime: array, metric_alpha: array, metric_alpha_prime: array, species_perturbations: dict)[source]

Bases: Module

Interpolatable table of perturbation evolution.

Stores perturbation modes as 2D arrays over wavenumber and time for efficient interpolation. Per-species perturbations in physically meaningful form are accessible via species_perturbations.

Attributes:

  • k array

    Wavenumber grid (units: Mpc^{-1})

  • lna array

    Logarithm of scale factor grid

  • delta_m array

    Total matter density perturbation, weighted sum over all matter species

  • theta_b_prime array

    Baryon velocity derivative (backward-calculated from Boltzmann equations)

  • metric_eta array

    Metric perturbation η

  • metric_h_prime array

    Time derivative of metric h

  • metric_eta_prime array

    Time derivative of metric η

  • metric_alpha array

    Derived metric perturbation α

  • metric_alpha_prime array

    Time derivative of metric α

  • species_perturbations dict

    Named perturbation arrays for each species, keyed by species name. Each value is a dict {quantity: array(Nlna, Nk)}. Species with no perturbations (e.g. dark energy) map to {}.