CAMB: CMB angular power spectra with MODIFIED primordial power spectrum

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Jia-Rui Li
Posts: 1
Joined: August 22 2022
Affiliation: University of Science and Technology of China

CAMB: CMB angular power spectra with MODIFIED primordial power spectrum

Post by Jia-Rui Li » August 22 2022

Hello, I'd like to get some help about CAMB, especially about class camb.initialpower.InitialPower(*args, **kwargs).
The python on my laptop is version 3.8.8 and CAMB 1.3.2.
I set a modified primordial tensor power spectrum, then get the corresponding tensor mode CMB power spectrum C_BB (unlensed).
I am puzzled with three things:
(1) Why the calculated C_BB is not consecutive but performs oscillation ?
(2) Why C_BB = 0.0 when ell is larger than 600 ?
(3) When I set lmax larger than 2400, Why the system will give warning: "WARNING:root:getting CMB power spectra to higher L than calculated, may be innacurate/zeroed."?
My code is as following:
Thanks a lot !
Sincerely.
<CODE><s>

Code: Select all

</s>import camb
import numpy
import math
import matplotlib.pyplot
%config InlineBackend.figure_format='svg'

m_start = 2
lmax = 2400 
num = 100000
log_k_min = -12
log_k_max = 12
As = 2.1e-9
ns = 0.965
r = 16*5.7e-9
kp = 0.05
nt = - r / 8.0 * (2.0 - ns - r / 8.0) #inflation consistency
log_k0 = math.log10(10**(-4))
log_k1 = log_k0+2
n1 = 2.84
n2 = -15.03

pars = camb.CAMBparams()
#from planck 2018: arxiv 1807.06209
pars.set_cosmology(H0=67.4, ombh2=0.0224, omch2=0.120, mnu=0.06, omk=0, tau=0.054)
ks = numpy.logspace(log_k_min, log_k_max, num)
log_ks = numpy.linspace(log_k_min, log_k_max, num)
pk_scalar = As*(ks/kp)**(ns-1)
initialpower = camb.initialpower.SplinedInitialPower()
initialpower.set_scalar_log_regular(10**(log_k_min), 10.**(log_k_max), pk_scalar)

def initial_tensor_power_spectrum(log_k, log_k0, log_k1, As, r, kp, nt, n1, n2):
    At = As*r
    log_A0 = math.log10(At)-nt*math.log10(kp)
    n0 = nt
    if log_k<log_k0:
        return log_A0+n0*log_k
    else:
        if log_k<log_k1:
            return log_A0+n0*log_k0+n1*(log_k-log_k0)
        else:
            if log_k<((n0-n1)*log_k0+(n1-n2)*log_k1)/(n0-n2):
                return log_A0+n0*log_k0+n1*(log_k1-log_k0)+n2*(log_k-log_k1)
            else:
                return log_A0+n0*log_k

pk_tensor = []

for i in range(0, num, 1):
    log_Pt = initial_tensor_power_spectrum(log_ks[i], log_k0=log_k0, log_k1=log_k1, As=As, r=r, kp=kp, nt=nt, n1=n1, n2=n2)
    pk_tensor.append(10**log_Pt)

initialpower.set_tensor_log_regular(10**(log_k_min), 10.**(log_k_max), pk_tensor)
pars.WantTensors = True
pars.set_initial_power(initialpower)
results = camb.get_results(pars)
powers = results.get_cmb_power_spectra(params=pars, 
	spectra=('total', 'unlensed_scalar', 'unlensed_total', 'lensed_scalar', 'tensor', 'lens_potential'), 
	CMB_unit='muK', lmax=lmax, raw_cl=False) 
powspect = powers['tensor'].T 
Dl = powspect[2, m_start:lmax]

ell = numpy.arange(m_start, lmax)

matplotlib.pyplot.loglog(ks, pk_tensor, color = 'red')
matplotlib.pyplot.xlim(10**(-6), 10**0)
matplotlib.pyplot.ylim(top=10**(-9))
matplotlib.pyplot.xlabel("$k\,[\mathrm{Mpc}^{-1}]$")
matplotlib.pyplot.ylabel("$\logP_T(k)$")
matplotlib.pyplot.show()

matplotlib.pyplot.loglog(ell, Dl, color = 'red')
matplotlib.pyplot.xlim(2, 1500)
matplotlib.pyplot.xlabel("$\ell$")
matplotlib.pyplot.ylabel("$\ell(\ell+1)C_\ell^{BB}/2\mathrm{\pi}[\mu K^2]$")
matplotlib.pyplot.show()<e>
</e></CODE></r>

Antony Lewis
Posts: 1812
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: CAMB: CMB angular power spectra with MODIFIED primordial power spectrum

Post by Antony Lewis » August 23 2022

You can set max_l_tensor for what tensor lmax to compute (usually negligible compared to lensing at high L).

You expect acoustic oscillations on sub-horizon scales if that's what you mean (+ reionization).

Use set_for_lmax to set maximum L computed.

Post Reply