Code: Select all
import numpy as np
import camb
pars = camb.CAMBparams()
pars.set_cosmology(H0=67.5, ombh2=0.022, omch2=0.122)
ks_h = np.geomspace(1e-8, 1e4, 131)
PK = camb.get_matter_power_interpolator(pars, var1="delta_cdm");
zs = [0, 3600]
Ps = PK.P(zs, ks_h)
plt.rcParams["mathtext.fontset"] = "cm"
plt.loglog(ks_h, Ps[0,:], label=r"$z=0$")
plt.loglog(ks_h, Ps[1,:], label=r"$z=3600$")
plt.xlabel(r"$k/h\ [\rm{Mpc}^{-1}]$", fontsize=18)
plt.ylabel(r"$P(k)\ [(\rm{Mpc}/h)^3]$", fontsize=18)
plt.legend(fontsize=18)
plt.show()
https://ibb.co/25Kf5Xt
Is my implementation of the power spectrum correct? The reason I'm asking is twofold. One is that I need this power spectrum to reproduce the collapse fraction of adiabatic halos as a function of redshift, as presented in a graph in a paper that I am reading and I seem to be getting a wrong curve. The second is that if I use the linear growth factor [math] to estimate the power spectrum at an arbitrary redshift [math], I don't get the right answer. For example, if I use: Power spectrum ([math]) [math] Power spectrum([math]), where I calculate " Power spectrum([math])" using CAMB and [math] using Dodelson and Schmidt text book eqn (8.77), the resulting "Power spectrum ([math])" I get is not the same as I get when passing the redshift value [math] directly to CAMB to calculate the power spectrum.
P.S. Please note that the cosmological parameter values that I am using in CAMBparams() function are taken from the "CAMBdemo.ipynb" file that I found online.