aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-01-07 16:51:26 +0800
committerAaron LI <aly@aaronly.me>2017-06-01 16:33:38 +0800
commita154d19d38fc0b693184ac1b2edbd0565fdcec55 (patch)
treed75dbb9930198bd06d07c42a2e0eb90293a72bb7 /fg21sim/extragalactic
parent1a9bb3aadda76fc20f6aec49e37d13b44cd600cf (diff)
downloadfg21sim-a154d19d38fc0b693184ac1b2edbd0565fdcec55.tar.bz2
clusters/solver.py: Extrapolate the x grid to avoid NaN's
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r--fg21sim/extragalactic/clusters/solver.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/fg21sim/extragalactic/clusters/solver.py b/fg21sim/extragalactic/clusters/solver.py
index f7c96ea..c1f01d1 100644
--- a/fg21sim/extragalactic/clusters/solver.py
+++ b/fg21sim/extragalactic/clusters/solver.py
@@ -98,17 +98,27 @@ class FokkerPlanckSolver:
@property
def dx(self):
"""
- Values of delta X on the grid.
+ Values of dx[i] on the grid.
dx[i] = (x[i+1] - x[i-1]) / 2
- Thus the first and last element is NaN.
+
+ NOTE:
+ Extrapolate the x grid by 1 point beyond each side, therefore
+ avoid NaN for the first and last element of dx[i].
+ Otherwise, the following calculation of tridiagonal coefficients
+ may be invalid on the boundary elements.
References: Ref.[1],Eq.(8)
"""
x = self.x
- dx_ = (x[2:] - x[:-2]) / 2
- grid = np.concatenate([[np.nan], dx_, [np.nan]])
- return grid
+ # Extrapolate the x grid by 1 point beyond each side
+ x2 = np.concatenate([
+ [x[0]**2/x[1]],
+ x,
+ [x[-1]**2/x[-2]],
+ ])
+ dx_ = (x2[2:] - x2[:-2]) / 2
+ return dx_
@property
def dx_phalf(self):