LSSTDESC / CCL

DESC Core Cosmology Library: cosmology routines with validated numerical accuracy
BSD 3-Clause "New" or "Revised" License
145 stars 68 forks source link

A question regarding M_vir mass definition within CCL #1067

Closed dwhan89 closed 1 year ago

dwhan89 commented 1 year ago

I have a quick question about the mass definition used in the pyccl library.

While calculating the virial radius of halos using the pyccl.halos.massdef.MassDefVir object, I found that the overdensity parameter Delta has an extra factor of 1/Omega_m compared to the standard definition (See https://github.com/LSSTDESC/CCL/blob/master/pyccl/halos/massdef.py#L140 and https://github.com/LSSTDESC/CCL/blob/master/src/ccl_massfunc.c#L41.).

I checked whether the library uses rho_m in the mass definition (i.e such that Delta/omega_m * rho_m = Delta*rho_crit), but it doesn't seem like it at a glance (https://github.com/LSSTDESC/CCL/blob/master/pyccl/halos/massdef.py#L282). I'm wondering if you could help me understand why there's a difference and whether I'm missing something simple.

nikfilippas commented 1 year ago

I think the difference is there because we define MassDefVir in terms of the critical density, which multiplies Delta in the radius calculation, as seen here.

You may wish to define your own MassDef("vir", "matter"), which recovers that extra 1/Omega_m factor:

cosmo = ccl.CosmologyVanillaLCDM()
print(ccl.halos.MassDefVir().get_radius(cosmo, M=1e14, a=1) / cosmo["Omega_m"]**(1/3))
print(ccl.halos.MassDef("vir", "matter").get_radius(cosmo, M=1e14, a=1))

1.2373782561528808
1.2373782561528808
damonge commented 1 year ago

@dwhan89 I think you're right, this is definitely a bug. We should either remove the Om factor from here, or use 'critical' here.

I think the former (i.e. fixing the C code) is the only proper way of doing this.