CAMB: Getting the power spectrum for isocurvature perturbations for dark matter

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Ian DSouza
Posts: 3
Joined: September 27 2023
Affiliation: University of Canterbury

CAMB: Getting the power spectrum for isocurvature perturbations for dark matter

I am trying to get the power spectrum for isocurvature perturbations for dark matter for redshift $z=1$ using CAMB. I have the following code:

Code: Select all

import numpy as np
import camb
from camb import model, initialpower
import matplotlib.pyplot as plt

# Set up the CAMB parameters
pars = camb.CAMBparams()

# Set cosmological parameters
pars.set_cosmology(H0=67.7, ombh2=0.022447, omch2=0.11928, mnu=0.06, omk=0, tau=0.0568)

# Indicate we want scalar perturbations
pars.WantScalars = True
pars.WantTensors = False
pars.WantVectors = False
pars.DoLensing = True

# Set the initial power spectrum parameters
pars.InitPower.set_params(As=2e-9, ns=0.9682)

# Adjust the InitialCondition and InitialConditionVector
pars.InitialCondition = 2
pars.InitialConditionVector = [0, 1]

# Set the desired redshift
redshifts = np.array([1])
pars.set_matter_power(redshifts=redshifts, kmax=5)

# Calculate results for these parameters
results = camb.get_results(pars)

# Get the matter power spectrum at the desired redshift: P(k,z)
kmin = 1e-4
kmax = 5
nk = 1000
k = np.logspace(np.log10(kmin), np.log10(kmax), nk)
ks_isocurvature, zs_isocurvature, pk_isocurvature  = results.get_matter_power_spectrum(minkh=kmin, maxkh=kmax, npoints=nk)
pk_isocurvature = pk_isocurvature.T

plt.rcParams["mathtext.fontset"] = "cm"
# Plot
for i , z in enumerate(zs_isocurvature):
plt.loglog(ks_isocurvature, pk_isocurvature[:,i], label=f"Isocurvature mode")
However, I get the same power spectrum as that for adiabatic perturbations for dark matter. Could someone help me modify this code to get only the isocurvature contribution.
Last edited by Ian DSouza on May 23 2024, edited 1 time in total.
Antony Lewis
Posts: 1970
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: CAMB: Getting the power spectrum for isocurvature perturbations for dark matter

I think you want to set pars.scalar_initial_condition = initial_iso_CDM
Ian DSouza
Posts: 3
Joined: September 27 2023
Affiliation: University of Canterbury

Re: CAMB: Getting the power spectrum for isocurvature perturbations for dark matter

Thanks, that seemed to change the power spectrum.