Skip to content

Commit

Permalink
fixed evolving conditions not setting attributes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjamesgarza committed Apr 2, 2024
1 parent 597c508 commit 8cea0c8
Show file tree
Hide file tree
Showing 9 changed files with 4,089 additions and 1,049 deletions.
25 changes: 18 additions & 7 deletions src/box_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,16 @@ def solve(self, path_to_output = None):
next_conditions = None
next_conditions_time = 0
next_conditions_index = 0
if(len(self.evolving_conditions.conditions) != 0):
next_conditions_index = 0
next_conditions = self.evolving_conditions.conditions[0]
next_conditions_time = self.evolving_conditions.times[0]
if(len(self.evolving_conditions) != 0):
if(self.evolving_conditions.times[0] != 0):
next_conditions_index = 0
next_conditions = self.evolving_conditions.conditions[0]
next_conditions_time = self.evolving_conditions.times[0]
elif(len(self.evolving_conditions) > 1):
next_conditions_index = 1
next_conditions = self.evolving_conditions.conditions[1]
next_conditions_time = self.evolving_conditions.times[1]


#initalizes output headers
output_array = []
Expand All @@ -428,10 +434,9 @@ def solve(self, path_to_output = None):
next_output_time = curr_time
#runs the simulation at each timestep



while(curr_time <= self.box_model_options.simulation_length):

#outputs to output_array if enough time has elapsed
if(next_output_time <= curr_time):
row = []
Expand All @@ -445,8 +450,10 @@ def solve(self, path_to_output = None):

#iterates evolvings conditons if enough time has elapsed
if(next_conditions != None and next_conditions_time <= curr_time):

#curr_conditions = next_conditions
curr_conditions.update_conditions(next_conditions)


#iterates next_conditions if there are remaining evolving conditions
if(len(self.evolving_conditions) > next_conditions_index + 1):
Expand All @@ -459,14 +466,17 @@ def solve(self, path_to_output = None):
if(len(curr_conditions.get_concentration_array()) != 0):
ordered_concentrations = self.order_species_concentrations(curr_conditions, species_constant_ordering)

ordered_rate_constants = self.order_reaction_rates(curr_conditions, rate_constant_ordering)

else:
next_conditions = None


#print(ordered_rate_constants)


#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)



#increments time
Expand Down Expand Up @@ -550,6 +560,7 @@ def order_species_concentrations(self, curr_conditions, species_constant_orderin
concentrations[concentraton.species.name] = concentraton.concentration

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

for key, value in concentrations.items():

ordered_concentrations[species_constant_ordering[key]] = value
Expand Down
1 change: 1 addition & 0 deletions src/configs/test_config_3/camp_data/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"camp-files": ["species.json", "reactions.json"]}
118 changes: 118 additions & 0 deletions src/configs/test_config_3/camp_data/reactions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"camp-data": [
{
"type": "MECHANISM",
"name": "music box interactive configuration",
"reactions": [
{
"type": "ARRHENIUS",
"A": 8e-12,
"Ea": 2.8428e-20,
"B": 0,
"D": 300,
"E": 0,
"reactants": {
"O": {
"qty": 1
},
"O3": {
"qty": 1
}
},
"products": {
"O2": {
"yield": 2
},
"irr__228bcf53-cf76-46cb-b952-68a76a044353": {
"yield": 1
}
}
},
{
"type": "ARRHENIUS",
"A": 6e-34,
"Ea": 0,
"B": -2.4,
"D": 300,
"E": 0,
"reactants": {
"O": {
"qty": 1
},
"O2": {
"qty": 1
},
"M": {
"qty": 1
}
},
"products": {
"O3": {
"yield": 1
},
"M": {
"yield": 1
},
"irr__2f09b69b-d831-453a-9d3d-716c6df06d9b": {
"yield": 1
}
}
},
{
"type": "ARRHENIUS",
"A": 2.15e-11,
"Ea": -1.518e-21,
"B": 0,
"D": 300,
"E": 0,
"reactants": {
"O1D": {
"qty": 1
},
"N2": {
"qty": 1
}
},
"products": {
"O": {
"yield": 1
},
"N2": {
"yield": 1
},
"irr__bddff497-90b2-4af9-9b1d-39cb2bc5ea39": {
"yield": 1
}
}
},
{
"type": "ARRHENIUS",
"A": 3.3e-11,
"Ea": -7.59e-22,
"B": 0,
"D": 300,
"E": 0,
"reactants": {
"O1D": {
"qty": 1
},
"O2": {
"qty": 1
}
},
"products": {
"O": {
"yield": 1
},
"O2": {
"yield": 1
},
"irr__cf3f20f2-140d-4cb7-a99d-8a37c3c25705": {
"yield": 1
}
}
}
]
}
]
}
1 change: 1 addition & 0 deletions src/configs/test_config_3/camp_data/species.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"camp-data": [{"name": "M", "type": "CHEM_SPEC", "tracer type": "CONSTANT"}, {"name": "Ar", "type": "CHEM_SPEC", "absolute tolerance": 1e-12}, {"name": "CO2", "type": "CHEM_SPEC", "absolute tolerance": 1e-12}, {"name": "H2O", "type": "CHEM_SPEC", "absolute tolerance": 1e-12}, {"name": "O1D", "type": "CHEM_SPEC", "absolute tolerance": 1e-12}, {"name": "O", "type": "CHEM_SPEC", "absolute tolerance": 1e-12}, {"name": "O2", "type": "CHEM_SPEC", "absolute tolerance": 1e-12}, {"name": "O3", "type": "CHEM_SPEC", "absolute tolerance": 1e-12}, {"name": "N2", "type": "CHEM_SPEC", "absolute tolerance": 1e-12}, {"name": "irr__228bcf53-cf76-46cb-b952-68a76a044353", "type": "CHEM_SPEC"}, {"name": "irr__2f09b69b-d831-453a-9d3d-716c6df06d9b", "type": "CHEM_SPEC"}, {"name": "irr__bddff497-90b2-4af9-9b1d-39cb2bc5ea39", "type": "CHEM_SPEC"}, {"name": "irr__cf3f20f2-140d-4cb7-a99d-8a37c3c25705", "type": "CHEM_SPEC"}]}
Loading

0 comments on commit 8cea0c8

Please sign in to comment.