Skip to content

[BUG] growth_rate, currently implemented following Hamilton (2001) eq. 4, is very far from the CAMB growth rate #198

@MinhMPA

Description

@MinhMPA

Describe the bug
Currently, growth_rate() in the growth model GrowthFactor implements the linear growth rate $f(a)$ following eq. 4 of Hamilton (2001). However, this particular eq. does not yield an accurate growth rate when compared to $d\ln D/d\ln a$ from CAMB and the growth model CambGrowth.

My suggestion, if I may, and I can make a PR for this, is to either a/ use Hamilton (2001) eq. 5 instead, or b/ simply $f(a)=\Omega_m(a)^\gamma$ where $\gamma=0.55$.

To Reproduce
Code snippet reproduce the behavior:

import matplotlib.pyplot as plt
%matplotlib inline

from hmf import MassFunction,Transfer

transfer_CambGrowth=Transfer(z=0.0, lnk_min=-18.420680743952367, lnk_max=9.903487552536127, dlnk=0.05, transfer_model='CAMB', transfer_params=None, takahashi=True, growth_model='CambGrowth', growth_params=None, use_splined_growth=True)
transfer_GrowthFactor=Transfer(z=0.0, lnk_min=-18.420680743952367, lnk_max=9.903487552536127, dlnk=0.05, transfer_model='CAMB', transfer_params=None, takahashi=True, growth_model='GrowthFactor', growth_params=None, use_splined_growth=True)

z=np.linspace(0.,100.,256)
a=1./(1.+z)
D_CambGrowth=transfer_CambGrowth.growth.growth_factor(z)
f_CambGrowth=np.gradient(np.log(D_CambGrowth),np.log(a))
f_GrowthFactor=transfer_GrowthFactor.growth.growth_rate(z)

fig, ax = plt.subplots(2, sharex=True, sharey=False, gridspec_kw={'hspace': 0., 'wspace':0., 'height_ratios':[8, 2]}, figsize=(6.4, 4.8))
ax[0].semilogx(a,f_GrowthFactor,c='b',ls='-',label=r'GrowthFactor, Hamilton Eq. (4)')
ax[0].semilogx(a,f_CambGrowth,c='r',ls='--',label=r'CambGrowth')
ax[0].legend(frameon=False)
ax[0].set_ylabel(r'$f(a)$')
#ax[0].set_ylim(0.65,1.)
ax[1].semilogx(a,f_GrowthFactor/f_CambGrowth)
ax[1].set_ylabel(r'$f_{\mathrm{GF}}/f_{\mathrm{CG}}$')
ax[1].set_xlabel(r'$a$')

Expected behavior
This is the comparison between either Hamilton eq. 4 or eq. 5, against the CAMB numerical derivative $d\ln D/d\lna$.

download-1

download

Additional context
This is related to, but not the same issue, #196.

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions