99 Ground ,
1010 Line ,
1111 LineParameters ,
12+ PositiveSequence ,
1213 PotentialRef ,
1314 PowerLoad ,
1415 RoseauLoadFlowException ,
@@ -214,31 +215,29 @@ def test_voltage_limits(recwarn):
214215def test_res_voltages ():
215216 # With a neutral
216217 bus = Bus (id = "bus" , phases = "abcn" )
217- direct_seq = np .exp ([0 , - 2 / 3 * np .pi * 1j , 2 / 3 * np .pi * 1j ])
218- direct_seq_neutral = np .array ([1 , np .exp (- 2 / 3 * np .pi * 1j ), np .exp (2 / 3 * np .pi * 1j ), 0 ])
218+ direct_seq_neutral = np .array ([* PositiveSequence , 0 ])
219219 bus ._res_potentials = (230 + 0j ) * direct_seq_neutral
220220
221221 assert np .allclose (bus .res_potentials .m , (230 + 0j ) * direct_seq_neutral )
222- assert np .allclose (bus .res_voltages .m , (230 + 0j ) * direct_seq )
222+ assert np .allclose (bus .res_voltages .m , (230 + 0j ) * PositiveSequence )
223223 assert bus .res_voltage_levels is None
224224 bus .nominal_voltage = 400 # V
225225 assert np .allclose (bus .res_voltage_levels .m , 230 / 400 * np .sqrt (3 ))
226226
227227 # Without a neutral
228228 bus = Bus (id = "bus" , phases = "abc" )
229- bus ._res_potentials = (20_000 + 0j ) * direct_seq / np .sqrt (3 )
229+ bus ._res_potentials = (20e3 + 0j ) * PositiveSequence / np .sqrt (3 )
230230
231- assert np .allclose (bus .res_potentials .m , (20_000 + 0j ) * direct_seq / np .sqrt (3 ))
232- assert np .allclose (bus .res_voltages .m , (20_000 + 0j ) * direct_seq * np .exp (np .pi * 1j / 6 ))
231+ assert np .allclose (bus .res_potentials .m , (20e3 + 0j ) * PositiveSequence / np .sqrt (3 ))
232+ assert np .allclose (bus .res_voltages .m , (20e3 + 0j ) * PositiveSequence * np .exp (np .pi * 1j / 6 ))
233233 assert bus .res_voltage_levels is None
234- bus .nominal_voltage = 20_000 # V
234+ bus .nominal_voltage = 20e3 # V
235235 assert np .allclose (bus .res_voltage_levels .m , 1.0 )
236236
237237
238238def test_res_violated ():
239239 bus = Bus (id = "bus" , phases = "abc" )
240- direct_seq = np .exp ([0 , - 2 / 3 * np .pi * 1j , 2 / 3 * np .pi * 1j ])
241- bus ._res_potentials = (230 + 0j ) * direct_seq
240+ bus ._res_potentials = (230 + 0j ) * PositiveSequence
242241
243242 # No limits
244243 assert bus .res_violated is None
@@ -249,29 +248,35 @@ def test_res_violated():
249248
250249 # Only min voltage
251250 bus .min_voltage_level = 0.9
252- assert bus .res_violated is False
251+ assert ( bus .res_violated == [ False , False , False ]). all ()
253252 bus .min_voltage_level = 1.1
254- assert bus .res_violated is True
253+ assert ( bus .res_violated == [ True , True , True ]). all ()
255254
256255 # Only max voltage
257256 bus .min_voltage_level = None
258257 bus .max_voltage_level = 1.1
259- assert bus .res_violated is False
258+ assert ( bus .res_violated == [ False , False , False ]). all ()
260259 bus .max_voltage_level = 0.9
261- assert bus .res_violated is True
260+ assert ( bus .res_violated == [ True , True , True ]). all ()
262261
263262 # Both min and max voltage
264263 # min <= v <= max
265264 bus .min_voltage_level = 0.9
266265 bus .max_voltage_level = 1.1
267- assert bus .res_violated is False
266+ assert ( bus .res_violated == [ False , False , False ]). all ()
268267 # v < min
269268 bus .min_voltage_level = 1.1
270- assert bus .res_violated is True
269+ assert ( bus .res_violated == [ True , True , True ]). all ()
271270 # v > max
272271 bus .min_voltage_level = 0.9
273272 bus .max_voltage_level = 0.9
274- assert bus .res_violated is True
273+ assert (bus .res_violated == [True , True , True ]).all ()
274+
275+ # Not all phases are violated
276+ bus .min_voltage_level = 0.9
277+ bus .max_voltage_level = 1.1
278+ bus ._res_potentials [0 ] = 300 + 0j
279+ assert (bus .res_violated == [True , False , True ]).all ()
275280
276281
277282def test_propagate_limits (): # noqa: C901
0 commit comments