aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic/clusters
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-01-08 19:17:38 +0800
committerAaron LI <aly@aaronly.me>2017-06-01 16:33:39 +0800
commitb2fcd6845837a46f4774b6deb6e025010941a1e7 (patch)
tree91e4966b773b64ebaab654e763cf51a34804ac96 /fg21sim/extragalactic/clusters
parent3816f93f46e42bb277b076b63b353aba2026e371 (diff)
downloadfg21sim-b2fcd6845837a46f4774b6deb6e025010941a1e7.tar.bz2
cosmology.py: Optimize the speed of overdensity_crit()
Diffstat (limited to 'fg21sim/extragalactic/clusters')
-rw-r--r--fg21sim/extragalactic/clusters/cosmology.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/fg21sim/extragalactic/clusters/cosmology.py b/fg21sim/extragalactic/clusters/cosmology.py
index 54fa306..12e581a 100644
--- a/fg21sim/extragalactic/clusters/cosmology.py
+++ b/fg21sim/extragalactic/clusters/cosmology.py
@@ -181,7 +181,7 @@ class Cosmology:
Appendix.A, Eq.(A1)
"""
coef = 3 * (12*np.pi) ** (2/3) / 20
- D0 = self.growth_factor(0)
+ D0 = self.growth_factor0
D_z = self.growth_factor(z)
Om_z = self.Om(z)
delta_c = coef * (D0 / D_z) * (1 + 0.0123*np.log10(Om_z))
@@ -201,6 +201,15 @@ class Cosmology:
x = x0 / (1 + z)
coef = np.sqrt(x**3 + 2) / (x**1.5)
integral = integrate.quad(lambda y: y**1.5 * (y**3+2)**(-1.5),
- a=0, b=x)[0]
+ a=0, b=x, epsabs=1e-5, epsrel=1e-5)[0]
D = coef * integral
return D
+
+ @property
+ def growth_factor0(self):
+ """
+ Present-day (z=0) growth factor.
+ """
+ if not hasattr(self, "_growth_factor0"):
+ self._growth_factor0 = self.growth_factor(0)
+ return self._growth_factor0