Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All output is recorded and no extra simulation steps are run #222

Open
K20shores opened this issue Aug 30, 2024 · 0 comments
Open

All output is recorded and no extra simulation steps are run #222

K20shores opened this issue Aug 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@K20shores
Copy link
Collaborator

K20shores commented Aug 30, 2024

We seem to not add the last row of data produced. Or, we do get the last row of data, but only because we simulate one more time step than is necessary, from what I can understand

while (curr_time <= self.box_model_options.simulation_length):
# iterates evolving conditions if enough time has elapsed
while (
next_conditions is not None and next_conditions_time <= curr_time):
curr_conditions.update_conditions(next_conditions)
ordered_rate_constants = self.order_reaction_rates(
curr_conditions, rate_constant_ordering)
# iterates next_conditions if there are remaining evolving
# conditions
if (len(self.evolving_conditions) > next_conditions_index + 1):
next_conditions_index += 1
next_conditions = self.evolving_conditions.conditions[next_conditions_index]
next_conditions_time = self.evolving_conditions.times[next_conditions_index]
else:
next_conditions = None
# calculate air density from the ideal gas law
BOLTZMANN_CONSTANT = 1.380649e-23
AVOGADRO_CONSTANT = 6.02214076e23
GAS_CONSTANT = BOLTZMANN_CONSTANT * AVOGADRO_CONSTANT
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
# ensure the time step is not greater than the next update to the
# evolving conditions or the next output time
time_step = self.box_model_options.chem_step_time
if (next_conditions is not None and next_conditions_time > curr_time):
time_step = min(time_step, next_conditions_time - curr_time)
if (next_output_time > curr_time):
time_step = min(time_step, next_output_time - curr_time)
# solves and updates concentration values in concentration array
if (not ordered_concentrations):
logger.info("Warning: ordered_concentrations list is empty.")
musica.micm_solve(
self.solver,
time_step,
curr_conditions.temperature,
curr_conditions.pressure,
air_density,
ordered_concentrations,
ordered_rate_constants)
# increments time
curr_time += time_step
df = pd.DataFrame(output_array[1:], columns=output_array[0])

Acceptance criteria

  • No rows of output are missed
  • No extra time steps are taken

Ideas

  • This contains an emission reaction for 1 species. It should run for 100 seconds, but we only output up to 99 seconds
@K20shores K20shores added the bug Something isn't working label Aug 30, 2024
@K20shores K20shores added this to the MusicBox IGAC Demo milestone Aug 30, 2024
@K20shores K20shores changed the title Not all output is captured All output is recorded and no extra simulation steps are run Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant