Skip to content

Commit

Permalink
Remove more redundant variables in modelica step_run.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Jan 31, 2025
1 parent d5e9098 commit fdbcaa5
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions alfalfa_worker/jobs/modelica/step_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ class StepRun(StepRunBase):
def __init__(self, run_id, realtime, timescale, external_clock, start_datetime: datetime, end_datetime) -> None:
self.checkout_run(run_id)
super().__init__(run_id, realtime, timescale, external_clock, start_datetime, end_datetime)
sim_year = self.options.start_datetime.year
self.sim_start_time = (self.options.start_datetime - datetime(sim_year, 1, 1)) / timedelta(seconds=1)
self.sim_end_time = (self.options.end_datetime - datetime(sim_year, 1, 1)) / timedelta(seconds=1)

self.logger.info(f"current datetime at start of simulation: {self.options.start_datetime}")

Expand All @@ -22,7 +19,6 @@ def __init__(self, run_id, realtime, timescale, external_clock, start_datetime:
self.options.timestep_duration = timedelta(minutes=1)

# run the FMU simulation
self.simtime = self.sim_start_time
self.set_run_time(self.options.start_datetime)

# Allow model to warm up in first timestep without failing due to falling behind timescale
Expand All @@ -33,7 +29,7 @@ def initialize_simulation(self) -> None:
# Load fmu
config = {
'fmupath': fmupath,
'start_time': self.sim_start_time,
'start_time': (self.options.start_datetime - datetime(self.options.start_datetime.year, 1, 1)) / timedelta(seconds=1),
'step': self.options.timestep_duration / timedelta(seconds=1),
'kpipath': self.dir / 'resources' / 'kpis.json'
}
Expand All @@ -45,9 +41,6 @@ def initialize_simulation(self) -> None:
def check_simulation_stop_conditions(self) -> bool:
return False

def time_per_step(self):
return timedelta(seconds=self.step_size)

def get_sim_time(self) -> datetime:
sim_time = datetime(self.options.start_datetime.year, 1, 1, 0, 0, 0) + timedelta(seconds=float(self.tc.final_time))
self.logger.info(f"Current Sim Time: {sim_time}")
Expand Down

0 comments on commit fdbcaa5

Please sign in to comment.