From a172bba02606020e7ddfa3862fa32f602770c6ba Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 20 Jul 2017 00:00:41 +0800 Subject: clusters/formation.py: Fix bug in "_trace_main()" Do not modify the root node of the merger tree, and return this root node after tracing the formation history. Also print some more information for debug. Signed-off-by: Aaron LI --- fg21sim/extragalactic/clusters/formation.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fg21sim/extragalactic/clusters/formation.py b/fg21sim/extragalactic/clusters/formation.py index c1a93bf..0242992 100644 --- a/fg21sim/extragalactic/clusters/formation.py +++ b/fg21sim/extragalactic/clusters/formation.py @@ -245,10 +245,12 @@ class ClusterFormation: # Initial properties zc = self.z0 Mc = self.M0 - mtree = MergerTree(data={"mass": Mc, - "z": zc, - "age": self.cosmo.age(zc)}) + mtree_root = MergerTree(data={"mass": Mc, + "z": zc, + "age": self.cosmo.age(zc)}) + logger.debug("[main] z=%.4f : mass=%g [Msun]" % (zc, Mc)) + mtree = mtree_root while True: # Whether to stop the trace if self.zmax is not None and zc > self.zmax: @@ -283,18 +285,20 @@ class ClusterFormation: mtree.sub = MergerTree(data={"mass": M_sub, "z": z1, "age": age1}) + logger.debug("[sub] z=%.4f : mass=%g [Msun]" % (z1, M_sub)) # Update main cluster mtree.main = MergerTree(data={"mass": M_main, "z": z1, "age": age1}) + logger.debug("[main] z=%.4f : mass=%g [Msun]" % (z1, M_main)) # Update for next iteration Mc = M_main zc = z1 mtree = mtree.main - return mtree + return mtree_root def _trace_formation(self, M, _z=None, zmax=None): """ -- cgit v1.2.2