Skip to content

Commit

Permalink
Merge pull request e2nIEE#1365 from rbolgaryn/tap_dependent_impedance
Browse files Browse the repository at this point in the history
Tap dependent impedance
  • Loading branch information
rbolgaryn authored Oct 18, 2021
2 parents 0a7b232 + 8a1ea14 commit 5efc9d5
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 94 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Change Log
- [ADDED] "results" initialization for runopp()
- [CHANGED] toolbox function nets_equal()
- [ADDED] toolbox function merge_same_bus_generation_plants()
- [ADDED] TapDependentImpedance controller that adjusts the transformer parameters (e.g. vk_percent, vkr_percent) according to the tap position, based on a specified characteristic

[2.7.1]- 2021-07-22
----------------------
Expand Down
1 change: 1 addition & 0 deletions pandapower/control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pandapower.control.controller.trafo.ContinuousTapControl import ContinuousTapControl
from pandapower.control.controller.trafo.DiscreteTapControl import DiscreteTapControl
from pandapower.control.controller.trafo.USetTapControl import USetTapControl
from pandapower.control.controller.trafo.TapDependentImpedance import TapDependentImpedance
from pandapower.control.controller.trafo_control import TrafoController

# --- Other ---
Expand Down
46 changes: 46 additions & 0 deletions pandapower/control/controller/trafo/TapDependentImpedance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2016-2021 by University of Kassel and Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), Kassel. All rights reserved.

from pandapower.control.controller.characteristic_control import CharacteristicControl
from pandapower.control.util.characteristic import Characteristic

class TapDependentImpedance(CharacteristicControl):
"""
Controller that adjusts the impedance of a transformer (or multiple transformers) depending to the actual tap position and
according to a defined characteristic.
INPUT:
**net** (attrdict) - Pandapower net
**tid** (int or list or numpy array) - ID of the transformer or multiple transfromers
**characteristic** (object of class Characteristic) - Characteristic that describes the relationship between transformer tap
position and transformer impedance
OPTIONAL:
**in_service** (bool, True) - Indicates if the controller is currently in_service
**drop_same_existing_ctrl** (bool, False) - Indicates if already existing controllers of the same type and with the same matching parameters (e.g. at same element) should be dropped
"""

def __init__(self, net, transformer_index, characteristic, trafotable="trafo", output_variable="vk_percent", tol=1e-3, restore=True,
in_service=True, order=0, level=0, drop_same_existing_ctrl=False, matching_params=None, **kwargs):
if matching_params is None:
matching_params = {"transformer_index": transformer_index, 'output_variable': output_variable}
super().__init__(net, output_element=trafotable, output_variable=output_variable, output_element_index=transformer_index,
input_element=trafotable, input_variable="tap_pos", input_element_index=transformer_index,
characteristic=characteristic, tol=tol, in_service=in_service, order=order,
level=level, drop_same_existing_ctrl=drop_same_existing_ctrl, matching_params=matching_params, **kwargs)
self.restore=restore
self.initial_values = net[trafotable].loc[transformer_index, output_variable].copy()

def initialize_control(self, net):
if self.restore:
self.initial_values = net[self.output_element].loc[self.output_element_index, self.output_variable].copy()

def finalize_control(self, net):
if self.restore:
net[self.output_element].loc[self.output_element_index, self.output_variable] = self.initial_values
94 changes: 0 additions & 94 deletions pandapower/control/controller/trafo/u_setofp.py

This file was deleted.

75 changes: 75 additions & 0 deletions pandapower/test/control/test_tap_dependent_impedance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2016-2021 by University of Kassel and Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), Kassel. All rights reserved.

import pytest
import pandapower as pp
from pandapower.control import Characteristic, TapDependentImpedance


def test_tap_dependent_impedance_control():
net = pp.create_empty_network()
b1 = pp.create_bus(net, 110)
b2 = pp.create_bus(net, 20)
pp.create_ext_grid(net, b1)
pp.create_transformer_from_parameters(net, b1, b2, 40, 110, 21, 0.5, 12.3, 25, 0.11, 0, 'hv', 10, 20, 0, 1.8, 180, 10)

characteristic_vk = Characteristic.from_points(((0, 13.5), (10, 12.3), (20, 11.1)))
characteristic_vkr = Characteristic.from_points(((0, 0.52), (10, 0.5), (20, 0.53)))
TapDependentImpedance(net, 0, characteristic_vk, output_variable='vk_percent', restore=False)
TapDependentImpedance(net, 0, characteristic_vkr, output_variable='vkr_percent', restore=False)

pp.runpp(net, run_control=True)
assert net.trafo.vk_percent.at[0] == 12.3
assert net.trafo.vkr_percent.at[0] == 0.5

net.trafo.tap_pos = 0
pp.runpp(net, run_control=True)
assert net.trafo.vk_percent.at[0] == 13.5
assert net.trafo.vkr_percent.at[0] == 0.52

net.trafo.tap_pos = 20
pp.runpp(net, run_control=True)
assert net.trafo.vk_percent.at[0] == 11.1
assert net.trafo.vkr_percent.at[0] == 0.53


def test_tap_dependent_impedance_restore():
net = pp.create_empty_network()
b1 = pp.create_bus(net, 110)
b2 = pp.create_bus(net, 20)
pp.create_ext_grid(net, b1)
pp.create_load(net, b2, 20)
pp.create_transformer_from_parameters(net, b1, b2, 40, 110, 21, 0.5, 12.3, 25, 0.11, 0, 'hv', 10, 20, 0, 1.8, 180, 10)

characteristic_vk = Characteristic.from_points(((0, 13.5), (10, 12.3), (20, 11.1)))
characteristic_vkr = Characteristic.from_points(((0, 0.52), (10, 0.5), (20, 0.53)))
TapDependentImpedance(net, 0, characteristic_vk, output_variable='vk_percent', restore=True)
TapDependentImpedance(net, 0, characteristic_vkr, output_variable='vkr_percent', restore=True)

pp.runpp(net, run_control=True)
# remember the losses for the neutral position
pl_mw_neutral = net.res_trafo.pl_mw.at[0]
assert net.trafo.vk_percent.at[0] == 12.3
assert net.trafo.vkr_percent.at[0] == 0.5

net.trafo.tap_pos = 0
pp.runpp(net, run_control=True)
# check if the impedance has been restored
assert net.trafo.vk_percent.at[0] == 12.3
assert net.trafo.vkr_percent.at[0] == 0.5
# check if the losses are different than at the neutral position -> the tap-dependent impedance has been conbsidered
assert abs(net.res_trafo.pl_mw.at[0] - pl_mw_neutral) > 0.015

net.trafo.tap_pos = 20
pp.runpp(net, run_control=True)
# check if the impedance has been restored
assert net.trafo.vk_percent.at[0] == 12.3
assert net.trafo.vkr_percent.at[0] == 0.5
# check if the losses are different than at the neutral position -> the tap-dependent impedance has been conbsidered
assert abs(net.res_trafo.pl_mw.at[0] - pl_mw_neutral) > 0.002


if __name__ == '__main__':
pytest.main(['-xs', __file__])

0 comments on commit 5efc9d5

Please sign in to comment.