Skip to content

Commit

Permalink
Merge pull request #10 from sogno-platform/feature/cgmes-pgm-converter
Browse files Browse the repository at this point in the history
move cgmes_pgm_converter
  • Loading branch information
petersalemink95 authored Nov 9, 2023
2 parents aa39bff + 9c507d9 commit 249749d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/run_power_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests
import glob

from cgmes_pgm_converter import System
from src.pgm_service.power_grid.cgmes_pgm_converter import System

logging.basicConfig(filename='run_powerflow.log', level=logging.INFO, filemode='w')

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers=[
"Operating System :: MacOS",
"Topic :: Scientific/Engineering :: Physics",
]
requires-python = ">=3.12"
requires-python = ">=3.10"
dependencies = [
"numpy>=1.20",
"power_grid_model>=1.6",
Expand Down
Empty file added src/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def load_cim_data(self, res):
# list_SvPowerFlow = [elem for elem in res.values() if elem.__class__.__name__ == "SvPowerFlow"]
# list_EnergySources = [elem for elem in res.values() if elem.__class__.__name__ == "EnergySource"]
# list_EnergyConsumer = [elem for elem in res.values() if elem.__class__.__name__ == "EnergyConsumer"]
# list_ACLineSegment = [elem for elem in res.values() if elem.__class__.__name__ == "ACLineSegment"]
# list_Terminals = [elem for elem in res.values() if elem.__class__.__name__ == "Terminal"]
list_ACLineSegment = [elem for elem in res['topology'].values() if elem.__class__.__name__ == "ACLineSegment"]
list_Terminals = [elem for elem in res['topology'].values() if elem.__class__.__name__ == "Terminal"]
# list_Terminals_ES = [elem for elem in list_Terminals if
# elem.ConductingEquipment.__class__.__name__ == "EnergySource"]
# list_Terminals_EC = [elem for elem in list_Terminals if
Expand All @@ -35,11 +35,16 @@ def load_cim_data(self, res):
self.nodes.append(TPNode.mRID)
self.voltages.append(dict_VoltageLevel[TPNode])

# # create branches type ACLineSegment
# for ACLineSegment in list_ACLineSegment:
# self.lines[ACLineSegment]
# create branches type ACLineSegment
for ACLineSegment in list_ACLineSegment:
uuid_ACLineSegment = ACLineSegment.mRID
connected_nodes = self._get_nodes(list_Terminals, uuid_ACLineSegment)
node_ids = list[connected_nodes.keys()]
status = list[connected_nodes.values()]
# self.lines[ACLineSegment.mRID] = {"from_node": node_ids[0],
# "to_node": node_ids[1]}

# line = initialize_array("input", "line", len(self.lines))
line = initialize_array("input", "line", len(self.lines))
# line["id"] =
# line["from_node"] =
# line["to_node"] =
Expand All @@ -60,3 +65,23 @@ def create_pgm_input(self):
print("debug")

return {"node": node}

def _get_nodes(self, list_Terminals, elem_uuid):
start_node_uuid = None
end_node_uuid = None
start_node_connected = None
end_node_connected = None

for terminal in list_Terminals:
if terminal.ConductingEquipment.mRID != elem_uuid:
continue
sequence_number = terminal.sequenceNumber
if sequence_number == 1:
start_node_uuid = terminal.TopologicalNode.mRID
start_node_connected = terminal.connected
elif sequence_number == 2:
end_node_uuid = terminal.TopologicalNode.mRID
end_node_connected = terminal.connected


return {start_node_uuid: start_node_connected, end_node_uuid: end_node_connected}

0 comments on commit 249749d

Please sign in to comment.