aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic/clusters/cosmology.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-01-08 18:50:40 +0800
committerAaron LI <aly@aaronly.me>2017-06-01 16:33:39 +0800
commit3816f93f46e42bb277b076b63b353aba2026e371 (patch)
tree4f980a7e864bc41be9ce031bb22c0cf54af7e390 /fg21sim/extragalactic/clusters/cosmology.py
parentcea0bf6d84e10619d2604de7a14066abf17ad32d (diff)
downloadfg21sim-3816f93f46e42bb277b076b63b353aba2026e371.tar.bz2
Update to use custom units.py instead of astropy's
Also fix a parameter error in "formation.py"
Diffstat (limited to 'fg21sim/extragalactic/clusters/cosmology.py')
-rw-r--r--fg21sim/extragalactic/clusters/cosmology.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/fg21sim/extragalactic/clusters/cosmology.py b/fg21sim/extragalactic/clusters/cosmology.py
index 4d65cdc..54fa306 100644
--- a/fg21sim/extragalactic/clusters/cosmology.py
+++ b/fg21sim/extragalactic/clusters/cosmology.py
@@ -7,9 +7,10 @@ Flat ΛCDM cosmological model.
import numpy as np
from scipy import integrate
-import astropy.units as au
from astropy.cosmology import FlatLambdaCDM
+from .units import (UnitConversions as AUC, Constants as AC)
+
class Cosmology:
"""
@@ -57,9 +58,10 @@ class Cosmology:
Mass contained in a sphere of radius of 8 h^-1 Mpc.
Unit: [Msun]
"""
- r = 8 * au.Mpc.to(au.cm) / self.h # [cm]
- M8 = (4*np.pi/3) * r**3 * self.rho_crit(0)
- return (M8 * au.g.to(au.solMass))
+ r = 8 * AUC.Mpc2cm / self.h # [cm]
+ M8 = (4*np.pi/3) * r**3 * self.rho_crit(0) # [g]
+ M8 *= AUC.g2Msun # [Msun]
+ return M8
def E(self, z):
"""
@@ -79,8 +81,7 @@ class Cosmology:
Hubble time.
Unit: [Gyr]
"""
- # uconv = au.Mpc.to(au.km) * au.s.to(au.Gyr)
- uconv = 977.7922216731284
+ uconv = AUC.Mpc2km * AUC.s2Gyr
t_H = (1.0/self.H0) * uconv # [Gyr]
return t_H
@@ -143,11 +144,8 @@ class Cosmology:
Critical density at redshift z.
Unit: [g/cm^3]
"""
- G = 6.67384e-08 # [cm^3/g/s^2]
- rho = 3 * self.H(z)**2 / (8*np.pi * G)
- # uconv = au.km.to(au.Mpc)**2
- uconv = 1.0502650403056094e-39
- rho *= uconv
+ rho = 3 * self.H(z)**2 / (8*np.pi * AC.G)
+ rho *= AUC.km2Mpc**2
return rho
def Om(self, z):