# cosmicpy.cosmology – Cosmology module¶

 cosmology(**kwargs) Stores all cosmological parameters and performs the computation
class cosmicpy.cosmology.cosmology(**kwargs)[source]

Bases: object

Stores all cosmological parameters and performs the computation of derived quantities (distances, matter power spectra, etc...)

Parameters: h (float) – Reduced hubble constant (def: 0.7) Omega_b (float) – Baryonic matter density (def: 0.045) Omega_m (float) – Matter density (def: 0.25) Omega_de (float) – Dark energy density (def: 0.75) wa (w0,) – Dark energy equation of state parameters (def: w0 = -0.95, wa = 0.0) n (float) – Scalar spectral index (def: 1.0) tau (float) – Reionization optical depth (def: 0.09) sigma8 (float) – Fluctuation amplitude at 8 Mpc/h (def: 0.8)

References

 [EfstathiouBond99] (1, 2) G. Efstathiou and J. R. Bond. Cosmic confusion: degeneracies among cosmological parameters derived from measurements of microwave background anisotropies. MNRAS, 304:75–97, March 1999. arXiv:arXiv:astro-ph/9807103, doi:10.1046/j.1365-8711.1999.02274.x.
 [EisensteinHu98] (1, 2, 3) D. J. Eisenstein and W. Hu. Baryonic Features in the Matter Transfer Function. ApJ, 496:605, March 1998. arXiv:arXiv:astro-ph/9709112, doi:10.1086/305424.
 [Linder03] E. V. Linder. Exploring the Expansion History of the Universe. Physical Review Letters, 90(9):091301, March 2003. arXiv:arXiv:astro-ph/0208512, doi:10.1103/PhysRevLett.90.091301.
 [Percival05] (1, 2, 3, 4) W. J. Percival. Cosmological structure formation in a homogeneous dark energy background. AA, 443:819–830, December 2005. arXiv:arXiv:astro-ph/0508156, doi:10.1051/0004-6361:20053637.
 [SmithPeacockJenkins+03] R. E. Smith, J. A. Peacock, A. Jenkins, S. D. M. White, C. S. Frenk, F. R. Pearce, P. A. Thomas, G. Efstathiou, and H. M. P. Couchman. Stable clustering, the halo model and non-linear cosmological power spectra. MNRAS, 341:1311–1332, June 2003. arXiv:astro-ph/0207664, doi:10.1046/j.1365-8711.2003.06503.x.

Esqr(a)[source]

Square of the scale factor dependent factor E(a) in the Hubble parameter.

Parameters: a (array_like) – Scale factor E^2 – Square of the scaling of the Hubble constant as a function of scale factor ndarray, or float if input scalar

Notes

The Hubble parameter at scale factor a is given by $$H^2(a) = E^2(a) H_o^2$$ where $$E^2$$ is obtained through Friedman’s Equation (see [Percival05]) :

$E^2(a) = \Omega_m a^{-3} + \Omega_k a^{-2} + \Omega_{de} a^{f(a)}$

where $$f(a)$$ is the Dark Energy evolution parameter computed by f_de().

G(a)[source]

Compute Growth factor at a given scale factor, normalised such that G(a=1) = 1.

Parameters: a (array_like) – Scale factor G – Growth factor computed at requested scale factor ndarray, or float if input scalar
H(a)[source]

Hubble parameter [km/s/(Mpc/h)] at scale factor a

Parameters: a (array_like) – Scale factor H – Hubble parameter at the requested scale factor. ndarray, or float if input scalar
Omega_b[source]

baryon density

Omega_de_a(a)[source]

Dark Energy density at scale factor a.

Parameters: a (array_like) – Scale factor Omega_de – Dark Energy density at the requested scale factor ndarray, or float if input scalar

Notes

The evolution of Dark Energy density $$\Omega_{de}(a)$$ is given by:

$\Omega_{de}(a) = \frac{\Omega_{de} a^{f(a)}}{E^2(a)}$

where $$f(a)$$ is the Dark Energy evolution parameter computed by f_de() (see [Percival05] Eq. (6)).

Omega_m_a(a)[source]

Matter density at scale factor a.

Parameters: a (array_like) – Scale factor Omega_m – Non-relativistic matter density at the requested scale factor ndarray, or float if input scalar

Notes

The evolution of matter density $$\Omega_m(a)$$ is given by:

$\Omega_m(a) = \frac{\Omega_m a^{-3}}{E^2(a)}$

see [Percival05] Eq. (6)

T(k, type='eisenhu_osc')[source]

Computes the matter transfer function.

Parameters: k (array_like) – Wave number in h Mpc^{-1} type (str, optional) – Type of transfer function. Either ‘eisenhu’ or ‘eisenhu_osc’ (def: ‘eisenhu_osc’) T – Value of the transfer function at the requested wave number array_like

Notes

The Eisenstein & Hu transfer functions are computed using the fitting formulae of [EisensteinHu98]

a2chi(a)[source]

Radial comoving distance in [Mpc/h] for a given scale factor.

Parameters: a (array_like) – Scale factor chi – Radial comoving distance corresponding to the specified scale factor. ndarray, or float if input scalar

Notes

The radial comoving distance is computed by performing the following integration:

$\chi(a) = R_H \int_a^1 \frac{da^\prime}{{a^\prime}^2 E(a^\prime)}$
chi2a(chi)[source]

Scale factor for the radial comoving distance specified in [Mpc/h].

Parameters: chi (array_like) – Radial comoving distance in [Mpc/h] a – Scale factor corresponding to the specified radial comoving distance. ndarray, or float if input scalar
d_A(a)[source]

Angular diameter distance in [Mpc/h] for a given scale factor.

Parameters: a (array_like) – Scale factor d_A ndarray, or float if input scalar

Notes

Angular diameter distance is expressed in terms of the transverse comoving distance as:

$d_A(a) = a f_k(a)$
dchioverda(a)[source]

Derivative of the radial comoving distance with respect to the scale factor.

Parameters: a (array_like) – Scale factor dchi/da – Derivative of the radial comoving distance with respect to the scale factor at the specified scale factor. ndarray, or float if input scalar

Notes

The expression for $$\frac{d \chi}{da}$$ is:

$\frac{d \chi}{da}(a) = \frac{R_H}{a^2 E(a)}$
dzoverda(a)[source]

Derivative of the redshift with respect to the scale factor.

Parameters: a (array_like) – Scale factor dz/da – Derivative of the redshift with respect to the scale factor at the specified scale factor. ndarray, or float if input scalar

Notes

The expression for $$\frac{d z}{da}$$ is:

$\frac{d z}{da}(a) = \frac{1}{a^2}$
f_de(a)[source]

Evolution parameter for the Dark Energy density.

Parameters: a (array_like) – Scale factor f – The evolution parameter of the Dark Energy density as a function of scale factor ndarray, or float if input scalar

Notes

For a given parametrisation of the Dark Energy equation of state, the scaling of the Dark Energy density with time can be written as:

$\rho_{de}(a) \propto a^{f(a)}$

(see [Percival05]) where $$f(a)$$ is computed as $$f(a) = \frac{-3}{\ln(a)} \int_0^{\ln(a)} [1 + w(a^\prime)] d \ln(a^\prime)$$. In the case of Linder’s parametrisation for the dark energy in Eq. (?) $$f(a)$$ becomes:

$f(a) = -3(1 + w_0) + 3 w \left[ \frac{a - 1}{ \ln(a) } - 1 \right]$
f_k(a)[source]

Transverse comoving distance in [Mpc/h] for a given scale factor.

Parameters: a (array_like) – Scale factor f_k – Transverse comoving distance corresponding to the specified scale factor. ndarray, or float if input scalar

Notes

The transverse comoving distance depends on the curvature of the universe and is related to the radial comoving distance through:

$\begin{split}f_k(a) = \left\lbrace \begin{matrix} R_H \frac{1}{\sqrt{\Omega_k}}\sinh(\sqrt{|\Omega_k|}\chi(a)R_H)& \mbox{for }\Omega_k > 0 \\ \chi(a)& \mbox{for } \Omega_k = 0 \\ R_H \frac{1}{\sqrt{\Omega_k}} \sin(\sqrt{|\Omega_k|}\chi(a)R_H)& \mbox{for } \Omega_k < 0 \end{matrix} \right.\end{split}$
g(a, a_s)[source]

Lensing efficiency kernel computed a distance chi for sources placed at distance chi_s

pk(k, a=1.0, nl_type='smith2003', **kwargs)[source]

Computes the full non linear matter power spectrum.

Parameters: k (array_like) – Wave number in h Mpc^{-1} a (array_like, optional) – Scale factor (def: 1.0) nl_type (str, optional) – Type of non linear corrections. Only ‘smith2003’ is implemented type (str, optional) – Type of transfer function. Either ‘eisenhu’ or ‘eisenhu_osc’ (def: ‘eisenhu_osc’) pk – Non linear matter power spectrum at the specified scale and scale factor. array_like

Notes

The non linear corrections are implemented following [2003:smith]

pk_lin(k, a=1.0, **kwargs)[source]

Computes the linear matter power spectrum.

Parameters: k (array_like) – Wave number in h Mpc^{-1} a (array_like, optional) – Scale factor (def: 1.0) type (str, optional) – Type of transfer function. Either ‘eisenhu’ or ‘eisenhu_osc’ (def: ‘eisenhu_osc’) pk – Linear matter power spectrum at the specified scale and scale factor. array_like
pk_prim(k)[source]

Primordial power spectrum Pk = k^n

pl(l, a, **kwargs)[source]

Computes the non linear matter power spectrum at a given angular scale using the Limber approximation

pl_lin(l, a, **kwargs)[source]

Computes the linear matter power spectrum at the specified scale and scale factor

sh_d[source]

Sound horizon at drag epoch in Mpc/h

Computed from Equation (6) in [EisensteinHu98] :

$r_s(z_d) = \frac{2}{3 k_{eq}} \sqrt{ \frac{6}{R_{eq}} } \ln \frac{ \sqrt{1 + R_d} + \sqrt{R_d + R_{eq}}}{1 + \sqrt{R_{eq}}}$

where $$R_d$$ and $$R_{eq}$$ are respectively the ratio of baryon to photon momentum density at drag epoch and equality epoch (see Equation (5) in [EisensteinHu98]) and $$k_{eq}$$ is the scale of the scale of the particle horizon at equality epoch.

sh_r[source]

Sound horizon at recombination in Mpc/h

Computed from Equation (19) in [EfstathiouBond99] :

$r_s(z_r) = \frac{4000 \sqrt{a_{equ}}}{\sqrt{\omega_b (1 + \eta_\nu)}} \ln \frac{ \sqrt{1 + R_r} + \sqrt{R_r + R_{eq}}}{1 + \sqrt{R_{eq}}}$

where $$R_r$$ and $$R_{eq}$$ are respectively the ratio of baryon to photon momentum density at recombination epoch and equality epoch (see Equation (18) in [EfstathiouBond99]) and $$\eta_{\nu}$$ denotes the relative densities of massless neutrinos and photons.

sigmasqr(R, **kwargs)[source]

Computes the energy of the fluctuations within a sphere of R h^{-1} Mpc

$\sigma^2(R)= \frac{1}{2 \pi^2} \int_0^\infty \frac{dk}{k} k^3 P(k,z) W^2(kR)$

where

$W(kR) = \frac{3j_1(kR)}{kR}$
update(**kwargs)[source]

Updates the current cosmology based on the parameters specified in input.

Parameters: h (float) – Reduced hubble constant Omega_b (float) – Baryonic matter density Omega_m (float) – Matter density Omega_de (float) – Dark energy density wa (w0,) – Dark energy equation of state parameters n (float) – Scalar spectral index tau (float) – Reionization optical depth sigma8 (float) – Fluctuation amplitude at 8 Mpc/h
w(a)[source]

Dark Energy equation of state parameter using the Linder parametrisation.

Parameters: a (array_like) – Scale factor w – The Dark Energy equation of state parameter at the specified scale factor ndarray, or float if input scalar

Notes

The Linder parametrization [Linder03] for the Dark Energy equation of state $$p = w \rho$$ is given by:

$w(a) = w_0 + w (1 -a)$