From ee7ae0c4674b6f9dc91b50c8e6b61781e49e4a13 Mon Sep 17 00:00:00 2001 From: Matt Dawson Date: Tue, 27 Aug 2024 17:18:37 -0700 Subject: [PATCH] add air density to output --- src/acom_music_box/music_box.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/acom_music_box/music_box.py b/src/acom_music_box/music_box.py index 84756413..357a7a60 100644 --- a/src/acom_music_box/music_box.py +++ b/src/acom_music_box/music_box.py @@ -199,7 +199,9 @@ def generateConfig(self, directory): elif reaction_rate.reaction.reaction_type == "LOSS": name = "LOSS." + reaction_rate.reaction.name + ".s-1" elif reaction_rate.reaction.reaction_type == "EMISSION": - name = "EMISSION." + reaction_rate.reaction.name + ".s-1" + name = "EMIS." + reaction_rate.reaction.name + ".s-1" + elif reaction_rate.reaction.reaction_type == "USER_DEFINED": + name = "USER." + reaction_rate.reaction.name + ".s-1" reaction_names.append(name) reaction_rates.append(reaction_rate.rate) @@ -469,6 +471,7 @@ def solve(self, output_path=None): headers.append("time") headers.append("ENV.temperature") headers.append("ENV.pressure") + headers.append("ENV.number_density_air") if (self.solver is None): raise Exception("Error: MusicBox object {} has no solver." @@ -500,16 +503,6 @@ def solve(self, output_path=None): while (curr_time <= self.box_model_options.simulation_length): - # outputs to output_array if enough time has elapsed - if (next_output_time <= curr_time): - row = [] - row.append(next_output_time) - row.append(curr_conditions.temperature) - row.append(curr_conditions.pressure) - for conc in ordered_concentrations: - row.append(conc) - output_array.append(row) - next_output_time += self.box_model_options.output_step_time # iterates evolving conditions if enough time has elapsed while ( @@ -535,6 +528,18 @@ def solve(self, output_path=None): air_density = curr_conditions.pressure / \ (GAS_CONSTANT * curr_conditions.temperature) + # outputs to output_array if enough time has elapsed + if (next_output_time <= curr_time): + row = [] + row.append(next_output_time) + row.append(curr_conditions.temperature) + row.append(curr_conditions.pressure) + row.append(air_density) + for conc in ordered_concentrations: + row.append(conc) + output_array.append(row) + next_output_time += self.box_model_options.output_step_time + # solves and updates concentration values in concentration array if (not ordered_concentrations): logger.info("Warning: ordered_concentrations list is empty.")