aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-06-24 22:37:51 +0800
committerAaron LI <aly@aaronly.me>2017-06-24 22:37:51 +0800
commitac97d7a01d1c990de77596fb3d3953dc00d4628e (patch)
treea28107f80c7fd00c7eddc0e305f3c6c9dd2a8fb6 /fg21sim/extragalactic
parent034fd525a2ef65363df94ce8fe7e73803eb8c078 (diff)
downloadfg21sim-ac97d7a01d1c990de77596fb3d3953dc00d4628e.tar.bz2
halo.py: Add argument "n0_e" to method "calc_electron_spectrum()"
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r--fg21sim/extragalactic/clusters/halo.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py
index 649cfb4..11c05c4 100644
--- a/fg21sim/extragalactic/clusters/halo.py
+++ b/fg21sim/extragalactic/clusters/halo.py
@@ -156,7 +156,7 @@ class HaloSingle:
self.mtree = self.formation.simulate_mergertree()
return self.mtree
- def calc_electron_spectrum(self, zbegin=None, zend=None):
+ def calc_electron_spectrum(self, zbegin=None, zend=None, n0_e=None):
"""
Calculate the relativistic electron spectrum by solving the
Fokker-Planck equation.
@@ -169,6 +169,11 @@ class HaloSingle:
zend : float, optional
The redshift where to stop solving the Fokker-Planck equation.
Default: ``self.z0``.
+ n0_e : 1D `~numpy.ndarray`, optional
+ The initial electron number distribution.
+ Should have the same shape as ``self.pgrid`` and has unit
+ [cm^-3 mec^-1].
+ Default: accumulated constant-injected electrons until zbegin.
Returns
-------
@@ -198,9 +203,10 @@ class HaloSingle:
f_injection=self.fp_injection,
)
p = fpsolver.x
- # Assume NO initial electron distribution, i.e., only
- # injection.
- n0_e = np.zeros(p.shape)
+ if n0_e is None:
+ # Accumulated constant-injected electrons until ``tstart``.
+ n_inj = np.array([self.fp_injection(p_) for p_ in p])
+ n0_e = n_inj * tstart
n_e = fpsolver.solve(u0=n0_e, tstart=tstart, tstop=tstop)
return (p, n_e)