From 3dfd7ce87f8d5351ca25c2392d69da30696b051c Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 26 Jan 2019 21:07:53 +0800 Subject: clusters/halo: Rewrite _merger_time() to get the effective merger If the acceleration durations of multiple mergers overlap, the one with the largest efficiency (i.e., smallest tau_acc) is chosen. --- fg21sim/extragalactic/clusters/halo.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'fg21sim') diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py index f66c347..4a62d3e 100644 --- a/fg21sim/extragalactic/clusters/halo.py +++ b/fg21sim/extragalactic/clusters/halo.py @@ -788,14 +788,6 @@ class RadioHaloAM(RadioHalo1M): "t": self.t_merger[idx], } - def _merger_time(self, t): - """ - Determine the beginning time of the merger event within which - the given time is located. - """ - merger = self._merger_event(t) - return merger["t"] - def mass_merged(self, t): """ The mass of merged cluster at the given (cosmic) time. @@ -845,6 +837,30 @@ class RadioHaloAM(RadioHalo1M): rate = (mass0 - mass1) / (t0 - t1) return (mass1 + rate * (t - t1)) + def _merger_time(self, t): + """ + Determine the beginning time of the merger event that is doing + effective acceleration at the given time. + + At a certain time, there may be multiple past merger events with + different turbulence durations (``tau_turb``) and acceleration + efficiencies (``tau_acc``). Therefore, multiple mergers can cover + the given time. The one with the largest acceleration efficiency + (i.e., smallest ``tau_acc``) is chosen and its beginning time is + returned. Otherwise, the most recent merger event happened before + the given time is chosen. + """ + mergers = [(tm, tm+self.duration_turb(tm), self.tau_acceleration(tm)) + for tm in self.t_merger] + m_active = [(tm, tend, tau) for (tm, tend, tau) in mergers + if t >= tm and t < tend] + if m_active: + m_eff = min(m_active, key=lambda item: item[2]) + return m_eff[0] + else: + m = self._merger_event(t) + return m["t"] + class RadioHalo: """ -- cgit v1.2.2