Skip to content

Commit

Permalink
add optional nonlinear parameter to set_for_lmax
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Apr 22, 2022
1 parent 7e3fe99 commit 241c37d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions camb/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def set_nonlinear_lensing(self, nonlinear):
self.NonLinear = NonLinear_none

def set_for_lmax(self, lmax, max_eta_k=None, lens_potential_accuracy=0,
lens_margin=150, k_eta_fac=2.5, lens_k_eta_reference=18000.0):
lens_margin=150, k_eta_fac=2.5, lens_k_eta_reference=18000.0, nonlinear=None):
r"""
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
Expand All @@ -730,6 +730,8 @@ def set_for_lmax(self, lmax, max_eta_k=None, lens_potential_accuracy=0,
:param k_eta_fac: k_eta_fac default factor for setting max_eta_k = k_eta_fac*lmax if max_eta_k=None
:param 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
:param nonlinear: use non-linear power spectrum; if None, sets nonlinear if lens_potential_accuracy>0 otherwise
preserves current setting
:return: self
"""
if self.DoLensing:
Expand All @@ -738,8 +740,10 @@ def set_for_lmax(self, lmax, max_eta_k=None, lens_potential_accuracy=0,
self.max_l = lmax
self.max_eta_k = max_eta_k or self.max_l * k_eta_fac
if lens_potential_accuracy:
self.set_nonlinear_lensing(True)
self.set_nonlinear_lensing(nonlinear is not False)
self.max_eta_k = max(self.max_eta_k, lens_k_eta_reference * lens_potential_accuracy)
elif nonlinear is not None:
self.set_nonlinear_lensing(nonlinear)
return self

def scalar_power(self, k):
Expand Down

0 comments on commit 241c37d

Please sign in to comment.