| |
| |
|
|
| |
|
|
|
|
| |
| |
| get_ipython().run_line_magic('matplotlib', 'inline') |
| import matplotlib |
| import matplotlib.pyplot as plt |
| import numpy as np |
| from classy import Class |
| from scipy.optimize import fsolve |
| import math |
|
|
|
|
| |
|
|
|
|
| |
| |
| |
| |
| var_name = 'N_ur' |
| var_array = np.linspace(3.044,5.044,5) |
| var_num = len(var_array) |
| var_legend = r'$N_\mathrm{eff}$' |
| var_figname = 'neff' |
| |
| |
| |
| |
| |
| |
| |
| |
| omega_b = 0.0223828 |
| omega_cdm_standard = 0.1201075 |
| h_standard = 0.67810 |
| |
| |
| |
| |
| |
| |
| |
| |
| coeff = 1.70961e-05/2.47298e-05/3.044 |
| print ("coeff=",coeff) |
| |
| |
| |
| |
| |
| common_settings = { |
| 'omega_b':omega_b, |
| '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} |
| |
| |
| |
| |
| |
| M = {} |
| |
| for i, N_ur in enumerate(var_array): |
| |
| |
| |
| alpha = (1.+coeff*N_ur)/(1.+coeff*3.044) |
| omega_cdm = (omega_b + omega_cdm_standard)*alpha - omega_b |
| h = h_standard*math.sqrt(alpha) |
| print (' * Compute with %s=%e, %s=%e, %s=%e'%('N_ur',N_ur,'omega_cdm',omega_cdm,'h',h)) |
| |
| |
| |
| M[i] = Class() |
| M[i].set(common_settings) |
| M[i].set(better_precision_settings) |
| M[i].set({'N_ur':N_ur}) |
| M[i].set({'omega_cdm':omega_cdm}) |
| M[i].set({'h':h}) |
| M[i].compute() |
|
|
|
|
| |
|
|
|
|
| |
| |
| |
| |
| |
| kvec = np.logspace(-4,np.log10(3),1000) |
| twopi = 2.*math.pi |
| |
| |
| |
| fig_Pk, ax_Pk = plt.subplots() |
| fig_TT, ax_TT = plt.subplots() |
| |
| |
| |
| ll = {} |
| clM = {} |
| clTT = {} |
| pkM = {} |
| legarray = [] |
|
|
| for i, N_ur in enumerate(var_array): |
| |
| alpha = (1.+coeff*N_ur)/(1.+coeff*3.044) |
| h = 0.67810*math.sqrt(alpha) |
| |
| |
| |
| if i == 0: |
| var_color = 'k' |
| var_alpha = 1. |
| else: |
| var_color = plt.cm.Reds(0.8*i/(var_num-1)) |
| |
| |
| |
| clM[i] = M[i].lensed_cl(2500) |
| ll[i] = clM[i]['ell'][2:] |
| clTT[i] = clM[i]['tt'][2:] |
| |
| |
| |
| pkM[i] = [] |
| |
| khvec = kvec*h |
| for kh in khvec: |
| pkM[i].append(M[i].pk(kh,0.)*h**3) |
| |
| |
| |
| if i == 0: |
| ax_Pk.semilogx(kvec,np.array(pkM[i])/np.array(pkM[0]), |
| color=var_color, |
| linestyle='-') |
| else: |
| ax_Pk.semilogx(kvec,np.array(pkM[i])/np.array(pkM[0]), |
| color=var_color, |
| linestyle='-', |
| label=r'$\Delta N_\mathrm{eff}=%g$'%(N_ur-3.044)) |
| |
| |
| |
| if i == 0: |
| ax_TT.semilogx(ll[i],clTT[i]/clTT[0], |
| color=var_color,alpha=var_alpha,linestyle='-') |
| else: |
| ax_TT.semilogx(ll[i],clTT[i]/clTT[0], |
| color=var_color,alpha=var_alpha,linestyle='-', |
| label=r'$\Delta N_\mathrm{eff}=%g$'%(N_ur-3.044)) |
| |
| |
| |
| ax_Pk.set_xlim([1.e-3,3.]) |
| ax_Pk.set_ylim([0.98,1.20]) |
| ax_Pk.set_xlabel(r'$k \,\,\,\, [h^{-1}\mathrm{Mpc}]$') |
| ax_Pk.set_ylabel(r'$P(k)/P(k)[N_\mathrm{eff}=3.046]$') |
| ax_Pk.legend(loc='upper left') |
| fig_Pk.tight_layout() |
| fig_Pk.savefig('ratio-%s-Pk.pdf' % var_figname) |
| |
| |
| |
| ax_TT.set_xlim([2,2500]) |
| ax_TT.set_ylim([0.850,1.005]) |
| ax_TT.set_xlabel(r'$\mathrm{Multipole} \,\,\,\, \ell$') |
| ax_TT.set_ylabel(r'$C_\ell^\mathrm{TT}/C_\ell^\mathrm{TT}(N_\mathrm{eff}=3.046)$') |
| ax_TT.legend(loc='lower left') |
| fig_TT.tight_layout() |
| fig_TT.savefig('ratio-%s-cltt.pdf' % var_figname) |
|
|
|
|