From 720b023d8e5f46f008b417c7e44d6889f2fbb885 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 21 Jan 2019 16:14:36 +0800 Subject: clusters/helper: Improve density_energy_electron() calculation --- fg21sim/extragalactic/clusters/helper.py | 8 ++++---- 1 file 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): -- cgit v1.2.2