Skip to content

Commit

Permalink
add air density to output
Browse files Browse the repository at this point in the history
  • Loading branch information
mattldawson committed Aug 28, 2024
1 parent 0257022 commit ee7ae0c
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/acom_music_box/music_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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 (
Expand All @@ -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.")
Expand Down

0 comments on commit ee7ae0c

Please sign in to comment.