Skip to content

Commit

Permalink
fixed solve to inc by seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjamesgarza committed Mar 26, 2024
1 parent 74ee215 commit 0a4f600
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/box_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ def solve(self):
# Update the internal state of the BoxModel instance to reflect the simulation results.


#simulation time in minutes
sim_length_min = self.box_model_options.simulation_length * 60
#simulation time in seconds
sim_length_seconds = self.box_model_options.simulation_length * 60 * 60
print(sim_length_seconds)

#sets up initial conditions to be current conditions
curr_conditions = self.initial_conditions
Expand All @@ -292,10 +293,12 @@ def solve(self):
next_conditions = self.evolving_conditions.conditions[0]
next_conditions_time = self.evolving_conditions.times[0]


print(self.box_model_options.chem_step_time)
#runs the simulation at each timestep
curr_time = 0
while(curr_time < sim_length_min):

while(curr_time < sim_length_seconds):
print(curr_concentrations)

#iterates evolvings conditons if enough time has elapsed
if(next_conditions != None and next_conditions_time <= curr_time):
Expand All @@ -317,11 +320,8 @@ def solve(self):
musica.micm_solve(self.solver, self.box_model_options.chem_step_time, curr_conditions.temperature, curr_conditions.pressure, curr_concentrations)

#increments time
curr_time += self.box_model_options.chem_step_time

print(curr_concentrations)


curr_time += self.box_model_options.chem_step_time

def readFromJson(self, path_to_json):
"""
TODO: Read the box model configuration from json and sets config
Expand Down
10 changes: 5 additions & 5 deletions src/music_box_model_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BoxModelOptions:
Attributes:
grid (str): The type of grid. Default is "box".
chemStepTime (float): Time step for chemical reactions in the simulation in minutes.
chemStepTime (float): Time step for chemical reactions in the simulation in seconds.
outputStepTime (float): Time step for output data in the simulation in hours.
simulationLength (float): Length of the simulation in hours.
"""
Expand All @@ -16,7 +16,7 @@ def __init__(self, chem_step_time, output_step_time, simulation_length, grid="bo
Initializes a new instance of the BoxModelOptions class.
Args:
chem_step_time (float): Time step for chemical reactions in the simulation in minutes.
chem_step_time (float): Time step for chemical reactions in the simulation in seconds.
output_step_time (float): Time step for output data in the simulation in hours.
simulation_length (float): Length of the simulation in hours.
grid (str): The type of grid. Default is "box".
Expand All @@ -37,7 +37,7 @@ def from_UI_JSON(cls, UI_JSON):
Returns:
BoxModelOptions: A new instance of the BoxModelOptions class.
"""
chem_step_time = utils.convert_time(UI_JSON['conditions']['box model options'], 'chemistry time step') * 60
chem_step_time = utils.convert_time(UI_JSON['conditions']['box model options'], 'chemistry time step') * 60 * 60
output_step_time = utils.convert_time(UI_JSON['conditions']['box model options'], 'output time step')
simulation_length = utils.convert_time(UI_JSON['conditions']['box model options'], 'simulation length')

Expand All @@ -49,8 +49,8 @@ def from_UI_JSON(cls, UI_JSON):
@classmethod
def from_config_JSON(cls, config_JSON):

chem_step_time = utils.convert_time(config_JSON['box model options'], 'chemistry time step') * 60
output_step_time = utils.convert_time(config_JSON['box model options'], 'output time step')
chem_step_time = utils.convert_time(config_JSON['box model options'], 'chemistry time step') * 60 * 60
output_step_time = utils.convert_time(config_JSON['box model options'], 'output time step')
simulation_length = utils.convert_time(config_JSON['box model options'], 'simulation length')

grid = config_JSON['box model options']['grid']
Expand Down

0 comments on commit 0a4f600

Please sign in to comment.