lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
230 stars 285 forks source link

HMcode not parallelising #334

Open JesusTorrado opened 4 years ago

JesusTorrado commented 4 years ago

Hi,

I think I have discovered what was causing CLASS to run so slowly with Cobaya, while investigating this issue: HMcode does not run in parallel!

To test it, I run the script below with some CPU monitor with a small polling interval (~0.1 sec)

from classy import Class
params = {
    'A_s': 2.109130215683372e-09, 'n_s': 0.9657995316557386,
    '100*theta_s': 1.042277663569975, 'omega_b': 0.022321567432474026,
    'omega_cdm': 0.11959205216595394, 'm_ncdm': 0.06,
    'tau_reio': 0.05399555600351819, 'N_ncdm': 1, 'N_ur': 2.0328,
    'output': 'pCl lCl tCl mPk', 'lensing': 'yes', 'l_max_scalars': 2508,
    'P_k_max_1/Mpc': 1,
    # HMCODE PARAMS
    'non linear': 'hmcode', 'hmcode_min_k_max': 20,
    # DEBUG PARAMS
    'input_verbose': 1, 'background_verbose': 1, 'thermodynamics_verbose': 1,
    'perturbations_verbose': 1, 'transfer_verbose': 1, 'primordial_verbose': 1,
    'spectra_verbose': 1, 'nonlinear_verbose': 1, 'lensing_verbose': 1,
    'output_verbose': 1}
cosmo = Class()
cosmo.set(params)
cosmo.compute()

CLASS stops running in parallel between printing

Computing non-linear matter power spectrum with HMcode

and printing

Computing transfers

Also, there is this HMcode warning (I guess it's fine for CMB lensing)

 -> [WARNING:] Non-linear corrections could not be computed at redshift z= 4.71 and higher.
    This is because k_max is too small for the algorithm (Halofit or HMcode) to be able to compute the scale k_NL at this redshift.
    If non-linear corrections at such high redshift really matter for you,
    just try to increase one of the parameters P_k_max_h/Mpc or P_k_max_1/Mpc or halofit_min_k_max (the code will take the max of these parameters) until reaching desired z.