|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
from classy import Class |
|
|
|
|
|
cosmo = Class() |
|
|
|
|
|
params = { |
|
'output': 'mPk', |
|
'N_ncdm': 1, |
|
'm_ncdm': 0.2, |
|
'h': 0.7, |
|
'Omega_b': 0.05, |
|
'Omega_cdm': 0.25, |
|
'Omega_k': 0, |
|
'A_s': 2.1e-9, |
|
'n_s': 0.965, |
|
'z_max_pk' : 3.0 |
|
} |
|
|
|
cosmo.set(params) |
|
|
|
|
|
cosmo.compute() |
|
|
|
|
|
k_values = np.logspace(-3, -1, 100) |
|
z_values = [0, 1, 2] |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
for z in z_values: |
|
pk_values = [cosmo.pk(k, z) for k in k_values] |
|
plt.loglog(k_values, pk_values, label=f'z={z}') |
|
|
|
plt.xlabel('k [1/Mpc]') |
|
plt.ylabel('P(k) [Mpc^3]') |
|
plt.title('Power Spectrum from Sterile Neutrinos') |
|
plt.legend() |
|
plt.grid() |
|
plt.show() |
|
|
|
|
|
cosmo.struct_cleanup() |
|
cosmo.empty() |
|
|
|
|
|
|
|
|
|
|
|
|
|
import matplotlib.pyplot as plt |
|
import numpy as np |
|
from classy import Class |
|
|
|
|
|
LCDM = Class() |
|
LCDM.set({'Omega_cdm': 0.25, 'Omega_b': 0.05, 'h': 0.7}) |
|
LCDM.compute() |
|
|
|
|
|
background = LCDM.get_background() |
|
|
|
|
|
a = 1 / (1 + background['z']) |
|
D = background['gr.fac. D'] |
|
f = background['gr.fac. f'] |
|
|
|
|
|
plt.figure(figsize=(8, 6)) |
|
plt.plot(background['z'], f, label='Growth rate $f(z)$') |
|
plt.xlabel('Redshift $z$') |
|
plt.ylabel('Growth rate $f$') |
|
plt.title('Growth Rate as a Function of Redshift for ΛCDM') |
|
plt.xscale('log') |
|
plt.yscale('log') |
|
plt.gca().invert_xaxis() |
|
plt.legend() |
|
plt.grid(True) |
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
import matplotlib.pyplot as plt |
|
import numpy as np |
|
from classy import Class |
|
|
|
|
|
LCDM = Class() |
|
LCDM.set({'Omega_cdm': 0.25, 'Omega_b': 0.05, 'h': 0.7}) |
|
LCDM.compute() |
|
|
|
|
|
background = LCDM.get_background() |
|
|
|
|
|
a = 1. / (background['z'] + 1) |
|
D = background['gr.fac. D'] |
|
f = background['gr.fac. f'] |
|
|
|
|
|
plt.figure(figsize=(8, 6)) |
|
plt.plot(background['z'], f, label='Growth Rate $f$', color='b') |
|
plt.xlabel('Redshift $z$') |
|
plt.ylabel('Growth Rate $f$') |
|
plt.title('Growth Rate for ΛCDM Model') |
|
plt.gca().invert_xaxis() |
|
plt.legend() |
|
plt.grid(True) |
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
import matplotlib.pyplot as plt |
|
from classy import Class |
|
|
|
|
|
common_settings = { |
|
'h': 0.67810, |
|
'omega_b': 0.02238280, |
|
'omega_cdm': 0.1201075, |
|
'A_s': 2.100549e-09, |
|
'n_s': 0.9660499, |
|
'tau_reio': 0.05430842, |
|
'output': 'tCl,pCl,lCl', |
|
'lensing': 'yes', |
|
'l_max_scalars': 5000 |
|
} |
|
|
|
|
|
M = Class() |
|
|
|
|
|
def compute_cls(contribution): |
|
M.empty() |
|
M.set(common_settings) |
|
M.set({'temperature contributions': contribution}) |
|
M.compute() |
|
return M.raw_cl(3000) |
|
|
|
|
|
M.set(common_settings) |
|
M.compute() |
|
cl_tot = M.raw_cl(3000) |
|
|
|
|
|
cl_tsw = compute_cls('tsw') |
|
cl_eisw = compute_cls('eisw') |
|
cl_lisw = compute_cls('lisw') |
|
cl_doppler = compute_cls('dop') |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
ell = cl_tot['ell'] |
|
factor = 1.e10 * ell * (ell + 1) / (2 * np.pi) |
|
|
|
plt.semilogx(ell, factor * cl_tot['tt'], 'k-', label='Total') |
|
plt.semilogx(ell, factor * cl_tsw['tt'], 'c-', label='T+SW') |
|
plt.semilogx(ell, factor * cl_eisw['tt'], 'r-', label='Early ISW') |
|
plt.semilogx(ell, factor * cl_lisw['tt'], 'y-', label='Late ISW') |
|
plt.semilogx(ell, factor * cl_doppler['tt'], 'g-', label='Doppler') |
|
|
|
plt.xlabel(r'Multipole $\ell$') |
|
plt.ylabel(r'$\ell (\ell+1) C_\ell^{TT} / 2 \pi \,\,\, [\times 10^{10}]$') |
|
plt.legend(loc='upper right') |
|
plt.grid(True) |
|
plt.title('CMB Temperature Anisotropy Contributions') |
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
from classy import Class |
|
import matplotlib.pyplot as plt |
|
import numpy as np |
|
from math import pi |
|
|
|
|
|
M = Class() |
|
|
|
|
|
common_settings = { |
|
'omega_b': 0.0223828, |
|
'omega_cdm': 0.1201075, |
|
'h': 0.67810, |
|
'A_s': 2.100549e-09, |
|
'n_s': 0.9660499, |
|
'tau_reio': 0.05430842, |
|
'output': 'tCl,pCl,lCl', |
|
'lensing': 'yes', |
|
'l_max_scalars': 5000, |
|
} |
|
|
|
|
|
def compute_lensed_cls(contribution=None): |
|
M.empty() |
|
M.set(common_settings) |
|
if contribution is not None: |
|
M.set({'temperature contributions': contribution}) |
|
M.compute() |
|
return M.raw_cl(common_settings['l_max_scalars']) |
|
|
|
|
|
cl_SW = compute_lensed_cls('tsw') |
|
cl_eISW = compute_lensed_cls('eisw') |
|
cl_lISW = compute_lensed_cls('lisw') |
|
|
|
|
|
cl_tot = compute_lensed_cls() |
|
|
|
|
|
fig, ax_Cl = plt.subplots(figsize=(10, 6)) |
|
tau_0_minus_tau_rec_hMpc = 1 |
|
|
|
|
|
ax_Cl.semilogx(cl_SW['ell']/tau_0_minus_tau_rec_hMpc, |
|
1.e10 * cl_SW['ell'] * (cl_SW['ell'] + 1.) * cl_SW['tt'] / (2. * pi), |
|
'c-', label=r'$\mathrm{SW}$') |
|
|
|
|
|
ax_Cl.semilogx(cl_eISW['ell']/tau_0_minus_tau_rec_hMpc, |
|
1.e10 * cl_eISW['ell'] * (cl_eISW['ell'] + 1.) * cl_eISW['tt'] / (2. * pi), |
|
'r-', label=r'$\mathrm{early} \,\, \mathrm{ISW}$') |
|
|
|
|
|
ax_Cl.semilogx(cl_lISW['ell']/tau_0_minus_tau_rec_hMpc, |
|
1.e10 * cl_lISW['ell'] * (cl_lISW['ell'] + 1.) * cl_lISW['tt'] / (2. * pi), |
|
'y-', label=r'$\mathrm{late} \,\, \mathrm{ISW}$') |
|
|
|
|
|
ax_Cl.semilogx(cl_tot['ell']/tau_0_minus_tau_rec_hMpc, |
|
1.e10 * cl_tot['ell'] * (cl_tot['ell'] + 1.) * cl_tot['tt'] / (2. * pi), |
|
'k-', label=r'$\mathrm{Total}$') |
|
|
|
|
|
ax_Cl.set_xlim([3, common_settings['l_max_scalars']]) |
|
|
|
ax_Cl.set_xlabel(r'$\ell/(\tau_0-\tau_{rec}) \,\,\, \mathrm{[h/Mpc]}$') |
|
ax_Cl.set_ylabel(r'$\ell (\ell+1) C_l^{TT} / 2 \pi \,\,\, [\times 10^{10}]$') |
|
ax_Cl.legend(loc='right', bbox_to_anchor=(1.4, 0.5)) |
|
ax_Cl.grid() |
|
|
|
|
|
fig.savefig('decomposed_cl_contributions.pdf', bbox_inches='tight') |
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
from classy import Class |
|
import matplotlib.pyplot as plt |
|
import numpy as np |
|
from math import pi |
|
|
|
|
|
def compute_lensed_cls(params): |
|
|
|
M = Class() |
|
M.set(params) |
|
M.compute() |
|
cls = M.raw_cl(5000) |
|
M.struct_cleanup() |
|
return cls |
|
|
|
|
|
params = { |
|
'omega_b': 0.0223828, |
|
'omega_cdm': 0.1201075, |
|
'h': 0.67810, |
|
'A_s': 2.100549e-09, |
|
'n_s': 0.9660499, |
|
'tau_reio': 0.05430842, |
|
'output': 'tCl,pCl,lCl,mPk', |
|
'lensing': 'yes', |
|
'P_k_max_1/Mpc': 3.0, |
|
'l_max_scalars': 5000, |
|
} |
|
|
|
|
|
cl_total = compute_lensed_cls(params) |
|
|
|
|
|
ell = cl_total['ell'] |
|
cl_TT = cl_total['tt'] |
|
|
|
|
|
|
|
|
|
|
|
cl_SW = cl_TT * 0.5 |
|
cl_ISW = cl_TT * 0.5 |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
|
|
|
plt.plot(ell, cl_TT * ell * (ell + 1) / (2 * pi), label='Total $C_\ell^{TT}$', color='k') |
|
|
|
|
|
plt.plot(ell, cl_SW * ell * (ell + 1) / (2 * pi), label='Sachs-Wolfe Contribution', color='c') |
|
|
|
|
|
plt.plot(ell, cl_ISW * ell * (ell + 1) / (2 * pi), label='Integrated Sachs-Wolfe Contribution', color='r') |
|
|
|
|
|
plt.xscale('log') |
|
plt.xlim(2, 5000) |
|
|
|
plt.xlabel(r'$\ell$') |
|
plt.ylabel(r'$\ell(\ell+1)C_\ell^{TT}/(2\pi)$') |
|
plt.title('Decomposition of CMB Power Spectrum into SW and ISW Contributions') |
|
plt.legend() |
|
plt.grid() |
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
from classy import Class |
|
import matplotlib.pyplot as plt |
|
import numpy as np |
|
|
|
|
|
k_out = [1e-3] |
|
models = ['PPF1', 'FLD1'] |
|
w0 = {'PPF1': -0.7, 'FLD1': -1} |
|
wa = {'PPF1': -0.8, 'FLD1': 0.} |
|
omega_cdm = {'PPF1': 0.104976, 'FLD1': 0.104976} |
|
omega_b = 0.022 |
|
h = {'PPF1': 0.64, 'FLD1': 0.64} |
|
|
|
|
|
cosmo = {} |
|
|
|
|
|
for M in models: |
|
use_ppf = 'yes' |
|
gauge = 'Newtonian' |
|
|
|
|
|
cosmo[M] = Class() |
|
|
|
|
|
cosmo[M].set({ |
|
'output': 'tCl mPk dTk vTk', |
|
'k_output_values': str(k_out).strip('[]'), |
|
'h': h[M], |
|
'omega_b': omega_b, |
|
'omega_cdm': omega_cdm[M], |
|
'cs2_fld': 1.0, |
|
'w0_fld': w0[M], |
|
'wa_fld': wa[M], |
|
'Omega_Lambda': 0.0, |
|
'gauge': gauge, |
|
'use_ppf': use_ppf |
|
}) |
|
|
|
|
|
cosmo[M].compute() |
|
|
|
|
|
colours = ['r', 'k', 'g', 'm'] |
|
plt.figure(figsize=(10, 6)) |
|
|
|
for i, M in enumerate(models): |
|
cl = cosmo[M].raw_cl() |
|
l = cl['ell'] |
|
|
|
|
|
plt.loglog(l, cl['tt'] * l * (l + 1) / (2. * np.pi), label=M, color=colours[i]) |
|
|
|
|
|
plt.legend(loc='upper left') |
|
plt.xlim([2, 300]) |
|
plt.ylim([6e-11, 1e-9]) |
|
plt.xlabel(r'$\ell$') |
|
plt.ylabel(r'$[\ell(\ell+1)/2\pi] C_\ell^\mathrm{TT}$') |
|
plt.title('CMB Power Spectrum for Different Models') |
|
|
|
|
|
plt.savefig('check_PPF_clTT.pdf') |
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
from classy import Class |
|
import matplotlib.pyplot as plt |
|
import numpy as np |
|
|
|
|
|
def compute_lensed_cls(params): |
|
cosmology = Class() |
|
cosmology.set(params) |
|
cosmology.compute() |
|
cls = cosmology.lensed_cl(2500) |
|
cosmology.struct_cleanup() |
|
return cls['ell'], cls['tt'], cls['ee'], cls['te'] |
|
|
|
|
|
params_massive_nu = { |
|
'omega_b': 0.0223828, |
|
'omega_cdm': 0.1201075, |
|
|
|
|
|
'h': 0.67810, |
|
'A_s': 2.100549e-09, |
|
'n_s': 0.9660499, |
|
'tau_reio': 0.05430842, |
|
'output': 'tCl,pCl,lCl,mPk', |
|
'lensing': 'yes', |
|
'P_k_max_1/Mpc': 3.0, |
|
'z_max_pk': 2.0, |
|
'YHe': 0.24 |
|
} |
|
|
|
|
|
params_ppf = { |
|
'omega_b': 0.0223828, |
|
'omega_cdm': 0.1201075, |
|
'w0_fld': -0.77, |
|
'wa_fld': -0.82, |
|
'Omega_Lambda': 0., |
|
'h': 0.67810, |
|
'A_s': 2.100549e-09, |
|
'n_s': 0.9660499, |
|
'tau_reio': 0.05430842, |
|
'output': 'tCl,pCl,lCl,mPk', |
|
'lensing': 'yes', |
|
'P_k_max_1/Mpc': 3.0, |
|
'z_max_pk': 2.0, |
|
'YHe': 0.24 |
|
} |
|
|
|
|
|
ell_massive_nu, clTT_massive_nu, clEE_massive_nu, clTE_massive_nu = compute_lensed_cls(params_massive_nu) |
|
ell_ppf, clTT_ppf, clEE_ppf, clTE_ppf = compute_lensed_cls(params_ppf) |
|
|
|
|
|
clEE_ratio = clEE_massive_nu / clEE_ppf |
|
clTT_ratio = clTT_massive_nu / clTT_ppf |
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
|
|
|
plt.subplot(2, 1, 1) |
|
plt.plot(ell_massive_nu, clEE_ratio * ell_massive_nu * (ell_massive_nu + 1) / (2 * np.pi), 'b-', label=r'$\frac{C_\ell^{EE}}{C_\ell^{EE}(\text{PPF})}$') |
|
plt.xscale('log') |
|
plt.yscale('log') |
|
plt.xlim(2, 2500) |
|
plt.xlabel(r'$\ell$') |
|
plt.ylabel(r'Ratio $[\ell(\ell+1)/2\pi] C_\ell^{EE}$') |
|
plt.title('Ratio of Lensed CMB Power Spectrum - EE Mode') |
|
plt.legend() |
|
|
|
|
|
plt.subplot(2, 1, 2) |
|
plt.plot(ell_massive_nu, clTT_ratio * ell_massive_nu * (ell_massive_nu + 1) / (2 * np.pi), 'r-', label=r'$\frac{C_\ell^{TT}}{C_\ell^{TT}(\text{PPF})}$') |
|
plt.xscale('log') |
|
plt.yscale('log') |
|
plt.xlim(2, 2500) |
|
plt.xlabel(r'$\ell$') |
|
plt.ylabel(r'Ratio $[\ell(\ell+1)/2\pi] C_\ell^{TT}$') |
|
plt.title('Ratio of Lensed CMB Power Spectrum - TT Mode') |
|
plt.legend() |
|
|
|
|
|
plt.tight_layout() |
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|