From b76721bc82b390fca98b7d1b9c32dffa03a2b6a0 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 22 Jul 2017 23:22:59 +0800 Subject: clusters: Move "magnetic_field()" function to helper.py Import the global "configs" in helper.py to make parameters lean. Signed-off-by: Aaron LI --- fg21sim/extragalactic/clusters/helper.py | 40 ++++++++++++++++++++++++++++++++ fg21sim/extragalactic/clusters/main.py | 24 ------------------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/fg21sim/extragalactic/clusters/helper.py b/fg21sim/extragalactic/clusters/helper.py index f07f1c0..f20af5f 100644 --- a/fg21sim/extragalactic/clusters/helper.py +++ b/fg21sim/extragalactic/clusters/helper.py @@ -17,11 +17,16 @@ References .. [cassano2007] Cassano et al. 2007, MNRAS, 378, 1565; http://adsabs.harvard.edu/abs/2007MNRAS.378.1565C + +.. [cassano2012] + Cassano et al. 2012, A&A, 548, A100 + http://adsabs.harvard.edu/abs/2012A%26A...548A.100C """ import numpy as np +from ...configs import configs from ...utils import cosmo from ...utils.units import (Constants as AC, UnitConversions as AUC) @@ -127,6 +132,11 @@ def density_number_thermal(mass, z=0.0): """ Calculate the number density of the ICM thermal plasma. + NOTE + ---- + This number density is independent of cluster (virial) mass, + but (mostly) increases with redshifts. + Parameters ---------- mass : float @@ -224,3 +234,33 @@ def time_crossing(M_main, M_sub, z=0.0): uconv = AUC.kpc2km * AUC.s2Gyr time = uconv * R_vir / vi # [Gyr] 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 diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index 840acbe..db82e78 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -75,8 +75,6 @@ class GalaxyClusters: self.merger_mass_min = self.configs.getn(comp+"/merger_mass_min") self.ratio_major = self.configs.getn(comp+"/ratio_major") self.tau_merger = self.configs.getn(comp+"/tau_merger") - self.b_mean = self.configs.getn(comp+"/b_mean") - self.b_index = self.configs.getn(comp+"/b_index") self.filename_pattern = self.configs.getn("output/filename_pattern") self.use_float = self.configs.getn("output/use_float") @@ -241,30 +239,8 @@ class GalaxyClusters: logger.info("%d (%.1f%%) clusters have recent major mergers." % (num_major, 100*num_major/num)) - def _magnetic_field(self, 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) """ - M_mean = 1.6e15 # [Msun] - B = self.b_mean * (mass/M_mean) ** self.b_index - return B def preprocess(self): """ -- cgit v1.2.2