# camb.model¶

class camb.model.CAMBparams[source]

Object storing the parameters for a CAMB calculation, including cosmological parameters and settings for what to calculate. When a new object is instantiated, default parameters are set automatically.

You can view the set of underlying parameters used by the Fortran code by printing the CAMBparams instance.

To add a new parameter, add it to the CAMBparams type in modules.f90, then edit the _fields_ list in the CAMBparams class in model.py to add the new parameter in the corresponding location of the member list. After rebuilding the python version you can then access the parameter by using params.new_parameter where params is a CAMBparams instance. You could also modify the wrapper functions to set the field value less directly.

N_eff()[source]
Returns: Effective number of degrees of freedom in relativistic species at early times.
copy()[source]

Make independent copy.

return: copy of self
get_DH(ombh2=None, delta_neff=None)[source]

Get deuterium ration D/H by intepolation using the bbn.BBNPredictor instance passed to model.CAMBparams.set_cosmology() (or the default one, if Y_He has not been set).

Parameters: ombh2 – $$\Omega_b h^2$$ (default: value passed to model.CAMBparams.set_cosmology()) delta_neff – additional $$N_{\rm eff}$$ relative to standard value (of 3.046) (default: from values passed to model.CAMBparams.set_cosmology()) BBN helium nucleon fraction D/H
get_Y_p(ombh2=None, delta_neff=None)[source]

Get BBN helium nucleon fraction (NOT the same as the mass fraction Y_He) by intepolation using the bbn.BBNPredictor instance passed to model.CAMBparams.set_cosmology() (or the default one, if Y_He has not been set).

Parameters: ombh2 – $$\Omega_b h^2$$ (default: value passed to model.CAMBparams.set_cosmology()) delta_neff – additional $$N_{\rm eff}$$ relative to standard value (of 3.046) (default: from values passed to model.CAMBparams.set_cosmology()) $$Y_p^{\rm BBN}$$ helium nucleon fraction predicted by BBN.
get_omega_k()[source]

Get curvature parameter $$\Omega_K$$

Returns: $$\Omega_K$$
set_accuracy(AccuracyBoost=1.0, lSampleBoost=1.0, lAccuracyBoost=1.0, HighAccuracyDefault=True, DoLateRadTruncation=True)[source]

Set parameters determining calculation accuracy (large values may give big slow down). Note curently these are set globally, not just per parameter set.

Parameters: AccuracyBoost – increase AccuracyBoost to decrease integration step size, increase density of k sampling, etc. lSampleBoost – increase lSampleBoost to increase density of L sampling for CMB lAccuracyBoost – increase lAccuracyBoost to increase the maximum L included in the Boltzmann hierarchies HighAccuracyDefault – True for Planck-level accuracy (False is WMAP) DoLateRadTruncation – If True, use approximation to radiation perturbation evolution at late times self
set_cosmology(H0=67.0, cosmomc_theta=None, ombh2=0.022, omch2=0.12, omk=0.0, neutrino_hierarchy='degenerate', num_massive_neutrinos=1, mnu=0.06, nnu=3.046, YHe=None, meffsterile=0.0, standard_neutrino_neff=3.046, TCMB=2.7255, tau=None, deltazrei=None, bbn_predictor=None, theta_H0_range=[10, 100])[source]

Sets cosmological parameters in terms of physical densities and parameters used in Planck 2015 analysis. Default settings give a single distinct neutrino mass eigenstate, by default one neutrino with mnu = 0.06eV. Set the neutrino_hierarchy parameter to normal or inverted to use a two-eigenstate model that is a good approximation to the known mass splittings seen in oscillation measurements. If you require more fine-grained control you can set the neutrino parameters directly rather than using this function.

Parameters: H0 – Hubble parameter (in km/s/Mpc) cosmomc_theta – The CosmoMC theta parameter. You must set H0=None to solve for H0 given cosmomc_theta. Note that you must have already set the dark energy model, you can’t use set_cosmology with cosmomc_theta and then change the background evolution (which would change cosmomc_theta at the calculated H0 value). ombh2 – physical density in baryons omch2 – physical density in cold dark matter omk – Omega_K curvature parameter neutrino_hierarchy – ‘degenerate’, ‘normal’, or ‘inverted’ (1 or 2 eigenstate approximation) num_massive_neutrinos – number of massive neutrinos (ignored unless hierarchy == ‘degenerate’) mnu – sum of neutrino masses (in eV) nnu – N_eff, effective relativistic degrees of freedom YHe – Helium mass fraction. If None, set from BBN consistency. meffsterile – effective mass of sterile neutrinos standard_neutrino_neff – default value for N_eff in standard cosmology (non-integer to allow for partial heating of neutrinos at electron-positron annihilation and QED effects) TCMB – CMB temperature (in Kelvin) tau – optical depth; if None, current Reion settings are not changed deltazrei – redshift width of reionization; if None, uses default bbn_predictor – bbn.BBNPredictor instance used to get YHe from BBN consistency if YHe is None theta_H0_range – if cosmomc_theta is specified, the min, max interval of H0 values to map to; outside this range it will raise an exception.
set_dark_energy(w=-1.0, sound_speed=1.0, dark_energy_model='fluid')[source]

Set dark energy parameters. Not that in this version these are not actually stored in the CAMBparams variable but set globally. So be careful!

Parameters: w – $$w\equiv p_{\rm de}/\rho_{\rm de}$$, assumed constant sound_speed – rest-frame sound speed of dark energy fluid dark_energy_model – model to use, default is ‘fluid’ self
set_for_lmax(lmax, max_eta_k=None, lens_potential_accuracy=0, lens_margin=150, k_eta_fac=2.5, lens_k_eta_reference=18000.0)[source]

Set parameters to get CMB power spectra accurate to specific a l_lmax. Note this does not fix the actual output L range, spectra may be calculated above l_max (but may not be accurate there). To fix the l_max for output arrays use the optional input argument to camb.CAMBdata.get_cmb_power_spectra() etc.

Parameters: lmax – $$\ell_{\rm max}$$ you want max_eta_k – maximum value of $$k \eta_0\approx k\chi_*$$ to use, which indirectly sets k_max. If None, sensible value set automatically. lens_potential_accuracy – Set to 1 or higher if you want to get the lensing potential accurate lens_margin – the $$\Delta \ell_{\rm max}$$ to use to ensure lensed $$C_\ell$$ are correct at $$\ell_{\rm max}$$ k_eta_fac – k_eta_fac default factor for setting max_eta_k = k_eta_fac*lmax if max_eta_k=None lens_k_eta_reference – value of max_eta_k to use when lens_potential_accuracy>0; use k_eta_max = lens_k_eta_reference*lens_potential_accuracy self
set_initial_power(initial_power_params)[source]

Set the InitialPower primordial power spectrum parameters

Parameters: initial_power_params – initialpower.InitialPowerParams instance self
set_matter_power(redshifts=[0.0], kmax=1.2, k_per_logint=None, nonlinear=None, accurate_massive_neutrino_transfers=False, silent=False)[source]

Set parameters for calculating matter power spectra and transfer functions.

Parameters: redshifts – array of redshifts to calculate kmax – maximum k to calculate k_per_logint – number of k steps per log k. Set to zero to use default optimized spacing. nonlinear – if None, uses existing setting, otherwise boolean for whether to use non-linear matter power. accurate_massive_neutrino_transfers – if you want the massive neutrino transfers accurately silent – if True, don’t give warnings about sort order self
set_nonlinear_lensing(nonlinear)[source]

Settings for whether or not to use non-linear corrections for the CMB lensing potential. Note that set_for_lmax also sets lensing to be non-linear if lens_potential_accuracy>0

Parameters: nonlinear – true to use non-linear corrections
validate()[source]

Do some quick tests for sanity

Returns: True if OK
class camb.model.TransferParams[source]

Object storing parameters for the matter power spectrum calculation. PK variables are for setting main outputs. Other entries are used internally, e.g. for sampling to get correct non-linear corrections and lensing.

Variables: high_precision – True for more accuracy kmax – k_max to output k_per_logint – number of points per log k interval. If zero, set an irregular optimized spacing. PK_num_redshifts – number of redshifts to calculate PK_redshifts – redshifts to output for the matter transfer and power