diff options
author | Aaron LI <aly@aaronly.me> | 2017-07-23 11:32:37 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-07-23 11:32:37 +0800 |
commit | a5cf20da1b7e2bc61321d948dae6e5016982d0fe (patch) | |
tree | 673f099143604027cc5386652a8e64b99a4a764e | |
parent | 5e1058cbe6f6d9510d3db501048f68ebf27e65f2 (diff) | |
download | fg21sim-a5cf20da1b7e2bc61321d948dae6e5016982d0fe.tar.bz2 |
clusters/helper.py: Add "density_energy_electron()" function
Signed-off-by: Aaron LI <aly@aaronly.me>
-rw-r--r-- | fg21sim/extragalactic/clusters/helper.py | 29 |
1 files changed, 27 insertions, 2 deletions
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 |