Skip to content
Merged
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
29 changes: 19 additions & 10 deletions power-grid-model-ds/solutions/advanced_4_build_new_substation.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from power_grid_model_ds import PowerGridModelInterface

def check_for_capacity_issues(grid: Grid) -> LineArray:
"""Check for capacity issues on the grid.
Return the lines that with capacity issues.
def build_new_substation(grid: Grid, location: tuple[float, float]) -> NodeArray:
"""Build a new substation at the given location.
Return the new substation.
"""
pgm_interface = PowerGridModelInterface(grid)
pgm_interface.calculate_power_flow()
pgm_interface.update_grid()
new_substation = MyNodeArray(
node_type=[NodeType.SUBSTATION_NODE.value],
u_rated=[10500.0],
x=[location[0]],
y=[location[1]]
)
grid.append(new_substation)

return grid.line[grid.line.is_overloaded]
new_source = SourceArray(
node=[new_substation.id.item()],
status=[1],
u_ref=[1],
)
grid.append(new_source)
return new_substation

print(check_for_capacity_issues(grid))
# 🏗️ Add a new substation at (400, 400)
new_substation = build_new_substation(grid, (400, 400))