diff options
author | Aaron LI <aly@aaronly.me> | 2018-01-05 17:57:36 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-01-05 17:57:36 +0800 |
commit | 3d557e0507499e28a56023b9f4a428531bcfd22a (patch) | |
tree | 3dd9c24a9de989a0143bdc80d3084f399a661344 | |
parent | f38ae76e6b2cef5a36e9e290f6679da36e100e34 (diff) | |
download | fg21sim-3d557e0507499e28a56023b9f4a428531bcfd22a.tar.bz2 |
clusters/halo: calculate several time-averaged properties
* time_turbulence_avg
* mach_turbulence_avg
* tau_acceleration_avg
* time_acceleration_fraction
-rw-r--r-- | fg21sim/extragalactic/clusters/halo.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py index c0d6df1..d536ba4 100644 --- a/fg21sim/extragalactic/clusters/halo.py +++ b/fg21sim/extragalactic/clusters/halo.py @@ -877,3 +877,57 @@ class RadioHaloAM(RadioHalo): t0 = merger0["age"] rate = (mass0 - mass1) / (t0 - t1) return (mass1 + rate * (t - t1)) + + @property + def time_turbulence_avg(self): + """ + Calculate the time-averaged turbulence acceleration active time + within the period from ``age_begin`` to ``age_obs``. + + Unit: [Gyr] + """ + dt = self.tstep + xt = np.arange(self.age_begin, self.age_obs+dt/2, step=dt) + t_turb = np.array([self.time_turbulence(t) for t in xt]) + avg = np.sum(t_turb * dt) / (len(xt) * dt) + return avg + + @property + def mach_turbulence_avg(self): + """ + Calculate the time-averaged turbulence Mach number within the + period from ``age_begin`` to ``age_obs``. + """ + dt = self.tstep + xt = np.arange(self.age_begin, self.age_obs+dt/2, step=dt) + mach = np.array([self.mach_turbulence(t) for t in xt]) + avg = np.sum(mach * dt) / (len(xt) * dt) + return avg + + @property + def tau_acceleration_avg(self): + """ + Calculate the time-averaged turbulence acceleration timescale + (i.e., efficiency) within the period from ``age_begin`` to + ``age_obs``. + + Unit: [Gyr] + """ + dt = self.tstep + xt = np.arange(self.age_begin, self.age_obs+dt/2, step=dt) + tau = np.array([self.tau_acceleration(t) for t in xt]) + avg = np.sum(tau * dt) / (len(xt) * dt) + return avg + + @property + def time_acceleration_fraction(self): + """ + Calculate the fraction of time within the period from + ``age_begin`` to ``age_obs`` that the turbulence acceleration + is active. + """ + dt = self.tstep + xt = np.arange(self.age_begin, self.age_obs+dt/2, step=dt) + active = np.array([self._is_turb_active(t) for t in xt], dtype=int) + fraction = active.mean() + return fraction |