Page 1 of 1

CAMB: Non Linear Matter Power Spectra

Posted: December 02 2019
by Marco M Bonici
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

Re: CAMB: Non Linear Matter Power Spectra

Posted: December 02 2019
by Antony Lewis
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.

Re: CAMB: Non Linear Matter Power Spectra

Posted: December 03 2019
by Marco M Bonici
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

Re: CAMB: Non Linear Matter Power Spectra

Posted: December 03 2019
by Antony Lewis
Check if you have non-linear lensing on there.

Re: CAMB: Non Linear Matter Power Spectra

Posted: December 03 2019
by Marco M Bonici
Dear Professor Lewis,
I have set do_nonlinear = 1 and now it works.
Thank you so much for your help!
Best Regards,
Marco Bonici

Re: CAMB: Non Linear Matter Power Spectra

Posted: December 04 2019
by Antony Lewis
The master branch on github should now also allow you to change k_per_logint when non-linear lensing is on.