diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-01-07 14:22:20 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-06-01 16:33:37 +0800 |
commit | ae919983f3d161c3e28f3122cdedb9718782cbe1 (patch) | |
tree | 0626cc55f2d608cd697e15d3c81cc09bb34260ea | |
parent | 0f96a02aaaffff1eb0a17066bd9728fca008829b (diff) | |
download | fg21sim-ae919983f3d161c3e28f3122cdedb9718782cbe1.tar.bz2 |
cosmology.py: Change name to "Cosmology"; Add "age0" and "Ob0"
-rw-r--r-- | fg21sim/extragalactic/clusters/cosmology.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/fg21sim/extragalactic/clusters/cosmology.py b/fg21sim/extragalactic/clusters/cosmology.py index a66ff66..bedb17e 100644 --- a/fg21sim/extragalactic/clusters/cosmology.py +++ b/fg21sim/extragalactic/clusters/cosmology.py @@ -16,7 +16,7 @@ from astropy.cosmology import LambdaCDM, z_at_value logger = logging.getLogger(__name__) -class Cosmo: +class Cosmology: """ Cosmological model. @@ -34,17 +34,23 @@ class Cosmo: * closed : Om0 > 1, Ode0 = 0 * EdS (Einstein-de Sitter) : Om0 = 1, Ode0 = 0 * flatLambdaCDM : Om0 + Ode0 = 1, Ode0 > 0 + + References + ---------- + [1] https://astro.uni-bonn.de/~pavel/WIKIPEDIA/Lambda-CDM_model.html + [2] https://en.wikipedia.org/wiki/Lambda-CDM_model """ - def __init__(self, H0=71.0, Om0=0.27, Ode0=None, sigma8=None): + def __init__(self, H0=71.0, Om0=0.27, Ob0=0.046, Ode0=None, sigma8=None): Ode0 = 1.0 - Om0 if Ode0 is None else Ode0 if (Ode0 > 0) and abs(Om0 + Ode0 - 1) > 1e-5: raise ValueError("non-flat LambdaCDM model not supported!") self.H0 = H0 # [km/s/Mpc] self.Om0 = Om0 + self.Ob0 = Ob0 self.Ode0 = Ode0 self._sigma8 = sigma8 - self.cosmo = LambdaCDM(H0=H0, Om0=Om0, Ode0=Ode0) + self.cosmo = LambdaCDM(H0=H0, Om0=Om0, Ob0=Ob0, Ode0=Ode0) logger.info("Cosmological model: {0}".format(self.model)) @property @@ -120,6 +126,15 @@ class Cosmo: """ return self.cosmo.age(z).value + @property + def age0(self): + """ + Present age of the universe. + """ + if not hasattr(self, "_age0"): + self._age0 = self.age(0) + return self._age0 + def redshift(self, age): """ Invert the above age calculation, to return the redshift |