From ac97d7a01d1c990de77596fb3d3953dc00d4628e Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 24 Jun 2017 22:37:51 +0800 Subject: halo.py: Add argument "n0_e" to method "calc_electron_spectrum()" --- fg21sim/extragalactic/clusters/halo.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'fg21sim/extragalactic') 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) -- cgit v1.2.2