Skip to content

Commit

Permalink
fixed inital conditions for reaction rates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjamesgarza committed Apr 16, 2024
1 parent 4afde18 commit 3081ab8
Show file tree
Hide file tree
Showing 6 changed files with 3,620 additions and 3,610 deletions.
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 @@ -121,8 +121,9 @@ def generateConfig(self, directory):
data["initial conditions"] = {}

for reaction_rate in self.initial_conditions.reaction_rates:
name = "PHOT." + reaction_rate.reaction.name + ".s-1"
data["initial conditions"][name] = reaction_rate.rate
if(reaction_rate.reaction.reaction_type == "PHOTOLYSIS"):
name = "PHOT." + reaction_rate.reaction.name + ".s-1"
data["initial conditions"][name] = reaction_rate.rate

data["model components"] = [
{
Expand Down
16 changes: 13 additions & 3 deletions src/acom_music_box/music_box_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,22 @@ def from_config_JSON(cls, config_JSON, species_list, reaction_list):

# Set initial species concentrations
species_concentrations = []
reaction_rates = []

#reads initial conditions from csv if it is given
if 'initial conditions' in config_JSON:
initial_conditions_csv = config_JSON['initial conditions']
#initial_conditions_csv = config_JSON['initial conditions']

#read_initial_conditions_from_csv(initial_conditions_csv)
for reaction_rate in config_JSON['initial conditions']:

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

reaction = next(match, None)

rate = config_JSON['initial conditions'][reaction_rate]

reaction_rates.append(ReactionRate(reaction, rate))

#reads from config file directly if present
if 'chemical species' in config_JSON:
Expand All @@ -105,13 +116,12 @@ def from_config_JSON(cls, config_JSON, species_list, reaction_list):

#TODO: may or may not be necessary
# Set initial reaction rates
reaction_rates = []

for reaction in reaction_list.reactions:
if reaction.name != None and not any(reac.reaction.name == reaction.name for reac in reaction_rates):
reaction_rates.append(ReactionRate(reaction, 0))


return cls(pressure, temperature, species_concentrations, reaction_rates)


Expand Down
4 changes: 2 additions & 2 deletions tests/configs/wall_loss_config/camp_data/reactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"type": "PHOTOLYSIS",


"scaling factor": 1,
"MUSICA name": "LOSS_SOA1 wall loss",
"reactants": {
"SOA1": {}
Expand All @@ -21,7 +21,7 @@
{
"type": "PHOTOLYSIS",


"scaling factor": 1,
"MUSICA name": "LOSS_SOA2 wall loss",
"reactants": {
"SOA2": {}
Expand Down
2 changes: 0 additions & 2 deletions tests/configs/wall_loss_config/initial_conditions.csv

This file was deleted.

3 changes: 2 additions & 1 deletion tests/configs/wall_loss_config/my_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
}
},
"initial conditions": {
"initial_conditions.csv": {}
"PHOT.LOSS_SOA1 wall loss.s-1": 0.01,
"PHOT.LOSS_SOA2 wall loss.s-1": 0.05
},
"model components": [
{
Expand Down
Loading

0 comments on commit 3081ab8

Please sign in to comment.