forked from e2nIEE/pandapower
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
137 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
tutorials/* linguist-vendored | ||
*.rst text eol=lf | ||
*.rst text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
pandapower/control/controller/trafo/TapDependentImpedance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters