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

Updates #192

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/acom_music_box/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,13 @@ def from_config_JSON(
for reaction in reaction_list.reactions:
if (reaction.name is None):
continue
if not any(rate.reaction.name ==
reaction.name for rate in reaction_rates):
reaction_exists = False
for rate in reaction_rates:
if rate.reaction.name == reaction.name:
reaction_exists = True
break

if not reaction_exists:
Comment on lines +182 to +188
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't actually know what this does but it's apparently crucial and tests fail without it

reaction_rates.append(ReactionRate(reaction, 0))

return cls(
Expand Down Expand Up @@ -217,18 +222,12 @@ def read_initial_rates_from_file(cls, file_path, reaction_list):
# The second row of the CSV contains rates
rates = initial_conditions[1]

for i in range(0, len(headers)):

reaction_rate = headers[i]

match = filter(
lambda x: x.name == reaction_rate.split('.')[1],
reaction_list.reactions)

reaction = next(match, None)
rate = rates[i]
for reaction_rate, rate in zip(headers, rates):
type, name, *rest = reaction_rate.split('.')
for reaction in reaction_list.reactions:
if reaction.name == name and reaction.short_type() == type:
reaction_rates.append(ReactionRate(reaction, rate))

reaction_rates.append(ReactionRate(reaction, rate))
return reaction_rates

def add_species_concentration(self, species_concentration):
Expand Down
5 changes: 3 additions & 2 deletions src/acom_music_box/music_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os

import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -554,6 +555,7 @@ def solve(self, output_path=None):
# outputs to file if output is present
if (output_path is not None):
logger.info("path_to_output = {}".format(output_path))
os.makedirs(os.path.dirname(output_path), exist_ok=True)
with open(output_path, 'w', newline='') as output:
writer = csv.writer(output)
writer.writerows(output_array)
Expand Down Expand Up @@ -706,15 +708,14 @@ def order_reaction_rates(self, curr_conditions, rate_constant_ordering):

if (rate.reaction.reaction_type == "PHOTOLYSIS"):
key = "PHOTO." + rate.reaction.name
elif (rate.reaction.reaction_type == "LOSS"):
elif (rate.reaction.reaction_type == "FIRST_ORDER_LOSS"):
key = "LOSS." + rate.reaction.name
elif (rate.reaction.reaction_type == "EMISSION"):
key = "EMIS." + rate.reaction.name
rate_constants[key] = rate.rate

ordered_rate_constants = len(rate_constants.keys()) * [0.0]
for key, value in rate_constants.items():

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

Expand Down
18 changes: 18 additions & 0 deletions src/acom_music_box/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ def add_product(self, product):
product (Product): The Product instance to be added.
"""
self.products.append(product)

def short_type(self):
"""
Return the first letter of the reaction type.

Returns:
str: The first letter of the reaction type.
"""
type_map = {
"EMISSION": "EMIS",
"PHOTOLYSIS": "PHOT",
"FIRST_ORDER_LOSS": "LOSS",
"BRANCHED": "BRAN",
"ARRHENIUS": "ARRH",
"TUNNELING": "TUNN",
"TROE_TERNARY": "TROE",
}
return type_map.get(self.reaction_type, "UNKNOWN")


class Branched(Reaction):
Expand Down
5 changes: 0 additions & 5 deletions tests/integration/input_use_cases/1/camp_data/config.json

This file was deleted.

54 changes: 0 additions & 54 deletions tests/integration/input_use_cases/1/camp_data/species.json

This file was deleted.

32 changes: 0 additions & 32 deletions tests/integration/input_use_cases/1/config_camp.json

This file was deleted.

5 changes: 0 additions & 5 deletions tests/integration/input_use_cases/1/expected_output.csv

This file was deleted.

5 changes: 0 additions & 5 deletions tests/integration/input_use_cases/1/expected_output_camp.csv

This file was deleted.

25 changes: 0 additions & 25 deletions tests/integration/input_use_cases/1/run_camp.sh

This file was deleted.

25 changes: 0 additions & 25 deletions tests/integration/input_use_cases/1/run_preprocessed_data.sh

This file was deleted.

25 changes: 0 additions & 25 deletions tests/integration/input_use_cases/1/run_preprocessed_data_camp.sh

This file was deleted.

24 changes: 0 additions & 24 deletions tests/integration/input_use_cases/1/run_preprocessor_camp.sh

This file was deleted.

5 changes: 0 additions & 5 deletions tests/integration/input_use_cases/2/camp_data/config.json

This file was deleted.

54 changes: 0 additions & 54 deletions tests/integration/input_use_cases/2/camp_data/species.json

This file was deleted.

27 changes: 0 additions & 27 deletions tests/integration/input_use_cases/2/config_camp.json

This file was deleted.

Loading