changeset 2576:4a2134f6283c

app/pitot: fixed bug in normalised output in pitot_condition_builder.py A while ago I added the ability to output species mole and mass fractions from certain important states. These had to be added as exceptions to the normalised results, as often some species will have nothing at different states However, it turns out that I never set up the nitrogen case properly at the time and had just left it for future me. Now it works for both air and nitrogen
author Chris James (c.james4@uq.edu.au)
date Sun, 02 Dec 2018 14:33:52 +1000
parents 5166ba3eefb2
children 4ee2a3a3105d
files app/pitot/pitot_condition_builder.py
diffstat 1 files changed, 43 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/app/pitot/pitot_condition_builder.py	Wed Aug 15 13:59:21 2018 +1000
+++ b/app/pitot/pitot_condition_builder.py	Sun Dec 02 14:33:52 2018 +1000
@@ -10,7 +10,7 @@
 
 """
 
-VERSION_STRING = "24-Apr-2018"
+VERSION_STRING = "29-Nov-2018"
 
 import sys
 
@@ -720,38 +720,55 @@
         
         # we also need to add exceptions for the mole or mass fractions...
         if 'store_mole_fractions' in cfg and cfg['store_mole_fractions']:
+
             # we have to add more columns here based on the test gas...
             if cfg['test_gas'] in ['n2_o2', 'N2_O2', 'N2-O2', 'n2-o2', 'air-cfd-with-ions', 'air-N2-O2', 'air_N2_O2', 'air_n2_o2', 'air-n2-o2']:
-                cfd_air_list = ['N2', 'O2', 'N', 'O', 'N3', 'O3', 'N+','N-','O+','O-','e-', 'N2+','N2-','O2+','O2-','N2O','NO2','NO','NO+','N2O+']
-                
-                cfd_air_state8_list = []
-                cfd_air_state10e_list = []
-                
-                for species in cfd_air_list:
-                    cfd_air_state8_list.append('s8 %{0}'.format(species))
-                    if cfg['shock_over_model']:
-                        cfd_air_state10e_list.append('s10e %{0}'.format(species))
-                        
-                normalise_exceptions += cfd_air_state8_list
+                variable_list = ['N2', 'O2', 'N', 'O', 'N3', 'O3', 'N+','N-','O+','O-','e-', 'N2+','N2-','O2+','O2-','N2O','NO2','NO','NO+','N2O+']
+            elif cfg['test_gas'] == 'n2':
+                variable_list = ['N2', 'N', 'N3', 'N+', 'N-', 'e-', 'N2+', 'N2-']
+
+            state2_list = []
+            state7_list = []
+            state8_list = []
+            state10e_list = []
+
+            for species in variable_list:
+                state2_list.append('s2 %{0}'.format(species))
+                state2_list.append('s7 %{0}'.format(species))
+                state8_list.append('s8 %{0}'.format(species))
                 if cfg['shock_over_model']:
-                    normalise_exceptions += cfd_air_state10e_list
-        
+                    state10e_list.append('s10e %{0}'.format(species))
+
+            normalise_exceptions += state2_list
+            normalise_exceptions += state7_list
+            normalise_exceptions += state8_list
+            if cfg['shock_over_model']:
+                normalise_exceptions += state10e_list
+
         if 'store_mass_fractions' in cfg and cfg['store_mass_fractions']:
             # we have to add more columns here based on the test gas...
             if cfg['test_gas'] in ['n2_o2', 'N2_O2', 'N2-O2', 'n2-o2', 'air-cfd-with-ions', 'air-N2-O2', 'air_N2_O2', 'air_n2_o2', 'air-n2-o2']:
                 cfd_air_list = ['N2', 'O2', 'N', 'O', 'N3', 'O3', 'N+','N-','O+','O-','e-', 'N2+','N2-','O2+','O2-','N2O','NO2','NO','NO+','N2O+']
-                
-                cfd_air_state8_list = []
-                cfd_air_state10e_list = []
-                
-                for species in cfd_air_list:
-                    cfd_air_state8_list.append('s8 y{0}'.format(species))
-                    if cfg['shock_over_model']:
-                        cfd_air_state10e_list.append('s10e y{0}'.format(species))
-                        
-                normalise_exceptions += cfd_air_state8_list
+            elif cfg['test_gas'] == 'n2':
+                variable_list = ['N2', 'N', 'N3', 'N+', 'N-', 'e-', 'N2+', 'N2-']
+
+            state2_list = []
+            state7_list = []
+            state8_list = []
+            state10e_list = []
+
+            for species in variable_list:
+                state2_list.append('s2 y{0}'.format(species))
+                state2_list.append('s7 y{0}'.format(species))
+                state8_list.append('s8 y{0}'.format(species))
                 if cfg['shock_over_model']:
-                    normalise_exceptions += cfd_air_state10e_list
+                    state10e_list.append('s10e y{0}'.format(species))
+
+            normalise_exceptions += state2_list
+            normalise_exceptions += state7_list
+            normalise_exceptions += state8_list
+            if cfg['shock_over_model']:
+                normalise_exceptions += state10e_list
         
         if extra_normalise_exceptions:
             normalise_exceptions += extra_normalise_exceptions
@@ -806,7 +823,7 @@
             elif normalised_by == 'maximum value':
                 normalising_value_dict[value] = max(results[value])
             elif normalised_by == 'last value':
-                normalising_value_dict[value] = results[value][-1] 
+                normalising_value_dict[value] = results[value][-1]
         
         for i in range(0, number_of_test_runs, 1):
             output_line = ''