CAMB icon indicating copy to clipboard operation
CAMB copied to clipboard

P(k) at high k depends on value of WantCls

Open ahallcosmo opened this issue 9 months ago • 5 comments

The linear matter power spectrum at z=0 at very high k seems to depend on WantCls.

MWE:

import camb

kmax = 2000

H0=70.0
Omega_cdm0=0.25
Omega_b0=0.05
ns=0.96 
As=2e-9
mnu=0.06
h = H0/100

cp = camb.CAMBparams()

cp.WantCls = True

cp.set_cosmology(H0=H0, ombh2=Omega_b0*h**2, omch2=Omega_cdm0*h**2, mnu=mnu)
cp.InitPower.set_params(As=As, ns=ns)
cp.set_matter_power(redshifts=[0], kmax=kmax)
results = camb.get_results(cp)
k_T, _, Pk_T = results.get_linear_matter_power_spectrum()

cp = camb.model.CAMBparams()

cp.WantCls = False 

cp.set_cosmology(H0=H0, ombh2=Omega_b0*h**2, omch2=Omega_cdm0*h**2, mnu=mnu)
cp.InitPower.set_params(As=As, ns=ns)
cp.set_matter_power(redshifts=[0], kmax=kmax)
results = camb.get_results(cp)
k_F, _, Pk_F = results.get_linear_matter_power_spectrum()

import matplotlib.pyplot as plt

plt.loglog(k_T, Pk_T[0,:], label='WantCls=T')
plt.loglog(k_F, Pk_F[0,:], label='WantCls=F')

plt.xlim([1e1, 3000])
plt.xlabel(r'$k \, [{\rm Mpc}/h]^{-1}$', fontsize=16);
plt.ylabel(r'$P(k)\, [{\rm Mpc}/h]^{3}$', fontsize=16);
plt.legend(fontsize=16)
plt.savefig('Pk_WantCls_MWE.png')

Results in

Image

The k sampling in both cases seems to be basically the same. Do you know what might be causing this?

ahallcosmo avatar May 17 '25 10:05 ahallcosmo

It's something to do with reionization; if I set tau=0, both curves agree.

ahallcosmo avatar May 17 '25 10:05 ahallcosmo

Perhaps this is physical? Reionization boosting the baryon temperature, which increases the sound speed and hence the baryon Jeans scale. But that would suppress matter clustering at a fixed scale, not enhance it?

ahallcosmo avatar May 17 '25 11:05 ahallcosmo

Looks far too large to be physical, effect of (inaccurate linear) reion temp change is very small. (though this is crazy small scale, not sure I've looked much beyond 500) Not sure what it is though...

cmbant avatar May 17 '25 12:05 cmbant

Possibly forcing WantCls is causing minuscule time steps that are then numerically unstable?

cmbant avatar May 17 '25 12:05 cmbant

Could be; setting AccuracyBoost=3 causes dverk to return the error "unable to satisfy the error requirement with a particular step-size that is less than or equal to hmin, which may mean that tol is too small", which does suggest this regime is near the boundary of numerical stability. Obviously this has no practical consequences, I was just surprised that WantCls has any impact on P(k) at all.

ahallcosmo avatar May 17 '25 18:05 ahallcosmo

I think the difference comes from WantCl=F turning off reionization, so it really is just an effect of reionization on the growth via the sound speed. Obviously CAMB can't calculate reionization temperature/pressures reliably, but maybe what it is doing is a bit inconsistent as a baseline - i.e. it is using the non-reionization gas temperature (from recfast) but the ionization fraction including reionization (https://github.com/cmbant/CAMB/blob/master/fortran/results.f90#L1939). Changing these lines to use the ionization fraction without reionization I think removes the discrepancy - i.e. the sound speed is then exactly as it would have been without reionization (https://github.com/cmbant/CAMB/pull/180).

cmbant avatar Aug 22 '25 15:08 cmbant

As shown in PR (https://github.com/cmbant/CAMB/pull/180), looks like the sound speed was going negative, which is why the sign of the effect is different to what we expected.

cmbant avatar Aug 22 '25 15:08 cmbant

Hmm interesting! I guess it's because the matter temperature is going negative.

ahallcosmo avatar Aug 22 '25 16:08 ahallcosmo