Skip to content

Commit

Permalink
fixed (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
damonge committed Jul 12, 2023
1 parent cb205af commit 0c1940a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 34 deletions.
10 changes: 0 additions & 10 deletions include/ccl_massfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ double ccl_dlnsigM_dlogM(ccl_cosmology *cosmo, double log_halomass, double a, in
*/
double dc_NakamuraSuto(ccl_cosmology *cosmo, double a, int *status);

/**
* Fitting function for virial collapse density contrast assuming LCDM.
* Density contrast is relative to background *matter* density, *not* critical density
* Fitting formula from Bryan & Norman (1998; arXiv:astro-ph/9710107)
* @param cosmo Cosmological parameters
* @param a, scale factor, normalized to a=1 today
* @param status Status flag. 0 if there are no errors, nonzero otherwise.
*/
double Dv_BryanNorman(ccl_cosmology *cosmo, double a, int *status);

CCL_END_DECLS

#endif
7 changes: 2 additions & 5 deletions pyccl/halos/hmfunc/despali16.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ def _get_fsigma(self, cosmo, sigM, a, lnM):
delta_c, status = lib.dc_NakamuraSuto(cosmo.cosmo, a, status)
check(status, cosmo=cosmo)

Dv, status = lib.Dv_BryanNorman(cosmo.cosmo, a, status)
check(status, cosmo=cosmo)

x = np.log10(self.mass_def.get_Delta(cosmo, a) *
cosmo.omega_x(a, self.mass_def.rho_type) / Dv)
Dv = self.mass_def.get_Delta_vir(cosmo, a)
x = np.log10(self.mass_def.get_Delta(cosmo, a) / Dv)

A, a, p = self.poly_A(x), self.poly_a(x), self.poly_p(x)

Expand Down
27 changes: 24 additions & 3 deletions pyccl/halos/massdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,29 @@ def name(self):
def __repr__(self):
return f"MassDef(Delta={self.Delta}, rho_type={self.rho_type})"

def get_Delta_vir(self, cosmo, a):
""" Computes the virial collapse density contrast with respect
to the critical density assuming a :math:`\\Lambda` CDM model. We
use the fitting function from
`Bryan and Norman 1998 <https://arxiv.org/abs/astro-ph/9710107>`_.
The virial overdensity is returned for the density type of this
object's mass definition (e.g. 'critical' or 'matter').
Args:
cosmo (:class:`~pyccl.cosmology.Cosmology`): A Cosmology object.
a (:obj:`float`): scale factor
Returns:
:obj:`float`: value of the virial overdensity.
"""
Omz = cosmo.omega_x(a, 'matter')
x = Omz-1
# Eq. 6
Dv = 18*np.pi**2+82*x-39*x**2
if self.rho_type == 'matter':
Dv /= Omz
return Dv

def get_Delta(self, cosmo, a):
""" Gets overdensity parameter associated to this mass
definition.
Expand All @@ -133,9 +156,7 @@ def get_Delta(self, cosmo, a):
raise ValueError("FoF masses don't have an associated overdensity."
"Nor can they be translated into other masses")
if self.Delta == 'vir':
status = 0
D, status = lib.Dv_BryanNorman(cosmo.cosmo, a, status)
return D
return self.get_Delta_vir(cosmo, a)
return self.Delta

def _get_Delta_m(self, cosmo, a):
Expand Down
16 changes: 0 additions & 16 deletions src/ccl_massfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@ double dc_NakamuraSuto(ccl_cosmology *cosmo, double a, int *status){

}

/*----- ROUTINE: Dv_BryanNorman -----
INPUT: cosmology, scale factor
TASK: Computes the virial collapse density contrast with respect to the matter density assuming LCDM.
Cosmology dependence of the virial collapse density according to the spherical-collapse model
Fitting function from Bryan & Norman (1998; arXiv:astro-ph/9710107)
*/
double Dv_BryanNorman(ccl_cosmology *cosmo, double a, int *status){

double Om_mz = ccl_omega_x(cosmo, a, ccl_species_m_label, status);
double x = Om_mz-1.;
double Dv0 = 18.*pow(M_PI,2);
double Dv = (Dv0+82.*x-39.*pow(x,2))/Om_mz;

return Dv;
}

static double sigmaM_m2r(ccl_cosmology *cosmo, double halomass, int *status)
{
double rho_m, smooth_radius;
Expand Down

0 comments on commit 0c1940a

Please sign in to comment.