diff options
author | Aaron LI <aly@aaronly.me> | 2017-10-22 18:08:43 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-10-22 18:08:43 +0800 |
commit | 6fa552dca1ad74f39a7d1d44e55d9eb8eaa4a9b9 (patch) | |
tree | 300203be83bf3639cdf9c4c1cb1080f6e1e716d8 /fg21sim/extragalactic | |
parent | 8b2083b53c5f897aed7292f005d35674a962594a (diff) | |
download | fg21sim-6fa552dca1ad74f39a7d1d44e55d9eb8eaa4a9b9.tar.bz2 |
clusters/formation: Fix problem that no mergers occurred
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r-- | fg21sim/extragalactic/clusters/formation.py | 10 | ||||
-rw-r--r-- | fg21sim/extragalactic/clusters/main.py | 1 |
2 files changed, 9 insertions, 2 deletions
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 |