From 73e6f8a436e7b805144c48c757a7bab0ab94b01b Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 19 Oct 2017 09:05:35 +0800 Subject: clusters/halo: Improve time step determination a bit --- fg21sim/extragalactic/clusters/halo.py | 7 +++++-- fg21sim/extragalactic/clusters/solver.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'fg21sim/extragalactic') diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py index a481ce5..3ce3ed7 100644 --- a/fg21sim/extragalactic/clusters/halo.py +++ b/fg21sim/extragalactic/clusters/halo.py @@ -294,8 +294,11 @@ class RadioHalo: # to improve the results. # XXX: is this necessary??? nstep_min = 20 - if (tstop - tstart) / self.fpsolver.tstep < nstep_min: - self.fpsolver.tstep = (tstop - tstart) / nstep_min + if (tstop - tstart) / self.time_step < nstep_min: + tstep = (tstop - tstart) / nstep_min + logger.debug("Decreased time step: %g -> %g [Gyr]" % + (self.time_step, self.fpsolver.tstep)) + self.fpsolver.tstep = tstep self.electron_spec = self.fpsolver.solve(u0=n0_e, tstart=tstart, tstop=tstop) diff --git a/fg21sim/extragalactic/clusters/solver.py b/fg21sim/extragalactic/clusters/solver.py index c29748e..2fd800a 100644 --- a/fg21sim/extragalactic/clusters/solver.py +++ b/fg21sim/extragalactic/clusters/solver.py @@ -408,7 +408,7 @@ class FokkerPlanckSolver: tstep = self.tstep logger.debug("Solving Fokker-Planck equation: " + "time: %.3f - %.3f" % (tstart, tstop)) - nstep = int((tstop - tc) / tstep) + nstep = int(np.ceil((tstop - tc) / tstep)) logger.debug("Constant time step: %.3f (#%d steps)" % (tstep, nstep)) i = 0 while tc+tstep < tstop: -- cgit v1.2.2