Observables

Observables#

Observables computed from a solve’s returned quantities.

discoeb.matter_power_spectrum(k, *, delta_c, delta_b, omega_c, omega_b, A_s, n_s, k_p) → Annotated[Array, 'k'][source]#

Return the linear P(k) in Mpc^3 from the density contrasts.

One cosmology’s P(k), that of the cold dark matter and baryons,

P(k) = 2 pi^2 / k^3 A_s (k / k_p)^(n_s - 1) delta_m(k)^2,

with delta_m their density-weighted contrast at unit initial curvature. Keep delta_c and delta_b in solve_eb() at the scale factor of interest, 1 for today, and pass their values there:

values = solve_eb(cosmology, k, [1.0], keep=("delta_c", "delta_b"), thermo_weight=0.1)
delta_c, delta_b = jnp.unstack(values[0, :, :, -1])
pk = matter_power_spectrum(
    k,
    delta_c=delta_c,
    delta_b=delta_b,
    omega_c=cosmology.omega_c,
    omega_b=cosmology.omega_b,
    A_s=cosmology.A_s,
    n_s=cosmology.n_s,
    k_p=cosmology.k_p,
)

For a batch, jax.vmap it over the cosmologies. The keyword arguments are mapped over their leading axis and k is held:

batched = jax.vmap(matter_power_spectrum, in_axes=(None,))
pk = batched(k, delta_c=delta_c, ..., k_p=k_p)  # (n_cosmologies, n_k)
Parameters:
  • k – Wave numbers in 1/Mpc, shape (n_k,).

  • delta_c – The CDM and baryon density contrasts, shape (n_k,).

  • delta_b – The CDM and baryon density contrasts, shape (n_k,).

  • omega_c – The cold dark matter and baryon densities, the primordial amplitude and tilt, and the pivot scale in 1/Mpc, each a scalar.

  • omega_b – The cold dark matter and baryon densities, the primordial amplitude and tilt, and the pivot scale in 1/Mpc, each a scalar.

  • A_s – The cold dark matter and baryon densities, the primordial amplitude and tilt, and the pivot scale in 1/Mpc, each a scalar.

  • n_s – The cold dark matter and baryon densities, the primordial amplitude and tilt, and the pivot scale in 1/Mpc, each a scalar.

  • k_p – The cold dark matter and baryon densities, the primordial amplitude and tilt, and the pivot scale in 1/Mpc, each a scalar.

Returns:

P(k) of shape (n_k,).

Return type:

jax.Array

Notes

Differentiable in the parameters given as JAX values, as solve_eb’s values are: the derivative at fixed scale factor.