Skip to content

Commit

Permalink
Merge pull request #194 from NCAR/main
Browse files Browse the repository at this point in the history
Version 2.2.1
  • Loading branch information
K20shores committed Aug 23, 2024
2 parents 989d5c2 + 4c35844 commit 8dc210d
Show file tree
Hide file tree
Showing 134 changed files with 37 additions and 3,334 deletions.
2 changes: 1 addition & 1 deletion src/acom_music_box/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This package contains modules for handling various aspects of a music box,
including species, products, reactants, reactions, and more.
"""
__version__ = "2.2.0"
__version__ = "2.2.1"

from .utils import convert_time, convert_pressure, convert_temperature, convert_concentration
from .species import Species
Expand Down
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:
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 @@ -60,6 +60,24 @@ def add_product(self, product):
"""
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.

Loading

0 comments on commit 8dc210d

Please sign in to comment.