flowpm.tfbackground

TensorFlow implementation of Cosmology Computations

flowpm.tfbackground.D1(cosmo, a)[source]

Normalised first order growth factor.

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

D1 (scalar float Tensor) – Normalised D1.

Notes

The expression for \(D_{1norm}(a)\) is:

\[D_{1norm}(a)=\frac{D_1(a)}{D_1(a=1)}\]
flowpm.tfbackground.D1f(cosmo, a)[source]

Derivative of the first order growth factor respect to scale factor a

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor – normalised derivative D1.

Notes

The expression for \(D'_{1norm}(a)\) is:

\[D'_{1norm}(a)=\frac{D'_1(a)}{D_1(a=1)}\]
flowpm.tfbackground.D2(cosmo, a)[source]

Normalised second order growth factor

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor – normalised D2.

Notes

The expression for \(D_{2norm}(a)\) is:

\[D_{2norm}(a)=\frac{D_2(a)}{D_2(a=1)}\]
flowpm.tfbackground.D2f(cosmo, a)[source]

Derivative of the second order growth factor respect to scale factor a

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor – normalised derivative D2.

Notes

The expression for \(D'_{2norm}(a)\) is:

\[D'_{2norm}(a)=\frac{D'_2(a)}{D_2(a=1)}\]
flowpm.tfbackground.E(cosmo, a)[source]

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

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

Returns

E^2 (Scalar float Tensor) – Square of the scaling of the Hubble constant as a function of scale factor

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 :cite:`2005:Percival`) :

\[E(a) = sqrt(\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().

flowpm.tfbackground.Gf(cosmo, a)[source]

FastPM growth factor function

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor (FastPM growth factor function.)

Notes

The expression for \(Gf(a)\) is:

\[Gf(a)=D'_{1norm}*a**3*E(a)\]
flowpm.tfbackground.Gf2(cosmo, a)[source]

FastPM second order growth factor function

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor (FastPM second order growth factor function.)

Notes

The expression for \(Gf_2(a)\) is:

\[Gf_2(a)=D'_{2norm}*a**3*E(a)\]
flowpm.tfbackground.H(cosmo, a)[source]

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

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

Returns

H (Scalar float Tensor) – Hubble parameter at the requested scale factor.

flowpm.tfbackground.Omega_de_a(cosmo, a)[source]

Dark Energy density at scale factor a.

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

Returns

Omega_de (Scalar float Tensor) – Dark Energy density at the requested scale factor

Notes

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

\[\Omega_{de}(a) = \frac{\Omega_{0,de} a^{f(a)}}{E^2(a)}\]

where \(f(a)\) is the Dark Energy evolution parameter computed by f_de() (see :cite:`2005:Percival` Eq. (6)).

flowpm.tfbackground.Omega_m_a(cosmo, a)[source]

Matter density at scale factor a.

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

Returns

Omega_m (Scalar float Tensor) – Non-relativistic matter density at the requested scale factor

Notes

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

\[\Omega_m(a) = \frac{\Omega_{0,m} a^{-3}}{E^2(a)}\]

see :cite:`2005:Percival` Eq. (6)

flowpm.tfbackground.a_of_chi(cosmo, chi)[source]

Computes the scale factor for corresponding (array) of radial comoving distance by reverse linear interpolation.

Parameters
  • cosmo (Cosmology) – Cosmological parameters

  • chi (array_like or tf.TensorArray) – radial comoving distance to query.

Returns

a (tf.TensorArray) – Scale factors corresponding to requested distances

flowpm.tfbackground.angular_diameter_distance(cosmo, a)[source]

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

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (tf.TensorArray) – Scale factor

Returns

d_A (tf.TensorArray)

Notes

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

\[d_A(a) = a f_k(a)\]
flowpm.tfbackground.dEa(cosmo, a)[source]

Derivative of the scale factor dependent factor E(a) in the Hubble parameter with respect to the scale factor.

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

Returns

dE(a)/da (Scalar float Tensor) – Derivative of the scale factor dependent factor in the Hubble parameter with respect to the scale factor.

Notes

The expression for \(\frac{dE}{da}\) is:

\[\frac{dE(a)}{da}=\frac{-3a^{-4}\Omega_{0m} -2a^{-3}\Omega_{0k} +f'_{de}\Omega_{0de}a^{f_{de}(a)}}{2E(a)}\]
flowpm.tfbackground.dchioverda(cosmo, a)[source]

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

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

Returns

dchi/da (tf.TensorArray) – Derivative of the radial comoving distance with respect to the scale factor at the specified scale factor.

Notes

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

\[\frac{d \chi}{da}(a) = \frac{R_H}{a^2 E(a)}\]
flowpm.tfbackground.dfde(cosmo, a, epsilon=1e-05)[source]

Derivative of the evolution parameter for the Dark Energy density f(a) with respect to the scale factor.

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

  • epsilon (float value) – Small number to make sure we are not dividing by 0 and avoid a singularity

Returns

df(a)/da (Scalar float Tensor) – Derivative of the evolution parameter for the Dark Energy density with respect to the scale factor.

Notes

The expression for \(\frac{df(a)}{da}\) is:

\[\frac{df}{da}(a) = =\frac{3w_a \left( \ln(a-\epsilon)-\]

frac{a-1}{a-epsilon}right)}{ln^2(a-epsilon)}

flowpm.tfbackground.f1(cosmo, a)[source]

Linear order growth rate

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor – Linear order growth rate.

Notes

The expression for \(f_{1}(a)\) is:

\[f{1}(a)=\frac{D'_1(a)}{D_1(a=1)}*a\]
flowpm.tfbackground.f2(cosmo, a)[source]

Second order growth rate.

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor – Linear order growth rate.

Notes

The expression for \(f_{2}(a)\) is:

\[f{2}(a)=\frac{D'_2(a)}{D_2(a=1)}*a\]
flowpm.tfbackground.fde(cosmo, a, epsilon=1e-05)[source]

Evolution parameter for the Dark Energy density.

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

  • epsilon (float value) – Small number to make sure we are not dividing by 0 and avoid a singularity

Returns

f (Scalar float Tensor.) – The evolution parameter of the Dark Energy density as a function of scale factor

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 :cite:`2005:Percival`) 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 \(f(a)\) becomes:

\[f(a) = -3(1 + w_0) + 3 w \left[ \frac{a - 1}{ \ln(a) } - 1 \right]\]
flowpm.tfbackground.gf(cosmo, a)[source]

Derivative of Gf against a

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor (the derivative of Gf against a.)

Notes

The expression for \(gf(a)\) is:

\[gf(a)=\frac{dGF}{da}= D^{''}_1 * a ** 3 *E(a) +D'_{1norm}*a ** 3 * E'(a) + 3 * a ** 2 * E(a)*D'_{1norm}\]
flowpm.tfbackground.gf2(cosmo, a)[source]

Derivative of Gf2 against a

Parameters
  • cosmo (dict) – Cosmology dictionary.

  • a (tf.TensorArray) – Scale factor.

Returns

Scalar float Tensor (the derivative of Gf2 against a.)

Notes

The expression for \(gf2(a)\) is:

\[gf_2(a)=\frac{dGF_2}{da}= D^{''}_2 * a ** 3 *E(a) +D'_{2norm}*a ** 3 * E'(a) + 3 * a ** 2 * E(a)*D'_{2norm}\]
flowpm.tfbackground.growth_ode(a, y, **kwcosmo)[source]

Define the ode functions that will be used to compute the linear growth factor D_1(a) and second-order growth factor D_2(a) at a given scale factor.

Parameters
  • a (Contain the value of y for each desired scale factors in) – Scale factor

  • y (tf.TensorArray) –

  • a

  • row (with the initial value y0 in the first) –

  • cosmo (Cosmology) – Cosmological parameters structure

Notes

Linear growth factor D_1(a) is given by .. math:: a^2frac{d^2 D_1}{da^2}+ left( Omega_{Lambda}(a)- frac{ Omega_{m}(a)}{2} +2 right) a frac{dD_1}{da}=frac{3}{2} Omega_{m}(a)D_1

(see :cite:`Florent Leclercq thesis` Eq. (1.96))

flowpm.tfbackground.maybe_compute_ODE(cosmo, log10_amin=- 2, steps=256)[source]

Either computes or returns the cached ODE solution

flowpm.tfbackground.odesolve_func(a, rtol=0.0001, **kwcosmo)[source]

Solves the growth ODE system for a given cosmology at the requested scale factors.

Parameters
  • a (array_like) – Output scale factors, note that the ODE is initialized at a[0]

  • rtol (float, optional) – Parameters determing the error control performed by the solver

  • kwcosmo (keyword args) – Cosmological parameter values.

Returns

(D1, D1f), (D2, D2f) (dictionary) – First and second order growth factors, and their derivatives, computed at the requested scale factors.

flowpm.tfbackground.rad_comoving_distance(cosmo, a, log10_amin=- 3, steps=256, rtol=0.001)[source]

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

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

  • log10_amin (integer) – Starting value of the log-scale spaced sequence.

  • steps (integer, optional) – Number of samples to generate.

  • rtol (float, optional) – Parameters determing the error control performed by the solver

Returns

chi (tf.TensorArray,) – Radial comoving distance corresponding to the specified scale factor.

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)}\]
flowpm.tfbackground.transverse_comoving_distance(cosmo, a)[source]

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

Parameters
  • cosmo (Cosmology) – Cosmological parameters

  • a (tf.TensorArray) – Scale factor

Returns

f_k (tf.TensorArray) – Transverse comoving distance corresponding to the specified scale factor.

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}\]
flowpm.tfbackground.w(cosmo, a)[source]

Dark Energy equation of state parameter using the Linder parametrisation.

Parameters
  • cosmo (Cosmology) – Cosmological parameters structure

  • a (array_like or tf.TensorArray) – Scale factor

Returns

w (Scalar float Tensor) – The Dark Energy equation of state parameter at the specified scale factor

Notes

The Linder parametrization :cite:`2003:Linder` for the Dark Energy equation of state \(p = w \rho\) is given by:

\[w(a) = w_0 + w (1 -a)\]