Skip to content

Commit

Permalink
fixed a bug in multi-timeseries-simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed Mar 6, 2024
1 parent 243706e commit 622bbfd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 3 additions & 4 deletions emerge/cli/multiscenario_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ def _run_timeseries_sim(config: ScenarioTimeseriesSimulationInput):
simulation_start_time=config.start_time,
profile_start_time=config.profile_start_time,
simulation_end_time=config.end_time,
simulation_timestep_min=config.resolution_min
simulation_timestep_min=config.resolution_min,
extra_dss_files=[str(config.scenario_file.absolute())]
)
manager.opendss_instance.execute_dss_command(f"Redirect {str(config.scenario_file)}")

subject = observer.MetricsSubject()

observers = get_observers.get_observers(config.metrics.model_dump())

for _, observer_ in observers.items():
subject.attach(observer_)


manager.simulate(subject)

Expand Down
2 changes: 1 addition & 1 deletion emerge/simulator/opendss.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def execute_dss_command(self, dss_command: str):
logger.error(f"Error executing command {dss_command} >> {error}")
raise Exception(f"Error executing command {dss_command} >> {error}")
logger.info(f"Sucessfully executed the command, {dss_command}")

return error

def set_frequency(self, frequency):
self.execute_dss_command(f"Set DefaultBaseFrequency={frequency}")
Expand Down
8 changes: 8 additions & 0 deletions emerge/simulator/simulation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(
profile_start_time: datetime.datetime,
simulation_end_time: datetime.datetime,
simulation_timestep_min: float,
extra_dss_files: Union[list[str], None] = None
)-> None:

self.path_to_master_dss_file = path_to_master_dss_file
Expand All @@ -45,6 +46,13 @@ def __init__(
self.simulation_timestep_min = simulation_timestep_min

self.opendss_instance = opendss.OpenDSSSimulator(self.path_to_master_dss_file)

if isinstance(extra_dss_files, list):
for file in extra_dss_files:
self.opendss_instance.execute_dss_command(f"Redirect {file}")
self.opendss_instance.execute_dss_command("calcv")
self.opendss_instance.execute_dss_command("solve")

self.opendss_instance.set_mode(2)
self.opendss_instance.set_simulation_time(
self.simulation_start_time,
Expand Down

0 comments on commit 622bbfd

Please sign in to comment.