Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pypsse/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""

from pathlib import Path
import sys
sys.path.append('C:\\Program Files\\PTI\\PSSE35\\35.4\\PSSPY39\\')

from loguru import logger
import click
Expand Down
38 changes: 29 additions & 9 deletions pypsse/helics_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def register_subscriptions(self):
), "HELICS co-simulations requires a subscriptions_file property populated"
sub_data = pd.read_csv(self.settings.simulation.subscriptions_file)
self.psse_dict = {}
subs_by_element_id = {}
for _, row in sub_data.iterrows():
try:
row["element_property"] = ast.literal_eval(row["element_property"])
Expand Down Expand Up @@ -236,15 +237,34 @@ def register_subscriptions(self):

element_id = str(row["element_id"])

self.subscriptions[row["sub_tag"]] = {
"bus": row["bus"],
"element_id": element_id,
"element_type": row["element_type"],
"property": row["element_property"],
"scaler": row["scaler"],
"dStates": [self.init_state] * self.n_states,
"subscription": h.helicsFederateRegisterSubscription(self.psse_federate, row["sub_tag"], ""),
}
# if there are multiple inputs with the same element target, then set it up as a multi-input, rather than a subscription:
if element_id in subs_by_element_id.keys():
matching_id_subs = subs_by_element_id[element_id]
subs_by_element_id[element_id].append(row["sub_tag"])
input = h.helicsFederateRegisterInput(self.psse_federate, matching_id_subs[0])
input.helics_handle_option_multi_input_handling_method = h.HelicsMultiInputMode.HELICS_MULTI_INPUT_NO_OP
input.helics_handle_option_targets = subs_by_element_id[element_id]
self.subscriptions[matching_id_subs[0]] = {
"bus": row["bus"],
"element_id": element_id,
"element_type": row["element_type"],
"property": row["element_property"],
"scaler": row["scaler"],
"dStates": [self.init_state] * self.n_states,
"subscription": input
}
msg = f"WARNING: Subscription element id {element_id} is duplicated, processed as multi-input with targets: {subs_by_element_id[element_id]}"
raise Warning(msg)
else:
self.subscriptions[row["sub_tag"]] = {
"bus": row["bus"],
"element_id": element_id,
"element_type": row["element_type"],
"property": row["element_property"],
"scaler": row["scaler"],
"dStates": [self.init_state] * self.n_states,
"subscription": h.helicsFederateRegisterSubscription(self.psse_federate, row["sub_tag"], ""),
}

logger.info(
"{} property of element {}.{} at bus {} has subscribed to {}".format(
Expand Down
4 changes: 2 additions & 2 deletions pypsse/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import toml
from loguru import logger
from networkx import Graph
import pssepath
sys.path.append('C:\\Program Files\\PTI\\PSSE35\\35.4\\PSSPY39\\')#import pssepath
import pypsse.contingencies as c
import pypsse.simulation_controller as sc
from pypsse.common import (
Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(
self.settings = settings

logger.debug(f"Instantiating psse version {psse_version}")
pssepath.add_pssepath(35.4)
#pssepath.add_pssepath(35.4)
__import__(psse_version, fromlist=[""]) # noqa: F401

import dyntools
Expand Down