From 6fa552dca1ad74f39a7d1d44e55d9eb8eaa4a9b9 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 22 Oct 2017 18:08:43 +0800 Subject: clusters/formation: Fix problem that no mergers occurred --- fg21sim/extragalactic/clusters/formation.py | 10 ++++++++-- fg21sim/extragalactic/clusters/main.py | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'fg21sim/extragalactic/clusters') diff --git a/fg21sim/extragalactic/clusters/formation.py b/fg21sim/extragalactic/clusters/formation.py index 193c7ec..bfe2142 100644 --- a/fg21sim/extragalactic/clusters/formation.py +++ b/fg21sim/extragalactic/clusters/formation.py @@ -256,9 +256,11 @@ class ClusterFormation: event : A dictionary representing this merger event, same format as the above ``self.recent_major_event``. + ``None`` if no mergers occurred during the traced period. """ mtree = self.mtree - event_max = {"M_main": 0, "M_sub": 0, "R_mass": 0, "z": 0, "age": 0} + event_max = {"M_main": -1, "M_sub": -1, "R_mass": -1, + "z": -1, "age": -1} event_major = None # Record the most recent major merger event while mtree and mtree.main: if mtree.sub is None: @@ -286,7 +288,11 @@ class ClusterFormation: if event_major and abs(event_major["z"]-event_max["z"]) > 1e-4: logger.warning("recent major merger != maximum merger") - return event_max + if event_max["z"] <= 0: + logger.warning("no mergers occurred at all!!") + return None + else: + return event_max def _trace_main(self): """ diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index 1aeb522..0be553a 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -216,6 +216,7 @@ class GalaxyClusters: merger_mass_min=self.merger_mass_min) clform.simulate_mergertree(main_only=True) if self.use_max_merger: + # NOTE: may be ``None`` due to no mergers occurred at all! mmev = clform.max_merger else: mmev = clform.recent_major_merger -- cgit v1.2.2