Skip to content

Commit

Permalink
check reaction names correctly for evolving conditions config, ensure…
Browse files Browse the repository at this point in the history
… floats for rate constants
  • Loading branch information
eadlg2 committed Apr 6, 2024
1 parent 5315cc0 commit 9663de5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/music_box/music_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,15 @@ def generateConfig(self, directory):
species_concentration = next((x for x in self.evolving_conditions.conditions[i].species_concentrations if x.species.name == species_name), None)
row.append(species_concentration.concentration)
elif header.endswith(".s-1"):
reaction_name = header.split('.')[1]
reaction_name = header.split('.')

if reaction_name[0] == 'LOSS' or reaction_name[0] == 'EMIS':
reaction_name = reaction_name[0] + '_' + reaction_name[1]
else:
reaction_name = reaction_name[1]

reaction_rate = next((x for x in self.evolving_conditions.conditions[i].reaction_rates if x.reaction.name == reaction_name), None)
row.append(reaction_rate.rate)
row.append(reaction_rate.rate)

writer.writerow(row)

Expand Down Expand Up @@ -549,7 +555,7 @@ def order_reaction_rates(self, curr_conditions, rate_constant_ordering):
ordered_rate_constants = len(rate_constants.keys()) * [0.0]
for key, value in rate_constants.items():

ordered_rate_constants[rate_constant_ordering[key]] = value
ordered_rate_constants[rate_constant_ordering[key]] = float(value)
return ordered_rate_constants

@classmethod
Expand Down

0 comments on commit 9663de5

Please sign in to comment.