aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic/clusters/helper.py
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-10-20 10:22:24 +0800
committerAaron LI <aly@aaronly.me>2017-10-20 10:22:24 +0800
commitfd20ab688759f3dfc3f7796ac0b1118e21ee5b22 (patch)
treea75ffd2b7ae280afe65b71e998b0da22c7e7fde1 /fg21sim/extragalactic/clusters/helper.py
parent283ca6c00e5ff6c74b529d0a460115516c16eec7 (diff)
downloadfg21sim-fd20ab688759f3dfc3f7796ac0b1118e21ee5b22.tar.bz2
clusters/halo: Determine magnetic field by fraction of its energy density
* Rewrite "magnetic_field()" function to calculate the mean magnetic field strength within ICM according its energy density fraction w.r.t. the ICM thermal energy density. * Remove config options "b_mean" and "b_index", which are replaced with the option "eta_b", the assumed magnetic energy density fraction w.r.t. the ICM thermal energy density.
Diffstat (limited to 'fg21sim/extragalactic/clusters/helper.py')
-rw-r--r--fg21sim/extragalactic/clusters/helper.py54
1 files changed, 24 insertions, 30 deletions
diff --git a/fg21sim/extragalactic/clusters/helper.py b/fg21sim/extragalactic/clusters/helper.py
index 6fd99fb..1c6e48e 100644
--- a/fg21sim/extragalactic/clusters/helper.py
+++ b/fg21sim/extragalactic/clusters/helper.py
@@ -210,6 +210,30 @@ def density_energy_thermal(mass, z=0.0):
return e_th
+def magnetic_field(mass, z=0.0):
+ """
+ Calculate the mean magnetic field strength within the ICM, which is
+ also assumed to be uniform, according to the assumed fraction of the
+ the magnetic field energy density w.r.t. the ICM thermal energy density.
+
+ NOTE
+ ----
+ Magnetic field energy density: u_B = B^2 / (8π),
+ where "B" in units of [G], then "u_B" has unit of [erg/cm^3].
+
+ Returns
+ -------
+ B : float
+ The mean magnetic field strength within the ICM.
+ Unit: [uG]
+ """
+ key = "extragalactic/clusters/eta_b"
+ eta_b = CONFIGS.getn(key)
+ e_th = density_energy_thermal(mass=mass, z=z)
+ B = np.sqrt(8*np.pi * eta_b * e_th) * 1e6 # [G] -> [uG]
+ return B
+
+
def density_energy_electron(spectrum, gamma):
"""
Calculate the energy density of relativistic electrons.
@@ -295,36 +319,6 @@ def time_crossing(M_main, M_sub, z=0.0):
return time
-def magnetic_field(mass):
- """
- Calculate the mean magnetic field strength according to the
- scaling relation between magnetic field and cluster mass.
-
- Parameters
- ----------
- mass : float
- Cluster mass
- Unit: [Msun]
-
- Returns
- -------
- B : float
- The mean magnetic field strength
- Unit: [uG]
-
- References
- ----------
- Ref.[cassano2012],Eq.(1)
- """
- comp = "extragalactic/clusters"
- b_mean = CONFIGS.getn(comp+"/b_mean")
- b_index = CONFIGS.getn(comp+"/b_index")
-
- M_mean = 1.6e15 # [Msun]
- B = b_mean * (mass/M_mean) ** b_index
- return B
-
-
def halo_rprofile(re, num_re=5, I0=1.0):
"""
Generate the radial profile of a halo.