From a5cf20da1b7e2bc61321d948dae6e5016982d0fe Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 23 Jul 2017 11:32:37 +0800 Subject: clusters/helper.py: Add "density_energy_electron()" function Signed-off-by: Aaron LI --- fg21sim/extragalactic/clusters/helper.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'fg21sim/extragalactic') diff --git a/fg21sim/extragalactic/clusters/helper.py b/fg21sim/extragalactic/clusters/helper.py index 67d72de..300ee08 100644 --- a/fg21sim/extragalactic/clusters/helper.py +++ b/fg21sim/extragalactic/clusters/helper.py @@ -25,10 +25,12 @@ References import numpy as np +from scipy import integrate from ...configs import CONFIGS from ...utils import COSMO -from ...utils.units import (Constants as AC, +from ...utils.units import (Units as AU, + Constants as AC, UnitConversions as AUC) @@ -169,7 +171,8 @@ def density_energy_thermal(mass, z=0.0): Returns ------- e_th : float - Energy density of the ICM (unit: erg/cm^3) + Energy density of the ICM + Unit: [erg cm^-3] """ n_th = density_number_thermal(mass, z) # [cm^-3] kT = mass_to_kT(mass, z) * AUC.keV2erg # [erg] @@ -177,6 +180,28 @@ def density_energy_thermal(mass, z=0.0): return e_th +def density_energy_electron(spectrum, gamma): + """ + Calculate the energy density of relativistic electrons. + + Parameters + ---------- + spectrum : 1D float `~numpy.ndarray` + The number density of the electrons w.r.t. Lorentz factors + Unit: [cm^-3] + gamma : 1D float `~numpy.ndarray` + The Lorentz factors of electrons + + Returns + ------- + e_re : float + The energy density of the relativistic electrons. + Unit: [erg cm^-3] + """ + e_re = integrate.trapz(spectrum*gamma*AU.mec2, gamma) + return e_re + + def velocity_impact(M_main, M_sub, z=0.0): """ Estimate the relative impact velocity between the two merging -- cgit v1.2.2