Skip to content

Commit

Permalink
bugfix: test DiscreteTapControl.py: consider tolerance for delta
Browse files Browse the repository at this point in the history
  • Loading branch information
rbolgaryn committed May 20, 2021
1 parent 3842555 commit fe770a1
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions pandapower/test/control/test_discrete_tap_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_discrete_tap_control_lv():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == -1
assert net.trafo.tap_pos.at[0] == -1

# increase voltage from 1.0 pu to 1.03 pu
net.ext_grid.vm_pu = 1.03
Expand All @@ -54,7 +54,7 @@ def test_discrete_tap_control_lv():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == -2
assert net.trafo.tap_pos.at[0] == -2
# reduce voltage from 1.03 pu to 0.949 pu
net.ext_grid.vm_pu = 0.949
# switch back tap position
Expand All @@ -70,7 +70,7 @@ def test_discrete_tap_control_lv():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == 1
assert net.trafo.tap_pos.at[0] == 1


def test_discrete_tap_control_hv():
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_discrete_tap_control_hv():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == 1
assert net.trafo.tap_pos.at[0] == 1
# increase voltage from 1.0 pu to 1.03 pu
net.ext_grid.vm_pu = 1.03
# switch back tap position
Expand All @@ -114,7 +114,7 @@ def test_discrete_tap_control_hv():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == 2
assert net.trafo.tap_pos.at[0] == 2
# increase voltage from 1.0 pu to 1.03 pu
net.ext_grid.vm_pu = 0.949
# switch back tap position
Expand All @@ -130,7 +130,7 @@ def test_discrete_tap_control_hv():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == -1
assert net.trafo.tap_pos.at[0] == -1


def test_discrete_tap_control_lv_from_tap_step_percent():
Expand Down Expand Up @@ -158,17 +158,17 @@ def test_discrete_tap_control_lv_from_tap_step_percent():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == -1
assert net.trafo.tap_pos.at[0] == -1

# check if it changes the lower and upper limits
net.controller.object.at[0].vm_set_pu = 1
pp.runpp(net, run_control=True)
assert abs(net.controller.object.at[0].vm_upper_pu - 1.00625) < 1e-6
assert abs(net.controller.object.at[0].vm_lower_pu - 0.99375) < 1e-6
assert abs(net.controller.object.at[0].vm_upper_pu - 1.00725) < 1e-6
assert abs(net.controller.object.at[0].vm_lower_pu - 0.99275) < 1e-6
net.controller.object.at[0].vm_set_pu = 0.98
pp.runpp(net, run_control=True)
assert abs(net.controller.object.at[0].vm_upper_pu - 0.98625) < 1e-6
assert abs(net.controller.object.at[0].vm_lower_pu - 0.97375) < 1e-6
assert abs(net.controller.object.at[0].vm_upper_pu - 0.98725) < 1e-6
assert abs(net.controller.object.at[0].vm_lower_pu - 0.97275) < 1e-6

# increase voltage from 1.0 pu to 1.03 pu
net.ext_grid.vm_pu = 1.03
Expand All @@ -185,7 +185,7 @@ def test_discrete_tap_control_lv_from_tap_step_percent():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == -2
assert net.trafo.tap_pos.at[0] == -2
# reduce voltage from 1.03 pu to 0.969 pu
net.ext_grid.vm_pu = 0.969
# switch back tap position
Expand All @@ -201,7 +201,7 @@ def test_discrete_tap_control_lv_from_tap_step_percent():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == 1
assert net.trafo.tap_pos.at[0] == 1


def test_discrete_tap_control_hv_from_tap_step_percent():
Expand Down Expand Up @@ -229,17 +229,17 @@ def test_discrete_tap_control_hv_from_tap_step_percent():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == 1
assert net.trafo.tap_pos.at[0] == 1

# check if it changes the lower and upper limits
net.controller.object.at[0].vm_set_pu = 1
pp.runpp(net, run_control=True)
assert abs(net.controller.object.at[0].vm_upper_pu - 1.00625) < 1e-6
assert abs(net.controller.object.at[0].vm_lower_pu - 0.99375) < 1e-6
assert abs(net.controller.object.at[0].vm_upper_pu - 1.00725) < 1e-6
assert abs(net.controller.object.at[0].vm_lower_pu - 0.99275) < 1e-6
net.controller.object.at[0].vm_set_pu = 0.98
pp.runpp(net, run_control=True)
assert abs(net.controller.object.at[0].vm_upper_pu - 0.98625) < 1e-6
assert abs(net.controller.object.at[0].vm_lower_pu - 0.97375) < 1e-6
assert abs(net.controller.object.at[0].vm_upper_pu - 0.98725) < 1e-6
assert abs(net.controller.object.at[0].vm_lower_pu - 0.97275) < 1e-6

# increase voltage from 1.0 pu to 1.03 pu
net.ext_grid.vm_pu = 1.03
Expand All @@ -256,7 +256,7 @@ def test_discrete_tap_control_hv_from_tap_step_percent():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == 2
assert net.trafo.tap_pos.at[0] == 2
# reduce voltage from 1.03 pu to 0.969 pu
net.ext_grid.vm_pu = 0.969
# switch back tap position
Expand All @@ -272,7 +272,7 @@ def test_discrete_tap_control_hv_from_tap_step_percent():
logger.info(
"after DiscreteTapControl: trafo voltage at low voltage bus is %f, tap position is %f"
% (net.res_bus.vm_pu[net.trafo.lv_bus].values, net.trafo.tap_pos.values))
assert net.trafo.tap_pos.values == -1
assert net.trafo.tap_pos.at[0] == -1


if __name__ == '__main__':
Expand Down

0 comments on commit fe770a1

Please sign in to comment.