abcmb.species module
- class abcmb.species.BackgroundFluid(first_idx, specs)[source]
Bases:
Fluid- rho_delta(lna, y, args)[source]
Compute density perturbation.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Density perturbation (units: eV cm^{-3})
- rho_plus_P_sigma(lna, y, args)[source]
Compute shear perturbation.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Shear perturbation (units: eV cm^{-3})
- class abcmb.species.Baryon(first_idx, specs)[source]
Bases:
StandardFluidBaryon fluid species implementation.
Non-relativistic baryons with density and velocity perturbations.
Required input parameters: params[‘omega_b’], params[‘YHe’]
Required derived parameters: params[‘R_nu’], params[‘R_b’], params[‘om’]
Methods:
rho:Compute baryon density (units: eV cm^{-3})
P:Compute baryon pressure (units: eV cm^{-3})
cs2:Compute sound speed squared (units: dimensionless)
mean_mass:Compute mean baryon mass (units: eV)
y_ini:Compute initial perturbation conditions
y_prime:Compute perturbation time derivatives
- P(lna, args)[source]
Compute baryon pressure.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Baryon pressure (units: eV cm^{-3})
Notes:
Baryon pressure is neglected, standard practice for SM baryons.
- cs2(lna, args)[source]
Compute sound speed squared.
Parameters:
lnafloatLogarithm of scale factor
argstupleBackground cosmology and cosmological parameters (BG, params)
Returns:
- float
Sound speed squared (units: dimensionless)
Notes:
Adiabatic sound speed squared, taken from M&B Eq. (68). Although we can neglect the pressure, this term is important for perturbation growth during recombination. During reionization this cs2 is negative. This is not physical but it should not matter for cosmology.
- mean_mass(lna, args)[source]
Compute mean baryon mass at given redshift.
Parameters:
lnafloatLogarithm of scale factor
argstupleBackground cosmology and cosmological parameters (BG, params)
Returns:
- float
Mean baryon mass (units: eV)
Notes:
Defined to be mu = rho_b / n_b = rho_b / (nH + nHe + ne)
- output_perturbations(lna, modes, args)[source]
Return named perturbation arrays for storage in PerturbationTable.
Each concrete species overrides this to select the physically meaningful subset of its modes. Species with no perturbations (e.g. dark energy) return an empty dict via this base implementation.
Parameters:
lnaarray, shape (Nlna,)Logarithm of scale factor grid
modesarray, shape (Ny, Nlna, Nk)Full perturbation state, already transposed
argstuple(BG, params) — background cosmology and cosmological parameters
Returns:
- dict
{quantity_name: array(Nlna, Nk)}. Empty for background-only species.
- rho(lna, args)[source]
Compute baryon density.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Baryon density (units: eV cm^{-3})
- y_ini(k, tau_ini, args)[source]
Compute initial conditions for baryon perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
tau_inifloatInitial conformal time (units: Mpc)
argsdictCosmological parameters (params)
Returns:
- array
Initial perturbation mode values (units: 1/Mpc for theta, else dimensionless)
- y_prime(k, lna, metric_h_prime, metric_eta_prime, y, args)[source]
Compute time derivatives of baryon perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
lnafloatLogarithm of scale factor
metric_h_primefloatDerivative of metric h
metric_eta_primefloatDerivative of metric eta
yarrayCurrent perturbation mode values
argstupleBackground cosmology and cosmological parameters (BG, params)
Returns:
- array
Time derivatives of perturbation modes (units: 1/Mpc for theta, else dimensionless)
- class abcmb.species.ColdDarkMatter(first_idx, specs)[source]
Bases:
StandardFluidCold dark matter fluid species implementation.
Non-relativistic, pressureless dark matter with density perturbations but no velocity or shear modes.
Required input parameters: params[‘omega_cdm’].
Required derived parameters: params[‘om’].
Methods:
rho:Compute cold dark matter density (units: eV cm^{-3})
P:Compute cold dark matter pressure (units: eV cm^{-3})
y_ini:Compute initial perturbation conditions
y_prime:Compute perturbation time derivatives
- P(lna, args)[source]
Compute cold dark matter pressure.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Cold dark matter pressure (units: eV cm^{-3})
Notes:
Cold dark matter is pressureless, so this always returns zero.
- output_perturbations(lna, modes, args)[source]
Return named perturbation arrays for storage in PerturbationTable.
Each concrete species overrides this to select the physically meaningful subset of its modes. Species with no perturbations (e.g. dark energy) return an empty dict via this base implementation.
Parameters:
lnaarray, shape (Nlna,)Logarithm of scale factor grid
modesarray, shape (Ny, Nlna, Nk)Full perturbation state, already transposed
argstuple(BG, params) — background cosmology and cosmological parameters
Returns:
- dict
{quantity_name: array(Nlna, Nk)}. Empty for background-only species.
- rho(lna, args)[source]
Compute cold dark matter density.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Cold dark matter density (units: eV cm^{-3})
- y_ini(k, tau_ini, args)[source]
Compute initial conditions for cold dark matter perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
tau_inifloatInitial conformal time (units: Mpc)
argsdictCosmological parameters (params)
Returns:
- array
Initial density perturbation (units: dimensionless)
- y_prime(k, lna, metric_h_prime, metric_eta_prime, y, args)[source]
Compute time derivatives of cold dark matter perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
lnafloatLogarithm of scale factor
metric_h_primefloatDerivative of metric h
metric_eta_primefloatDerivative of metric eta
yarrayCurrent perturbation mode values
argstupleBackground cosmology and cosmological parameters (BG, params) - Note: BG parameter is unused in this implementation
Returns:
- array
Time derivative of density perturbation (units: dimensionless)
- class abcmb.species.DarkEnergy(first_idx, specs)[source]
Bases:
BackgroundFluidDark energy fluid species implementation.
Represents a constant energy density fluid with negative pressure.
Required input parameters: None.
Required derived parameters: params[‘omega_Lambda’]
Methods:
rho:Compute dark energy density (units: eV cm^{-3})
P:Compute dark energy pressure (units: eV cm^{-3})
- class abcmb.species.Fluid(first_idx, specs)[source]
Bases:
ModuleBase class for fluid species.
Defines fluid properties.
Fields:
first_idxintDefault = 0 Position of the first perturbation equation in the Diffrax vector. For most fluids this is the density perturbation mode “delta”.
num_equationsintDefault = 0 Number of equations that need to be simultaneously evolved in the perturbations module.
namestrDefault = “” Name of the fluid, used to find fluid and refer to it later in the computation using species_dict[“name”].
is_matterboolDefault = False Whether the fluid is non-relativistic today and contributes towards the total matter power spectrum.
Methods:
rho:Compute energy density (units: eV cm^{-3})
P:Compute pressure (units: eV cm^{-3})
w:Compute equation of state parameter (units: dimensionless)
y_ini:Adiabatic initial conditions, in synchronous gauge
y_prime:Perturbation derivatives, in synchronous gauge
rho_delta:Perturbed density function δρ (units: eV cm^{-3})
rho_plus_P_theta:Velocity perturbation (units: eV cm^{-3} Mpc^{-1})
rho_plus_P_sigma:Compute standard shear perturbation (units: eV cm^{-3})
- P(lna, args)[source]
Compute pressure.
Calculates the pressure of the fluid species at a given cosmological epoch using the logarithm of the scale factor.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Pressure (units: eV cm^{-3})
- output_perturbations(lna, modes, args)[source]
Return named perturbation arrays for storage in PerturbationTable.
Each concrete species overrides this to select the physically meaningful subset of its modes. Species with no perturbations (e.g. dark energy) return an empty dict via this base implementation.
Parameters:
lnaarray, shape (Nlna,)Logarithm of scale factor grid
modesarray, shape (Ny, Nlna, Nk)Full perturbation state, already transposed
argstuple(BG, params) — background cosmology and cosmological parameters
Returns:
- dict
{quantity_name: array(Nlna, Nk)}. Empty for background-only species.
- rho(lna, args)[source]
Compute energy density.
Calculates the energy density of the fluid species at a given cosmological epoch using the logarithm of the scale factor.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Energy density (units: eV cm^{-3})
- rho_delta(lna, y, args)[source]
Compute density perturbation.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Density perturbation (units: eV cm^{-3})
- rho_plus_P_sigma(lna, y, args)[source]
Compute shear perturbation.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Shear perturbation (units: eV cm^{-3})
- rho_plus_P_theta(lna, y, args)[source]
Compute velocity perturbation.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Velocity perturbation (units: eV cm^{-3} Mpc^{-1})
- w(lna, args)[source]
Compute equation of state parameter.
Calculates the ratio of pressure to energy density, representing the equation of state for the fluid species.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Equation of state parameter (units: dimensionless)
- y_ini(k, tau_ini, args)[source]
Compute initial conditions for perturbation modes.
Calculates the initial state of perturbation modes at early cosmological times.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
tau_inifloatInitial conformal time (units: Mpc)
argsdictCosmological parameters (params)
Returns:
- array
Initial perturbation mode values
- y_prime(k, lna, metric_h_prime, metric_eta_prime, y, args)[source]
Compute time derivatives of perturbation modes.
Calculates how perturbation modes evolve with cosmological time.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
lnafloatLogarithm of scale factor
metric_h_primefloatDerivative of metric h
metric_eta_primefloatDerivative of metric eta
yarrayCurrent perturbation mode values
argstupleBackground cosmology and cosmological parameters (BG, params)
Returns:
- array
Time derivatives of perturbation modes
- class abcmb.species.MassiveNeutrino(first_idx, specs)[source]
Bases:
FluidMassive neutrinos fluid species implementation.
Non-relativistic neutrinos with multiple angular momentum modes.
Required input parameters: params[‘N_nu_massive’], params[‘T_nu_massive’], params[‘m_nu_massive’], params[‘TCMB0’]
Required derived parameters: params[‘R_nu’], params[‘om’]
Attributes:
num_ells_per_binintNumber of multipole moments per momentum bin for massive neutrino hierarchy
Methods:
rho:Compute massive neutrino density (units: eV cm^{-3})
P:Compute massive neutrino pressure (units: eV cm^{-3})
y_ini:Compute initial perturbation conditions
y_prime:Compute perturbation time derivatives
rho_delta:Compute density perturbation (units: eV cm^{-3})
rho_plus_P_theta:Compute velocity perturbation (units: eV cm^{-3} Mpc^{-1})
rho_plus_P_sigma:Compute shear perturbation (units: eV cm^{-3})
- P(lna, args)[source]
Compute massive neutrino pressure.
Parameters:
lnafloat or ArrayLikeLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float or ArrayLike
Massive neutrino pressure (units: eV cm^{-3})
- output_perturbations(lna, modes, args)[source]
Return named perturbation arrays for storage in PerturbationTable.
Each concrete species overrides this to select the physically meaningful subset of its modes. Species with no perturbations (e.g. dark energy) return an empty dict via this base implementation.
Parameters:
lnaarray, shape (Nlna,)Logarithm of scale factor grid
modesarray, shape (Ny, Nlna, Nk)Full perturbation state, already transposed
argstuple(BG, params) — background cosmology and cosmological parameters
Returns:
- dict
{quantity_name: array(Nlna, Nk)}. Empty for background-only species.
- rho(lna, args)[source]
Compute massive neutrino density.
Parameters:
lnafloat or ArrayLikeLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float or ArrayLike
Massive neutrino density (units: eV cm^{-3})
- rho_delta(lna, y, args)[source]
Compute massive neutrino density perturbation.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Density perturbation (units: eV cm^{-3})
- rho_plus_P_sigma(lna, y, args)[source]
Compute massive neutrino shear perturbation.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Shear perturbation (units: eV cm^{-3})
- rho_plus_P_theta(lna, y, args)[source]
Compute massive neutrino velocity perturbation.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Velocity perturbation (units: eV cm^{-3} Mpc^{-1})
- y_ini(k, tau_ini, args)[source]
Compute initial conditions for massive neutrino perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
tau_inifloatInitial conformal time (units: Mpc)
argsdictCosmological parameters (params)
Returns:
- array
Initial perturbation mode values (units: 1/Mpc for kPsi1, else dimensionless)
- y_prime(k, lna, metric_h_prime, metric_eta_prime, y, args)[source]
Compute time derivatives of massive neutrino perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
lnafloatLogarithm of scale factor
metric_h_primefloatDerivative of metric h
metric_eta_primefloatDerivative of metric eta
yarrayCurrent perturbation mode values
argstupleBackground cosmology and cosmological parameters (BG, params)
Returns:
- array
Time derivatives of perturbation modes (units: 1/Mpc for kPsi1, else dimensionless)
- class abcmb.species.MasslessNeutrino(first_idx, specs)[source]
Bases:
StandardFluidMassless neutrinos fluid species implementation.
Represents relativistic neutrinos with multiple angular momentum modes.
Required input parameters: params[‘N_nu_massless’], params[‘T_nu_massless’], params[‘TCMB0’]
Required derived parameters: params[‘R_nu’], params[‘om’]
Methods:
rho:Compute neutrino density (units: eV cm^{-3})
P:Compute neutrino pressure (units: eV cm^{-3})
- P(lna, args)[source]
Compute neutrino pressure.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Neutrino pressure (units: eV cm^{-3})
- output_perturbations(lna, modes, args)[source]
Return named perturbation arrays for storage in PerturbationTable.
Each concrete species overrides this to select the physically meaningful subset of its modes. Species with no perturbations (e.g. dark energy) return an empty dict via this base implementation.
Parameters:
lnaarray, shape (Nlna,)Logarithm of scale factor grid
modesarray, shape (Ny, Nlna, Nk)Full perturbation state, already transposed
argstuple(BG, params) — background cosmology and cosmological parameters
Returns:
- dict
{quantity_name: array(Nlna, Nk)}. Empty for background-only species.
- rho(lna, args)[source]
Compute neutrino density.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Neutrino density (units: eV cm^{-3})
- y_ini(k, tau_ini, args)[source]
Compute initial conditions for massless neutrino perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
tau_inifloatInitial conformal time (units: Mpc)
argsdictCosmological parameters (params)
Returns:
- array
Initial perturbation mode values (units: 1/Mpc for theta, else dimensionless)
- y_prime(k, lna, metric_h_prime, metric_eta_prime, y, args)[source]
Compute time derivatives of massless neutrino perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
lnafloatLogarithm of scale factor
metric_h_primefloatDerivative of metric h
metric_eta_primefloatDerivative of metric eta
yarrayCurrent perturbation mode values
argstupleBackground cosmology and cosmological parameters (BG, params)
Returns:
- array
Time derivatives of perturbation modes (units: 1/Mpc for theta, else dimensionless)
- class abcmb.species.Photon(first_idx, specs)[source]
Bases:
StandardFluidPhoton fluid species implementation.
Relativistic photons with temperature and polarization Boltzmann hierarchies.
Required input parameters: params[‘TCMB0’]
Required derived parameters: params[‘R_nu’], params[‘R_nu’], params[‘om’]
Attributes:
num_F_ell_modesintNumber of temperature multipole moments in Boltzmann hierarchy
num_G_ell_modesintNumber of polarization multipole moments in Boltzmann hierarchy
Methods:
rho:Compute photon density (units: eV cm^{-3})
P:Compute photon pressure (units: eV cm^{-3})
y_ini:Compute initial perturbation conditions
y_prime:Compute perturbation time derivatives
- P(lna, args)[source]
Compute photon pressure.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Photon pressure (units: eV cm^{-3})
- output_perturbations(lna, modes, args)[source]
Return named perturbation arrays for storage in PerturbationTable.
Each concrete species overrides this to select the physically meaningful subset of its modes. Species with no perturbations (e.g. dark energy) return an empty dict via this base implementation.
Parameters:
lnaarray, shape (Nlna,)Logarithm of scale factor grid
modesarray, shape (Ny, Nlna, Nk)Full perturbation state, already transposed
argstuple(BG, params) — background cosmology and cosmological parameters
Returns:
- dict
{quantity_name: array(Nlna, Nk)}. Empty for background-only species.
- rho(lna, args)[source]
Compute photon density.
Parameters:
lnafloatLogarithm of scale factor
argsdictCosmological parameters (params)
Returns:
- float
Photon density (units: eV cm^{-3})
- y_ini(k, tau_ini, args)[source]
Compute initial conditions for photon perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
tau_inifloatInitial conformal time (units: Mpc)
argsdictCosmological parameters (params)
Returns:
- array
Initial perturbation mode values (units: 1/Mpc for theta, else dimensionless)
- y_prime(k, lna, metric_h_prime, metric_eta_prime, y, args)[source]
Compute time derivatives of photon perturbations.
Parameters:
kfloatWavenumber (units: Mpc^{-1})
lnafloatLogarithm of scale factor
metric_h_primefloatDerivative of metric h
metric_eta_primefloatDerivative of metric eta
yarrayCurrent perturbation mode values
argstupleBackground cosmology and cosmological parameters (BG, params)
Returns:
- array
Time derivatives of perturbation modes (units: 1/Mpc for theta, else dimensionless)
- class abcmb.species.StandardFluid(first_idx, specs)[source]
Bases:
FluidStandard implementation of perturbation methods for fluid species.
Provides default computations for perturbation-related methods used in this code.
Methods:
rho_delta:Compute standard density perturbation (units: eV cm^{-3})
rho_plus_P_theta:Compute standard velocity perturbation (units: eV cm^{-3} Mpc^{-1})
rho_plus_P_sigma:Compute standard shear perturbation (units: eV cm^{-3})
- get_delta(lna, y, args)[source]
Getter method for density perturbation from perturbation equations vector
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Dimensionless density perturbation (units: None)
- get_sigma(lna, y, args)[source]
Getter method for shear perturbation from perturbation equations vector
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Dimensionless shear perturbation (units: None)
- get_theta(lna, y, args)[source]
Getter method for velocity divergence perturbation from perturbation equations vector
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Velocity divergence perturbation (units: 1/Mpc)
- rho_delta(lna, y, args)[source]
Compute energy density perturbation, contribution to metric perturbation evolution.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Energy density perturbation (units: eV cm^{-3})
- rho_plus_P_sigma(lna, y, args)[source]
Compute shear stress perturbation, needed for CMB
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Shear stress perturbation (units: eV cm^{-3})
- rho_plus_P_theta(lna, y, args)[source]
Compute velocity perturbation times the sum of energy density and pressure. {0, i} component of the perturbed stress energy tensor.
Parameters:
lnafloatLogarithm of scale factor
yarrayPerturbation mode values
argsdictCosmological parameters (params)
Returns:
- float
Velocity perturbation (units: eV cm^{-3} Mpc^{-1})