From 3d557e0507499e28a56023b9f4a428531bcfd22a Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 5 Jan 2018 17:57:36 +0800 Subject: clusters/halo: calculate several time-averaged properties * time_turbulence_avg * mach_turbulence_avg * tau_acceleration_avg * time_acceleration_fraction --- fg21sim/extragalactic/clusters/halo.py | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) 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 -- cgit v1.2.2