LSSTDESC / CCL

DESC Core Cosmology Library: cosmology routines with validated numerical accuracy
BSD 3-Clause "New" or "Revised" License
145 stars 68 forks source link

Cosmoogy: CAMB with Neff=0 does not complain... #937

Closed jecampagne closed 1 year ago

jecampagne commented 2 years ago

Hi, I report a possible problem that can be avoided by making a more restrictive parameters x-check:

If you run this small snippet

cosmo_ccl = ccl.Cosmology(
    Omega_c=0.3, Omega_b=0.05, 
    h=0.7, A_s=1.58e-9, n_s=0.96,
    transfer_function='boltzmann_class', matter_power_spectrum='halofit')

sigma8=cosmo_ccl.sigma8()
print(sigma8)

cosmo_ccl = ccl.Cosmology(
    Omega_c=0.3, Omega_b=0.05, 
    h=0.7, A_s=1.58e-9, n_s=0.96,
    transfer_function='boltzmann_camb', matter_power_spectrum='halofit')

sigma8 = cosmo_ccl.sigma8()
print(sigma8)

cosmo_ccl = ccl.Cosmology(
    Omega_c=0.3, Omega_b=0.05, 
    h=0.7, A_s=1.58e-9, n_s=0.96, Neff=0,
    transfer_function='boltzmann_camb', matter_power_spectrum='halofit')

sigma8=cosmo_ccl.sigma8()
print(sigma8)

cosmo_ccl = ccl.Cosmology(
    Omega_c=0.3, Omega_b=0.05, 
    h=0.7, A_s=1.58e-9, n_s=0.96, Neff=0,
    transfer_function='boltzmann_class', matter_power_spectrum='halofit')

sigma8=cosmo_ccl.sigma8()

you will get

0.8005284561523333            # class sigma8
0.8005634892329894           # camb sigma8
1.083442499820305              # camb sigma8 if user set wrongly Neff=0

ans a crash if you use Neff=0 with Class: with this message

Error in Class: thermodynamics_init(L:344) :error in thermodynamics_helium_from_bbn(ppr,pba,pth);
=>thermodynamics_helium_from_bbn(L:620) :condition (DeltaNeff < deltaN[0]) is true; You have asked for an unrealistic small value of Delta N_eff = -3.046000e+00. The corresponding value of the primordial helium fraction cannot be found in the interpolation table. If you really want this value, you should fix YHe to a given value rather than to BBN

I am pretty sure that CAMB may also complain with the user wrongly setting Neff=0, but I think CCL can help the user with an ERROR raising.

nikfilippas commented 2 years ago

CLASS apparently only fails because the He fraction is out of the internal interpolator's bounds for this extreme value of Neff. It's not like it's doing a check to see whether Neff makes sense. I had a go at CAMB and it looks like it also works with negative values of Neff.

I think this is a clear case of Garbage-In-Garbage-Out. If users really want to put in such extreme values of Neff they should be free to do so. We have too many neutrino consistency warnings anyway (see #766 ).

damonge commented 2 years ago

To me this looks more like a boltzmann solver issue than a CCL issue. I'll leave it open a bit longer for others to chime in (@c-d-leonard ?) and will then close