Skip to content

Commit

Permalink
updates m according to temp and pressure
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjamesgarza committed Apr 12, 2024
1 parent 392f3a0 commit e07ad12
Show file tree
Hide file tree
Showing 6 changed files with 2,228 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/acom_music_box/music_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def solve(self, path_to_output = None):

rate_constant_ordering = musica.user_defined_reaction_rates(self.solver)
species_constant_ordering = musica.species_ordering(self.solver)


#adds species headers to output
ordered_species_headers = [k for k, v in sorted(species_constant_ordering.items(), key=lambda item: item[1])]
Expand All @@ -428,6 +429,7 @@ def solve(self, path_to_output = None):

ordered_concentrations = self.order_species_concentrations(curr_conditions, species_constant_ordering)
ordered_rate_constants = self.order_reaction_rates(curr_conditions, rate_constant_ordering)


output_array.append(headers)

Expand Down Expand Up @@ -473,6 +475,14 @@ def solve(self, path_to_output = None):
else:
next_conditions = None


#updates M accordingly
if 'M' in species_constant_ordering:
BOLTZMANN_CONSTANT = 1.380649e-23
AVOGADRO_CONSTANT = 6.02214076e23;
GAS_CONSTANT = BOLTZMANN_CONSTANT * AVOGADRO_CONSTANT
ordered_concentrations[species_constant_ordering['M']] = curr_conditions.pressure / (GAS_CONSTANT * curr_conditions.temperature)

#solves and updates concentration values in concentration array
musica.micm_solve(self.solver, self.box_model_options.chem_step_time, curr_conditions.temperature, curr_conditions.pressure, ordered_concentrations, ordered_rate_constants)

Expand Down Expand Up @@ -582,13 +592,13 @@ def order_reaction_rates(self, curr_conditions, rate_constant_ordering):
@classmethod
def order_species_concentrations(self, curr_conditions, species_constant_ordering):
concentrations = {}

for concentraton in curr_conditions.species_concentrations:
concentrations[concentraton.species.name] = concentraton.concentration

ordered_concentrations = len(concentrations.keys()) * [0.0]

for key, value in concentrations.items():
print(key)
ordered_concentrations[species_constant_ordering[key]] = value
return ordered_concentrations

Expand Down
Loading

0 comments on commit e07ad12

Please sign in to comment.