88import pytest
99from numpy .typing import NDArray
1010from power_grid_model import LoadGenType , TapChangingStrategy , initialize_array
11- from power_grid_model .enum import BranchSide , WindingType
11+ from power_grid_model .enum import BranchSide
1212
1313from power_grid_model_ds ._core .data_source .generator .grid_generators import RadialGridGenerator
1414from power_grid_model_ds ._core .load_flow import PowerGridModelInterface
@@ -60,41 +60,9 @@ def test_load_flow_on_random():
6060 assert all (output ["line" ]["i_from" ] > 0 )
6161
6262
63- def test_load_flow (grid : Grid ):
63+ def test_load_flow (simple_loadflow_grid : Grid ):
6464 """Tests the power flow on a test grid with 2 nodes"""
65- nodes = NodeArray .zeros (2 )
66- nodes .id = [0 , 1 ]
67- nodes .u_rated = [10_500 ] * 2
68-
69- lines = LineArray .zeros (1 )
70- lines .id = [2 ]
71- lines .from_node = [0 ]
72- lines .to_node = [1 ]
73- lines .from_status = [1 ]
74- lines .to_status = [1 ]
75- lines .r1 = [0.1 ]
76- lines .x1 = [0.01 ]
77-
78- sources = SourceArray .zeros (1 )
79- sources .id = [3 ]
80- sources .node = [0 ]
81- sources .status = [1 ]
82- sources .u_ref = [1 ]
83-
84- loads = SymLoadArray .zeros (1 )
85- loads .id = [4 ]
86- loads .node = [1 ]
87- loads .status = [1 ]
88- loads .type = [LoadGenType .const_power ]
89- loads .p_specified = [250_000 ]
90- loads .q_specified = [50_000 ]
91-
92- grid .append (nodes )
93- grid .append (lines )
94- grid .append (sources )
95- grid .append (loads )
96-
97- core_interface = PowerGridModelInterface (grid = grid )
65+ core_interface = PowerGridModelInterface (grid = simple_loadflow_grid )
9866 core_interface .create_input_from_grid ()
9967 output = core_interface .calculate_power_flow ()
10068
@@ -105,65 +73,9 @@ def test_load_flow(grid: Grid):
10573 assert all (output ["line" ]["i_from" ] > 0 )
10674
10775
108- def test_load_flow_with_transformer (grid : Grid ):
76+ def test_load_flow_with_transformer (loadflow_grid_with_transformer : Grid ):
10977 """Tests the power flow on a test grid with 3 nodes and a trafo"""
110- nodes = NodeArray .zeros (3 )
111- nodes .id = [0 , 1 , 2 ]
112- nodes .u_rated = [10_500 ] * 2 + [3_000 ]
113-
114- lines = LineArray .zeros (1 )
115- lines .id = 3
116- lines .from_node = 0
117- lines .to_node = 1
118- lines .from_status = 1
119- lines .to_status = 1
120- lines .r1 = 0.1
121- lines .x1 = 0.01
122-
123- sources = SourceArray .zeros (1 )
124- sources .id = 4
125- sources .node = 0
126- sources .status = 1
127- sources .u_ref = 1
128-
129- loads = SymLoadArray .zeros (2 )
130- loads .id = [5 , 6 ]
131- loads .node = [1 , 2 ]
132- loads .status = [1 , 1 ]
133- loads .p_specified = [25_000 ] * 2
134- loads .q_specified = [5_000 ] * 2
135-
136- transformers = TransformerArray (
137- id = [7 ],
138- from_node = [1 ],
139- to_node = [2 ],
140- from_status = [1 ],
141- to_status = [1 ],
142- u1 = [10_500 ],
143- u2 = [3_000 ],
144- sn = [30e6 ],
145- clock = [12 ],
146- tap_size = [2.5e3 ],
147- uk = [0.203 ],
148- pk = [100e3 ],
149- i0 = [0.0 ],
150- p0 = [0.0 ],
151- winding_from = [WindingType .wye .value ],
152- winding_to = [WindingType .wye .value ],
153- tap_side = [BranchSide .from_side .value ],
154- tap_pos = [0 ],
155- tap_min = [- 11 ],
156- tap_max = [9 ],
157- tap_nom = [0 ],
158- )
159-
160- grid .append (nodes )
161- grid .append (lines )
162- grid .append (sources )
163- grid .append (loads )
164- grid .append (transformers )
165-
166- core_interface = PowerGridModelInterface (grid = grid )
78+ core_interface = PowerGridModelInterface (grid = loadflow_grid_with_transformer )
16779 core_interface .create_input_from_grid ()
16880 output = core_interface .calculate_power_flow ()
16981
0 commit comments