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:
ModuleLinear scalar perturbation evolution solver.
Evolves perturbations for all fluid species using Einstein-Boltzmann equations in synchronous gauge.
Attributes:
species_listtupleA list of all fluids in the cosmology
species_dictdictA dictionary containing the names of all fluids, in the same order as they appear in species_list.
k_axis_perturbationsjnp.arrayA list of wavenumbers k at which to compute perturbations
specsdictA dictionary containing run options
adjointdiffrax.adjointAdjoint 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:
kfloatWavenumber (units: Mpc^{-1})
lnaarrayLogarithm of scale factor grid for output
argstupleBackground 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:
kjnp.array1D axis of wavenumbers k. Perturbations are computed and stored at these values.
argstupleBackground 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:
lnafloatLogarithm of scale factor
yarrayCurrent perturbation state vector
argstupleWavenumber 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:
argstupleBackground 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:
kfloatWavenumber (units: Mpc^{-1})
lna_inifloatInitial logarithm of scale factor
argstupleBackground 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:
lnaarrayLogarithm of scale factor grid
modesarrayPerturbation evolution results
argstupleBackground 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:
ModuleInterpolatable 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:
karrayWavenumber grid (units: Mpc^{-1})
lnaarrayLogarithm of scale factor grid
delta_marrayTotal matter density perturbation, weighted sum over all matter species
theta_b_primearrayBaryon velocity derivative (backward-calculated from Boltzmann equations)
metric_etaarrayMetric perturbation η
metric_h_primearrayTime derivative of metric h
metric_eta_primearrayTime derivative of metric η
metric_alphaarrayDerived metric perturbation α
metric_alpha_primearrayTime derivative of metric α
species_perturbationsdictNamed 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 {}.