def M_to_sigma(M, z=0, mode='3D'): if mode == '3D': ndim_scale = np.sqrt(3) elif mode == '1D': ndim_scale = 1. # return prefac * .00989 * U.km / U.s \ # * np.power(M.to(U.Msun).value, 1 / 3) # Note: Delta_vir returns the overdensity in units of background, # which is Delta_c * Om in B&N98 notation. return 0.016742 * U.km * U.s**-1 * np.power( np.power(M.to(U.Msun).value, 2) * Delta_vir(z) / Delta_vir(0) * cosmo.Om(z) / cosmo.Om0 * np.power(cosmo.H(z) / cosmo.H0, 2), 1 / 6) / ndim_scale
def test_scalar(self): with pytest.raises(u.UnitConversionError): Planck13.Om(0. * u.m)
2) The second method is using a formula that has been extracted from a Taylor expansion approximation for scale factor. dp0 = (z*c/H0) * (1-(z*(1+q0)/2)) 3) The third method is using astropy's '.lookback_distance()' method. """ from astropy.cosmology import Planck13 as cosmo from astropy.constants import G, c import numpy as np import matplotlib.pyplot as plt Or0 = cosmo.Ogamma(0) + cosmo.Onu(0) Om0 = cosmo.Om(0) Ode0 = cosmo.Ode(0) # deceleration parameter (equation 6.11) q0 = Or0 + 0.5 * Om0 - Ode0 H0 = cosmo.H(0).to('1 / s') z = np.linspace(0, 2, 100) # current proper distance in terms of z (equation 6.12) dp0_612 = c * z / H0 dp0_612 = dp0_612.to('Mpc') # current proper distance in terms of z (equation 6.19) dp0_619 = (z * c / H0) * (1 - (z * (1 + q0) / 2))
import matplotlib.pyplot as plt import seaborn as sns sns.set() t0 = cosmo.age(0) time_window = np.linspace(0, t0, 100)[1:-1] z = [z_at_value(cosmo.age, t) for t in time_window] H = cosmo.H(z) # critical energy density of universe (all components) ced = ((3 * c**2) / (8 * np.pi * G)) * H**2 # Plotting Omega (density parameter) fig, ax = plt.subplots() ax.scatter(time_window, cosmo.Om(z), s=1, c='b', label='Matter') ax.scatter(time_window, cosmo.Odm(z), s=1, c='k', label='Dark Matter') ax.scatter(time_window, cosmo.Ode(z), s=1, c='brown', label='Dark Energy') plt.xlabel('Time (age of universe in Gyr)') plt.ylabel('Density Parameter (Omega)') ax.legend() plt.show() # Plotting energy density (ignoring the first 3 Gyrs from Big Bang) matter = (cosmo.Om(z) * ced).to('MeV / m3') dark_matter = (cosmo.Odm(z) * ced).to('MeV / m3') dark_energy = (cosmo.Ode(z) * ced).to('MeV / m3') fig, ax = plt.subplots() ax.scatter(time_window[20:], matter[20:], s=1, c='b', label='Matter') ax.scatter(time_window[20:], dark_matter[20:], s=1, c='k', label='Dark Matter')