diff options
author | Aaron LI <aly@aaronly.me> | 2017-06-25 10:54:17 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-06-25 10:54:17 +0800 |
commit | f5590230f0ee040004de93f990c0bca579ec31a4 (patch) | |
tree | decbf91d15b89282ffe52380a7c8a12be5970a40 /fg21sim/extragalactic | |
parent | 0b17f95ca897d3f62f0c9817ac21ad079cb9e71a (diff) | |
download | fg21sim-f5590230f0ee040004de93f990c0bca579ec31a4.tar.bz2 |
clusters/solver.py: Fix "fix_boundary()" and remove a warning
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r-- | fg21sim/extragalactic/clusters/solver.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fg21sim/extragalactic/clusters/solver.py b/fg21sim/extragalactic/clusters/solver.py index d7f8feb..50ea75f 100644 --- a/fg21sim/extragalactic/clusters/solver.py +++ b/fg21sim/extragalactic/clusters/solver.py @@ -226,9 +226,6 @@ class FokkerPlanckSolver: mask_mhalf = (np.abs(w_mhalf) > w_max) w_phalf[mask_phalf] = w_max * (np.sign(w_phalf[mask_phalf])) w_mhalf[mask_mhalf] = w_max * (np.sign(w_mhalf[mask_mhalf])) - logger.warning("Fixed too large w values: " + - "%d+%d" % (len(mask_phalf), len(mask_mhalf))) - # W_phalf = self.W(w_phalf) W_mhalf = self.W(w_mhalf) Wplus_phalf = W_phalf * np.exp(w_phalf/2) @@ -260,15 +257,17 @@ class FokkerPlanckSolver: References: Ref.[2],Sec.(3.3) """ - uc = np.array(uc) + uc = np.asarray(uc) x = self.x # Calculate the power-law index xa = x[self.buffer_np] xb = x[self.buffer_np+1] ya = uc[self.buffer_np] yb = uc[self.buffer_np+1] - s = np.log(yb/ya) / np.log(xb/xa) - uc[:self.buffer_np] = ya * (x[:self.buffer_np] / xa) ** s + if ya > 0 and yb > 0: + # Truncate and extrapolate as a power law + s = np.log(yb/ya) / np.log(xb/xa) + uc[:self.buffer_np] = ya * (x[:self.buffer_np] / xa) ** s return uc def solve_step(self, tc, uc): |