Non-linear models
- class camb.nonlinear.NonLinearModel(*args, **kwargs)[source]
Abstract base class for non-linear correction models.
- Variables:
Min_kh_nonlinear – (float64) minimum k/h at which to apply non-linear corrections
- class camb.nonlinear.Halofit(*args, **kwargs)[source]
Bases:
NonLinearModelVarious specific approximate non-linear correction models based on HaloFit.
- Variables:
halofit_version – (integer/string, one of: original, bird, peacock, takahashi, mead, halomodel, casarini, mead2015, mead2016, mead2020, mead2020_feedback)
HMCode_A_baryon – (float64) HMcode parameter A_baryon
HMCode_eta_baryon – (float64) HMcode parameter eta_baryon
HMCode_logT_AGN – (float64) HMcode parameter log10(T_AGN/K)
- set_params(halofit_version='mead2020', HMCode_A_baryon=3.13, HMCode_eta_baryon=0.603, HMCode_logT_AGN=7.8)[source]
Set the halofit model for non-linear corrections.
- Parameters:
halofit_version –
One of
original: astro-ph/0207664
bird: arXiv:1109.4416
peacock: Peacock fit
takahashi: arXiv:1208.2701
mead: HMCode arXiv:1602.02154
halomodel: basic halomodel
casarini: PKequal arXiv:0810.0190, arXiv:1601.07230
mead2015: original 2015 version of HMCode arXiv:1505.07833
mead2016: Alias for ‘mead’.
mead2020: 2020 version of HMcode arXiv:2009.01858
mead2020_feedback: 2020 version of HMcode with baryonic feedback arXiv:2009.01858
HMCode_A_baryon – HMcode parameter A_baryon. Default 3.13. Used only in models mead2015 and mead2016 (and its alias mead).
HMCode_eta_baryon – HMcode parameter eta_baryon. Default 0.603. Used only in mead2015 and mead2016 (and its alias mead).
HMCode_logT_AGN – HMcode parameter logT_AGN. Default 7.8. Used only in model mead2020_feedback.
- class camb.nonlinear.ExternalNonLinearRatio(*args, **kwargs)[source]
Bases:
NonLinearModelNon-linear model that applies a user-supplied ratio
sqrt(P_NL/P_L)from an external source, for example CCL or axionHMcode.Use
set_ratio()to provide the ratio grid, then assign the instance toparams.NonLinearModelbefore callingcamb.get_results(). This can also be used after computing time transfers, so lensedC_lvalues are generated with a consistent external non-linear prescription. Requestedk_horzvalues outside the supplied grid are clamped to the nearest grid boundary.- set_ratio(k_h, z, ratio)[source]
Set the non-linear ratio grid sqrt(P_NL/P_L).
- Parameters:
k_h – 1D array of k values in h/Mpc units (ascending)
z – 1D array of redshift values (ascending)
ratio – 2D array of sqrt(P_NL/P_L), shape (len(z), len(k_h)), matching the convention of CAMB’s get_matter_power_spectrum. Values requested outside the supplied grid are clamped to the nearest tabulated boundary.
- class camb.nonlinear.SecondOrderPK(*args, **kwargs)[source]
Bases:
NonLinearModelThird-order Newtonian perturbation theory results for the non-linear correction. Only intended for use at very high redshift (z>10) where corrections are perturbative, it will not give sensible results at low redshift.
See Appendix F of astro-ph/0702600 for equations and references.
Not intended for production use, it’s mainly to serve as an example alternative non-linear model implementation.
SP(k) model
The SPkNonLinear model wraps a base non-linear prescription (Halofit by
default) and applies SP(k) baryon suppression multiplicatively.
See SP(k) baryon suppression model for calibrated validity domain, boundary behavior, and MCMC/Cobaya usage guidance.
- class camb.nonlinear.SPkNonLinear(*args, **kwargs)[source]
Bases:
NonLinearModelSP(k) baryon suppression model applied on top of a base non-linear model.
- Variables:
BaseModel –
camb.nonlinear.NonLinearModelSPk_feedback – (boolean) Enable SP(k) suppression
SPk_SO – (integer) SP(k) spherical overdensity (200 or 500)
SPk_relation_kind – (integer) SP(k) relation kind: 1=power_law, 2=cosmo_power_law, 3=double_power_law
SPk_fb_a – (float64) Power-law relation normalization
SPk_fb_pow – (float64) Power-law relation exponent
SPk_fb_pivot – (float64) Power-law relation pivot mass [M_sun]
SPk_alpha – (float64) Relation alpha parameter (kinds 2/3)
SPk_beta – (float64) Relation beta parameter (kinds 2/3)
SPk_gamma – (float64) Relation gamma parameter (kinds 2/3)
SPk_epsilon – (float64) Relation epsilon parameter (kind 3)
SPk_m_pivot – (float64) Relation pivot mass [M_sun] (kind 3)
- set_params(SPk_feedback=False, SPk_SO=200, SPk_relation_kind=1, SPk_fb_a=1.0, SPk_fb_pow=0.0, SPk_fb_pivot=1.0, SPk_alpha=0.0, SPk_beta=0.0, SPk_gamma=0.0, SPk_epsilon=0.0, SPk_m_pivot=1.0, halofit_version='mead2020', HMCode_A_baryon=3.13, HMCode_eta_baryon=0.603, HMCode_logT_AGN=7.8)[source]
Configure the SP(k) baryon suppression model.
- References:
SP(k) model: MNRAS 523, 2247 (2023)
The base model is evaluated first (Halofit by default), then SP(k) suppression is applied to CAMB’s non-linear ratio as:
sqrt(P_NL/P_L) -> sqrt(P_NL/P_L) * sqrt(SPk_suppression)SP(k) relation kinds:
kind=1 (power_law):
f_b / (Omega_b/Omega_m) = SPk_fb_a * (M / SPk_fb_pivot)^SPk_fb_powkind=2 (cosmo_power_law):
f_b / (Omega_b/Omega_m) = (exp(SPk_alpha)/100) * (M_500c/1e14)^(SPk_beta - 1) * (E(z)/E(0.3))^SPk_gammakind=3 (double_power_law):
f_b / (Omega_b/Omega_m) = 0.5 * SPk_epsilon * ((M/SPk_m_pivot)^SPk_alpha + (M/SPk_m_pivot)^SPk_beta) * (E(z)/E(0.3))^SPk_gamma
- Parameters:
SPk_feedback – If True, apply SP(k) suppression on top of the base model.
SPk_SO – Spherical overdensity calibration (200 or 500).
SPk_relation_kind – Relation type: 1 (power_law), 2 (cosmo_power_law), 3 (double_power_law).
SPk_fb_a – Power-law normalization (kind=1).
SPk_fb_pow – Power-law exponent (kind=1).
SPk_fb_pivot – Power-law pivot mass in M_sun (kind=1).
SPk_alpha – Alpha parameter (kinds 2, 3).
SPk_beta – Beta parameter (kinds 2, 3).
SPk_gamma – Gamma parameter (kinds 2, 3).
SPk_epsilon – Epsilon parameter (kind=3).
SPk_m_pivot – Pivot mass in M_sun (kind=3).
halofit_version – Base Halofit version for the wrapped non-linear model.
HMCode_A_baryon – HMcode A_baryon parameter (mead2015/2016 only). Default 3.13.
HMCode_eta_baryon – HMcode eta_baryon parameter (mead2015/2016 only). Default 0.603.
HMCode_logT_AGN – HMcode log10(T_AGN/K) parameter (mead2020_feedback only). Default 7.8.
- Returns:
Self, for fluent configuration.
- Raises:
CAMBValueError – If parameters are invalid or incompatible with the base model.
Cobaya usage:
Cobaya passes keys from
extra_argsdirectly toset_params(). Parameters under the theoryparams:block are also forwarded and can be sampled.extra_args (fixed):
non_linear_model,halofit_version,SPk_feedback,SPk_SO,SPk_relation_kind, and pivot masses.params (sampled): continuous relation parameters (e.g.
SPk_fb_a,SPk_fb_pow).
Example YAML (kind=3, double_power_law):
params: SPk_epsilon: prior: {min: 0.24, max: 0.35} ref: {dist: norm, loc: 0.30, scale: 0.02} SPk_alpha: prior: {min: -0.12, max: 0.34} SPk_beta: prior: {min: -0.74, max: 0.77} SPk_gamma: prior: {min: -0.5, max: 1.20} log10_SPk_m_pivot: prior: {min: 13, max: 14} drop: true SPk_m_pivot: value: "lambda log10_SPk_m_pivot: 10**log10_SPk_m_pivot" theory: camb: extra_args: non_linear_model: SPkNonLinear halofit_version: mead2020 SPk_feedback: true SPk_SO: 200 SPk_relation_kind: 3
Boundary behavior:
z outside [0, 3]: no suppression applied (identity).
k > 12 h/Mpc: suppression clamped to value at k = 12 (saturates).
f_b outside calibrated limits:
nonlin_ratioset to NaN.
NaN propagates through
get_matter_power_interpolator()(Cobaya rejects the sample). Set priors to keep f_b in range.Warning
get_matter_power_spectrum()does not preserve NaN — useget_linear_matter_power_spectrum()withnonlinear=Trueto inspect which (z, k) cells are invalid.Cannot be combined with
halofit_version='mead2020_feedback'.