PyCosmo.BoltzmannSolver package

Submodules

PyCosmo.BoltzmannSolver.BdfSolver module

PyCosmo.BoltzmannSolver.Fields module

class PyCosmo.BoltzmannSolver.Fields.Fields(cosmology)[source]

Bases: object

Class for linear perturbations field objects. Usage example: fields.delta(5) returns the dark matter density perturbation at the 5th time step

property a

a(a_index): scale factor [1]

property d_t

d_t: time step in ln(a) units (one fewer value than ln(a) [1]

set_results(lna, solver_result)[source]
class PyCosmo.BoltzmannSolver.Fields.VectorWrapper(y, indices)[source]

Bases: object

PyCosmo.BoltzmannSolver.LinearPerturbationBoltzmann module

class PyCosmo.BoltzmannSolver.LinearPerturbationBoltzmann.LinearPerturbationBoltzmann(*a, **kw)[source]

Bases: LinearPerturbationBase

Class for computing linear perturbations by solving the Einstein-Boltzmann ODE system.

The Boltzmann solver is selected using the set function:

cosmo.set(pk_type = "boltz")
P_R_k(k)[source]

Computes the primordial power spectrum of gauge invariant curvature perturbations (R)

Parameters:

k – wavenumber \([1/Mpc]\)

Returns:

P_R(k), primordial power spectrum of R

fields(k, grid, sec_factor=5, keep_lna0=False, initial_conditions=None, enable_fast_solver=True, enable_sparse_lu_solver=True)[source]

Solves the Einstein-Boltzmann ODE system for the evolution of the linear order perturbation of the fields.

Parameters:
  • k – wavenumber \([h/Mpc]\)

  • grid – ln(a) values at which to output fields [1]

  • sec_factor – relaxes row permutation criterium in optimized LUP solver

  • keep_lna0 – if True includes the fields at initial time a_0

  • initial_conditions – can pass a_0, y_0 (vector of initial conditions)

  • enable_fast_solver – if set to False always use standard LUP solver for full matrix

  • enable_sparse_lu_solver – if set to True: avoid iterating over known zero-entries in fallback LUP solver

Returns:

Linear order perturbations, accessed with fields.a, fields.Phi etc.

growth_a(a=1.0, k=None)[source]

Returns the linear growth factor computed from the Boltzmann solver at a given k value.

Parameters:
  • a – scale factor [1]

  • k – wavenumber used to compute the growth factor (default:k=1 \(Mpc^{-1}\)) [\(Mpc^{-1}\)]

Returns:

D(a): growth factor normalised to 1 at a=1 [1]

max_redshift(k)[source]

computes max redshift for which this model is applicable. uses the implemented initial conditions to determine this.

Parameters:

k – wavenumber k [\(h Mpc^{-1}\)]

Returns:

redshift

min_a(k)[source]
powerspec_a_k(a=1.0, k=0.1, diag_only=False)[source]

Returns the linear total matter power spectrum computed from the Boltzmann solver, this includes cold dark matter, baryons and massive neutrinos for an array of a and k values.

Parameters:
  • a – scale factor [1] (default:a=1)

  • k – wavenumber used to compute the power spectrum (default:k=1 Mpc^1) [Mpc^-1]

  • diag_only – if set to True: compute powerspectrum for pairs \(a_i, k_i\), else consider all combinations \(a_i, k_j\)

Warning

If pk_norm_type = ‘A_s’ this will compute the total matter power spectrum following the general relativistic treatment (using delta_m_tot). If pk_norm_type = ‘deltah’ the Poisson equation will be assumed and the evolution will be split in growth factor and transfer function. We recommend the use of A_s or sigma8 normalizations.

Returns:

P(a,k): total matter power spectrum [\(Mpc^3\)]

powerspec_cb_a_k(a=1.0, k=0.1, diag_only=False)[source]

Returns the linear matter power spectrum of cold dark matter and baryons computed from the Boltzmann solver for an array of a and k values.

Parameters:
  • a – scale factor [1] (default:a=1)

  • k – wavenumber used to compute the power spectrum (default:k=1 \(Mpc^{-1}\)) [\(Mpc^{-1}\)]

  • diag_only – if set to True: compute powerspectrum for pairs \(a_i, k_i\), else consider all combinations \(a_i, k_j\)

Returns:

P_cb(a,k): power spectrum of CDM+baryons [\(Mpc^3\)]

transfer_k(k)[source]

Computes the linear matter transfer function using the Boltzmann solver assuming the Poisson equation.

Parameters:

k – wavenumber \([ Mpc^{-1} ]\)

Returns:

Transfer function \([ Mpc^{3/2} ]\)

PyCosmo.BoltzmannSolver.LinearPerturbationBoltzmann.print_new_traces(cache_file)[source]
PyCosmo.BoltzmannSolver.LinearPerturbationBoltzmann.src_m_column_j(args)[source]
PyCosmo.BoltzmannSolver.LinearPerturbationBoltzmann.trace_call(frame, event, arg)[source]

PyCosmo.BoltzmannSolver.LinearPerturbationBoltzmannCombined module

PyCosmo.BoltzmannSolver.LsodaSolver module

class PyCosmo.BoltzmannSolver.LsodaSolver.LsodaSolver(verbose, rtol, atol, max_bdf_order, max_iter, h0, cosmology, fast_solver, **extra_args_for_solver)[source]

Bases: object

SOLVER_ID = 'linear_perturbation'
initial_conditions(k)[source]
solve(k, grid, sec_factor=3, initial_conditions=None, enable_fast_solver=True, enable_sparse_lu_solver=True, keep_lna0=False)[source]

PyCosmo.BoltzmannSolver.ScipySolver module

class PyCosmo.BoltzmannSolver.ScipySolver.ScipySolver(cosmology, method, **extra_args_for_solver)[source]

Bases: object

fields(k, grid, keep_lna0=False)[source]
initial_conditions(k)[source]
solve(k, grid)[source]
class PyCosmo.BoltzmannSolver.ScipySolver.ScipySolverRSA(cosmology, method, **extra_args_for_solver)[source]

Bases: ScipySolver

fields(k, grid, keep_lna0=False)[source]
solve(k, grid)[source]
PyCosmo.BoltzmannSolver.ScipySolver.merge(wrapper, t_0, t_switch, t_1, y_0, y_1)[source]

combine the non-RSA and RSA solutions and recompute the approximated radiation fields at output times

PyCosmo.BoltzmannSolver.ScipySolver.switch_time(wrapper)[source]

Module contents