CAMB: Non Linear Matter Power Spectra

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Marco M Bonici
Posts: 3
Joined: December 02 2019
Affiliation: Universita' Degli Studi di Genova

CAMB: Non Linear Matter Power Spectra

Post by Marco M Bonici » December 02 2019

Dear All,
I want to calculate the (uninterpolated) Non Linear Matter Power Spectrum using the python version of CAMB. In particular, have two issues:
1) I want to calculate the Power Spectrum for more redshift values than the 150 allowed by the program
2) I want to test my result for different values of k_per_logint.
I (think) I have solved the first issue dividing my z_redshift list in smaller list with less than 150 redshifts. For the second issue, I wrote this python code

Code: Select all

z_values = np.linspace(0.001, 2.5, 300)
z_list = np.split(z_values, 2)
camb_pars=camb.read_ini(os.path.join(camb_pars_path,'planck_2018.ini'))
pk_nonlin_list = []
z_nonlin_list = []
for z_bin in z_list:
    camb_pars.set_matter_power(redshifts=z_bin, kmax=4., k_per_logint=130, nonlinear=True, accurate_massive_neutrino_transfers=True)
    background_camb = camb.get_background(camb_pars)
    camb_pars.NonLinear = model.NonLinear_both
    background_camb.calc_power_spectra(camb_pars)
    kh_nonlin, z_nonlin_small, pk_nonlin_small = background_camb.get_nonlinear_matter_power_spectrum(params=camb_pars)
    pk_nonlin_list.append(pk_nonlin_small)
    z_nonlin_list.append(z_nonlin_small)
Anyway, when I change the value of k_per_logint and print out the length of kh_nonlin the answer is always the same.
So, I do not understand where is my mistake. Any hints?
Thank you all for your time,
Marco

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

Re: CAMB: Non Linear Matter Power Spectra

Post by Antony Lewis » December 02 2019

The reason is the model.NonLinear_both line, though I would agree that behaviour is unintuitive and maybe should be changed. I think you can just delete it it not calculating CMB power spectra.

You also don't need calc_power_spectra (or don't need to pass params to get_nonlinear_matter_power_spectrum) - currently calculating things twice.

Marco M Bonici
Posts: 3
Joined: December 02 2019
Affiliation: Universita' Degli Studi di Genova

Re: CAMB: Non Linear Matter Power Spectra

Post by Marco M Bonici » December 03 2019

Dear Professor Lewis,
Thank you for your answer. I commented the lines you suggested to remove, but the result doesn't change: the number of evaluated k is always the same.
Maybe the problem is in my .ini file? If you want, I could attach it here.
Thank you for your time,
Marco

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

Re: CAMB: Non Linear Matter Power Spectra

Post by Antony Lewis » December 03 2019

Check if you have non-linear lensing on there.

Marco M Bonici
Posts: 3
Joined: December 02 2019
Affiliation: Universita' Degli Studi di Genova

Re: CAMB: Non Linear Matter Power Spectra

Post by Marco M Bonici » December 03 2019

Dear Professor Lewis,
I have set do_nonlinear = 1 and now it works.
Thank you so much for your help!
Best Regards,
Marco Bonici

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

Re: CAMB: Non Linear Matter Power Spectra

Post by Antony Lewis » December 04 2019

The master branch on github should now also allow you to change k_per_logint when non-linear lensing is on.

Post Reply