Cosmology#
RUBIX cosmology module#
For RUBIX we implemented a cosmology modlue that is similar to the astropy cosmology module and is jax compatible. Therefore, we follow https://github.com/ArgonneCPAC/dsps/blob/main/dsps/cosmology/flat_wcdm.py
We assume Planck15 cosmology: The present day matter density Om0 is set to 0.3089. The present day dark energy equation of state w0 is set to -1. The dark energy equation of state parameter wa is set to 0.0. The Hubble constant h is set to 0.6774.
# NBVAL_IGNORE_OUTPUT
from rubix.cosmology import PLANCK15 as rubix_cosmo
# Compare to astropy
from astropy.cosmology import Planck15 as astropy_cosmo
print(rubix_cosmo)
print(astropy_cosmo)
BaseCosmology(Om0=f32[], w0=f32[], wa=f32[], h=f32[])
FlatLambdaCDM(name="Planck15", H0=67.74 km / (Mpc s), Om0=0.3075, Tcmb0=2.7255 K, Neff=3.046, m_nu=[0. 0. 0.06] eV, Ob0=0.0486)
Comparison to astropy.cosmology#
We can now compare our RUBIX cosmology module with the astropy cosmology module. We show the comparison for the angular diameter distance, the comoving distance, the lookback to z and the age.
# NBVAL_IGNORE_OUTPUT
z = 0.2
print("Angular Diameter Distance")
print("rubix cosmo: ",rubix_cosmo.angular_diameter_distance_to_z(z))
print("astropy cosmo: ",astropy_cosmo.angular_diameter_distance(z))
print("Comoving Distance")
print("rubix cosmo: ",rubix_cosmo.comoving_distance_to_z(z))
print("astropy cosmo: ",astropy_cosmo.comoving_distance(z))
print("lookback to z")
print("rubix cosmo: ",rubix_cosmo.lookback_to_z(z))
print("astropy cosmo: ",astropy_cosmo.lookback_time(z))
print("Age")
print("rubix cosmo: ",rubix_cosmo.age_at_z(z))
print("astropy cosmo: ",astropy_cosmo.age(z))
Angular Diameter Distance
rubix cosmo: 702.5322
astropy cosmo: 702.3747610737071 Mpc
Comoving Distance
rubix cosmo: 843.0387
astropy cosmo: 842.8497132884485 Mpc
lookback to z
rubix cosmo: 2.5104787
astropy cosmo: 2.509878627257186 Gyr
Age
rubix cosmo: [11.310789]
astropy cosmo: 11.287737269639198 Gyr
from rubix.cosmology.utils import trapz
import jax.numpy as jnp
x = jnp.array([0, 1, 2, 3])
y = jnp.array([0, 1, 4, 9])
print(trapz(x, y))
9.5
from rubix.cosmology import PLANCK15 as rubix_cosmo
import jax.numpy as jnp
#from rubix.cosmology.base import scale_factor_to_redshift
scale_factor = jnp.array(0.5)
result = rubix_cosmo.scale_factor_to_redshift(jnp.array(0.5))
print(result) # Output: 1.0
result2 = rubix_cosmo.comoving_distance_to_z(0.5)
print(result2) # Output: 0.0
1.0
1946.5874