diff options
author | Aaron LI <aly@aaronly.me> | 2019-01-21 16:14:36 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2019-01-21 16:14:36 +0800 |
commit | 720b023d8e5f46f008b417c7e44d6889f2fbb885 (patch) | |
tree | 733d5d57f26c66a9ec8eb5f88e2baa7d0844da56 /fg21sim/extragalactic | |
parent | af7818ed9d6e9e2e2bbc293948797215df113392 (diff) | |
download | fg21sim-720b023d8e5f46f008b417c7e44d6889f2fbb885.tar.bz2 |
clusters/helper: Improve density_energy_electron() calculation
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r-- | fg21sim/extragalactic/clusters/helper.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fg21sim/extragalactic/clusters/helper.py b/fg21sim/extragalactic/clusters/helper.py index ad43f32..737d05b 100644 --- a/fg21sim/extragalactic/clusters/helper.py +++ b/fg21sim/extragalactic/clusters/helper.py @@ -281,13 +281,13 @@ def density_energy_thermal(mass, z=0.0, configs=CONFIGS): return e_th -def density_energy_electron(spectrum, gamma): +def density_energy_electron(n_e, gamma): """ Calculate the energy density of relativistic electrons. Parameters ---------- - spectrum : 1D float `~numpy.ndarray` + n_e : 1D float `~numpy.ndarray` The number density of the electrons w.r.t. Lorentz factors Unit: [cm^-3] gamma : 1D float `~numpy.ndarray` @@ -299,8 +299,8 @@ def density_energy_electron(spectrum, gamma): The energy density of the relativistic electrons. Unit: [erg cm^-3] """ - e_re = integrate.trapz(spectrum*gamma*AU.mec2, gamma) - return e_re + e_spec = n_e * gamma*AU.mec2 + return integrate.simps(e_spec * gamma, np.log(gamma)) # in log grid def magnetic_field(mass, z=0.0, configs=CONFIGS): |