Skip to content

Commit b4b6175

Browse files
authored
Merge pull request #34 from PowerGridModel/fix/swap_solution
fix: load the correct solution
2 parents 37748f1 + 0b032ab commit b4b6175

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed
Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
from power_grid_model_ds import PowerGridModelInterface
2-
3-
def check_for_capacity_issues(grid: Grid) -> LineArray:
4-
"""Check for capacity issues on the grid.
5-
Return the lines that with capacity issues.
1+
def build_new_substation(grid: Grid, location: tuple[float, float]) -> NodeArray:
2+
"""Build a new substation at the given location.
3+
Return the new substation.
64
"""
7-
pgm_interface = PowerGridModelInterface(grid)
8-
pgm_interface.calculate_power_flow()
9-
pgm_interface.update_grid()
5+
new_substation = MyNodeArray(
6+
node_type=[NodeType.SUBSTATION_NODE.value],
7+
u_rated=[10500.0],
8+
x=[location[0]],
9+
y=[location[1]]
10+
)
11+
grid.append(new_substation)
1012

11-
return grid.line[grid.line.is_overloaded]
13+
new_source = SourceArray(
14+
node=[new_substation.id.item()],
15+
status=[1],
16+
u_ref=[1],
17+
)
18+
grid.append(new_source)
19+
return new_substation
1220

13-
print(check_for_capacity_issues(grid))
21+
# 🏗️ Add a new substation at (400, 400)
22+
new_substation = build_new_substation(grid, (400, 400))

0 commit comments

Comments
 (0)