From 68bd014e91b6007a0b8899631f3667e88ccb78b5 Mon Sep 17 00:00:00 2001 From: Ran Livneh Date: Tue, 19 Jun 2018 10:36:08 +0300 Subject: [PATCH 1/5] Fix NLTE Normalization - issue #784 --- tardis/plasma/properties/partition_function.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tardis/plasma/properties/partition_function.py b/tardis/plasma/properties/partition_function.py index a9c08a161ea..88739e163f1 100644 --- a/tardis/plasma/properties/partition_function.py +++ b/tardis/plasma/properties/partition_function.py @@ -124,7 +124,7 @@ def __init__(self, plasma_parent): def _main_nlte_calculation( self, atomic_data, nlte_data, t_electrons, j_blues, beta_sobolevs, general_level_boltzmann_factor, - previous_electron_densities): + previous_electron_densities, g): """ The core of the NLTE calculation, used with all possible config. options. @@ -190,7 +190,7 @@ def _main_nlte_calculation( else: raise e general_level_boltzmann_factor[i].ix[species] = \ - level_boltzmann_factor + level_boltzmann_factor * g[species][0] / level_boltzmann_factor[0] return general_level_boltzmann_factor def _calculate_classical_nebular( @@ -232,7 +232,7 @@ def _calculate_coronal_approximation( def _calculate_general( self, t_electrons, lines, atomic_data, nlte_data, general_level_boltzmann_factor, j_blues, - previous_beta_sobolev, previous_electron_densities): + previous_beta_sobolev, previous_electron_densities, g): """ Full NLTE calculation without approximations. """ @@ -244,7 +244,7 @@ def _calculate_general( general_level_boltzmann_factor = self._main_nlte_calculation( atomic_data, nlte_data, t_electrons, j_blues, beta_sobolevs, general_level_boltzmann_factor, - previous_electron_densities) + previous_electron_densities, g) return general_level_boltzmann_factor From b54f34b5ebe6e22426d94265e8236528fabd9764 Mon Sep 17 00:00:00 2001 From: Ran Livneh Date: Tue, 19 Jun 2018 20:58:39 +0300 Subject: [PATCH 2/5] Fix NLTE Normalization - issue #784 g.loc --- tardis/plasma/properties/partition_function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tardis/plasma/properties/partition_function.py b/tardis/plasma/properties/partition_function.py index 88739e163f1..9dfb99db645 100644 --- a/tardis/plasma/properties/partition_function.py +++ b/tardis/plasma/properties/partition_function.py @@ -190,7 +190,7 @@ def _main_nlte_calculation( else: raise e general_level_boltzmann_factor[i].ix[species] = \ - level_boltzmann_factor * g[species][0] / level_boltzmann_factor[0] + level_boltzmann_factor * g.loc[species][0] / level_boltzmann_factor[0] return general_level_boltzmann_factor def _calculate_classical_nebular( From d243f4cfe10168ce1dd06b78d30e2a358e1c9b48 Mon Sep 17 00:00:00 2001 From: Ran Livneh Date: Tue, 19 Jun 2018 21:54:03 +0300 Subject: [PATCH 3/5] Fix NLTE Normalization - issue #784 some more gs --- tardis/plasma/properties/partition_function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tardis/plasma/properties/partition_function.py b/tardis/plasma/properties/partition_function.py index 9dfb99db645..c6ab3219f48 100644 --- a/tardis/plasma/properties/partition_function.py +++ b/tardis/plasma/properties/partition_function.py @@ -210,7 +210,7 @@ def _calculate_classical_nebular( j_blues, beta_sobolevs, general_level_boltzmann_factor, - previous_electron_densities) + previous_electron_densities, g) return general_level_boltzmann_factor def _calculate_coronal_approximation( @@ -226,7 +226,7 @@ def _calculate_coronal_approximation( general_level_boltzmann_factor = self._main_nlte_calculation( atomic_data, nlte_data, t_electrons, j_blues, beta_sobolevs, general_level_boltzmann_factor, - previous_electron_densities) + previous_electron_densities, g) return general_level_boltzmann_factor def _calculate_general( From 03c7acd1d2b9d97091753f199b39b13ef5da550f Mon Sep 17 00:00:00 2001 From: Ran Livneh Date: Tue, 19 Jun 2018 21:56:51 +0300 Subject: [PATCH 4/5] Flip g_ratio in NLTE collision matrix to fit new atomic data - issue #784 --- tardis/io/atomic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tardis/io/atomic.py b/tardis/io/atomic.py index 143c0fd6c44..c62ea261b70 100644 --- a/tardis/io/atomic.py +++ b/tardis/io/atomic.py @@ -442,7 +442,7 @@ def _create_collision_coefficient_matrix(self): C_ul_matrix[level_number_lower, level_number_upper, :] = line.values[2:] delta_E_matrix[level_number_lower, level_number_upper] = line['delta_e'] #TODO TARDISATOMIC fix change the g_ratio to be the otherway round - I flip them now here. - g_ratio_matrix[level_number_lower, level_number_upper] = line['g_ratio'] + g_ratio_matrix[level_number_lower, level_number_upper] = 1/line['g_ratio'] self.C_ul_interpolator[species] = interpolate.interp1d( self.atom_data.collision_data_temperatures, C_ul_matrix) From dff362ebde3aefce7f8fe73acce23bf64752b046 Mon Sep 17 00:00:00 2001 From: Ran Livneh Date: Tue, 19 Jun 2018 22:33:45 +0300 Subject: [PATCH 5/5] Fix NLTE Normalization - issue #784 even more gs --- tardis/plasma/properties/partition_function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tardis/plasma/properties/partition_function.py b/tardis/plasma/properties/partition_function.py index c6ab3219f48..8a07949f7cf 100644 --- a/tardis/plasma/properties/partition_function.py +++ b/tardis/plasma/properties/partition_function.py @@ -196,7 +196,7 @@ def _main_nlte_calculation( def _calculate_classical_nebular( self, t_electrons, lines, atomic_data, nlte_data, general_level_boltzmann_factor, j_blues, - previous_electron_densities): + previous_electron_densities, g): """ Performs NLTE calculations using the classical nebular treatment. All beta sobolev values taken as 1. @@ -216,7 +216,7 @@ def _calculate_classical_nebular( def _calculate_coronal_approximation( self, t_electrons, lines, atomic_data, nlte_data, general_level_boltzmann_factor, - previous_electron_densities): + previous_electron_densities, g): """ Performs NLTE calculations using the coronal approximation. All beta sobolev values taken as 1 and j_blues taken as 0.