aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-10-07 17:28:12 +0800
committerAaron LI <aly@aaronly.me>2017-10-07 17:28:12 +0800
commitc3d3d396dcf9cf86682089dd972f56643373f6b3 (patch)
tree49aa458b070014e20301c0417397007174e0e492 /fg21sim/extragalactic
parentbb36d88c19cff5004ca605aa58f5965fb5418030 (diff)
downloadfg21sim-c3d3d396dcf9cf86682089dd972f56643373f6b3.tar.bz2
clusters/solver.py: Small tweaks
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r--fg21sim/extragalactic/clusters/solver.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/fg21sim/extragalactic/clusters/solver.py b/fg21sim/extragalactic/clusters/solver.py
index 9117bfb..da6b4d4 100644
--- a/fg21sim/extragalactic/clusters/solver.py
+++ b/fg21sim/extragalactic/clusters/solver.py
@@ -169,11 +169,8 @@ class FokkerPlanckSolver:
"""
x = self.x # log scale
# Extrapolate the x grid by 1 point beyond each side
- x2 = np.concatenate([
- [x[0]**2/x[1]],
- x,
- [x[-1]**2/x[-2]],
- ])
+ ratio = x[1] / x[0]
+ x2 = np.concatenate([[x[0]/ratio], x, [x[-1]*ratio]])
dx_ = (x2[2:] - x2[:-2]) / 2
return dx_
@@ -232,6 +229,7 @@ class FokkerPlanckSolver:
@staticmethod
def W(w):
# References: Ref.[park1996],Eqs.(27,35)
+ w = np.asarray(w)
with np.errstate(invalid="ignore"):
# Ignore NaN's
w = np.abs(w)
@@ -248,11 +246,11 @@ class FokkerPlanckSolver:
Bound the absolute values of ``w`` within [wmin, wmax], to avoid
the underflow/overflow during later W/Wplus/Wminus calculations.
"""
+ ww = np.array(w)
with np.errstate(invalid="ignore"):
# Ignore NaN's
- m1 = (np.abs(w) < wmin)
- m2 = (np.abs(w) > wmax)
- ww = np.array(w)
+ m1 = (np.abs(ww) < wmin)
+ m2 = (np.abs(ww) > wmax)
ww[m1] = wmin * np.sign(ww[m1])
ww[m2] = wmax * np.sign(ww[m2])
return ww