From ac7eeea99232239f4011cb45367aca722f6e4741 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 24 Oct 2017 23:39:56 +0800 Subject: clusters/halo: Always pass the using configs The user-using `configs` object may be different to the global `CONFIGS`, which may be forgotten to load the up-to-date user configurations. --- fg21sim/extragalactic/clusters/halo.py | 9 ++++++--- fg21sim/extragalactic/clusters/helper.py | 12 ++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'fg21sim/extragalactic/clusters') diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py index 4016fe6..fd6f13a 100644 --- a/fg21sim/extragalactic/clusters/halo.py +++ b/fg21sim/extragalactic/clusters/halo.py @@ -277,12 +277,14 @@ class RadioHalo: Unit: [keV] """ - return helper.kT_cluster(mass=self.M_main, z=self.z_merger) + return helper.kT_cluster(mass=self.M_main, z=self.z_merger, + configs=self.configs) @property @lru_cache() def kT_sub(self): - return helper.kT_cluster(mass=self.M_sub, z=self.z_merger) + return helper.kT_cluster(mass=self.M_sub, z=self.z_merger, + configs=self.configs) @property @lru_cache() @@ -290,7 +292,8 @@ class RadioHalo: """ The "current" cluster ICM mean temperature at ``z_obs``. """ - return helper.kT_cluster(self.M_obs, z=self.z_obs) # [keV] + return helper.kT_cluster(self.M_obs, z=self.z_obs, + configs=self.configs) # [keV] @property @lru_cache() diff --git a/fg21sim/extragalactic/clusters/helper.py b/fg21sim/extragalactic/clusters/helper.py index 26b3ab3..2e27b11 100644 --- a/fg21sim/extragalactic/clusters/helper.py +++ b/fg21sim/extragalactic/clusters/helper.py @@ -143,7 +143,7 @@ def kT_virial(mass, z=0.0, radius=None): return kT -def kT_cluster(mass, z=0.0, radius=None): +def kT_cluster(mass, z=0.0, radius=None, configs=CONFIGS): """ Calculate the temperature of a cluster ICM. @@ -166,7 +166,7 @@ def kT_cluster(mass, z=0.0, radius=None): Unit: [keV] """ key = "extragalactic/clusters/kT_out" - kT_out = CONFIGS.getn(key) + kT_out = configs.getn(key) kT_vir = kT_virial(mass=mass, z=z, radius=radius) kT_icm = kT_vir + 1.5*kT_out return kT_icm @@ -202,7 +202,7 @@ def density_number_thermal(mass, z=0.0): return n_th -def density_energy_thermal(mass, z=0.0): +def density_energy_thermal(mass, z=0.0, configs=CONFIGS): """ Calculate the thermal energy density of the ICM. @@ -213,12 +213,12 @@ def density_energy_thermal(mass, z=0.0): Unit: [erg/cm^3] """ n_th = density_number_thermal(mass=mass, z=z) # [cm^-3] - kT = kT_cluster(mass, z) * AUC.keV2erg # [erg] + kT = kT_cluster(mass, z, configs=configs) * AUC.keV2erg # [erg] e_th = (3.0/2) * kT * n_th return e_th -def magnetic_field(mass, z=0.0): +def magnetic_field(mass, z=0.0, configs=CONFIGS): """ Calculate the mean magnetic field strength within the ICM, which is also assumed to be uniform, according to the assumed fraction of the @@ -236,7 +236,7 @@ def magnetic_field(mass, z=0.0): Unit: [uG] """ key = "extragalactic/clusters/eta_b" - eta_b = CONFIGS.getn(key) + 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 -- cgit v1.2.2