Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add trafo/shunt characteristics and phase shifter logics #2490

Open
wants to merge 162 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
d67515a
create shunt_characteristic_temp & trafo/trafo3w characteristic objec…
panos-xenos Oct 9, 2024
de0b2b3
create shunt spline characteristics
panos-xenos Oct 30, 2024
8e780cc
parameter re-naming
panos-xenos Nov 14, 2024
ada4320
move 'tap_characteristic_table' and 'shunt_characteristic_table' flag…
panos-xenos Nov 15, 2024
824f13d
Changes in pst logic
hilbrich Nov 18, 2024
af2bcc5
introduce id_characteristic_spline flag for trafos & shunts; align in…
panos-xenos Nov 20, 2024
b30a972
rename tap_characteristic_table to tap_dependency_table & step_charac…
panos-xenos Nov 21, 2024
c069bfa
introduce tap_phase_shifter_type flag; populate tap_step_percent & ta…
panos-xenos Nov 21, 2024
fbbdec1
Renamed tap_dependency_table and tap_phase_shifter_type
hilbrich Nov 22, 2024
8dc4ae7
Changes in Controller documentation
hilbrich Nov 22, 2024
ddc8b6e
Merge branch 'feature/shunt-characteristics' into feature/pst_logic
hilbrich Nov 22, 2024
ad1c6a0
fix shift_degree for trafo/3w
panos-xenos Nov 22, 2024
7cade72
address Mario's comments; update create.py lib for trafo/trafo3w para…
panos-xenos Nov 22, 2024
ecda52c
Merge branch 'feature/shunt-characteristics' into feature/pst_logic
hilbrich Nov 28, 2024
5660285
update pp_tools.py; update create.py lib for trafo/trafo3w & shunt pa…
panos-xenos Nov 28, 2024
7372a5a
Merge branch 'feature/shunt-characteristics' into feature/pst_logic
hilbrich Nov 28, 2024
3bf4b52
update diagnostic.py lib
panos-xenos Nov 28, 2024
9b4286e
update __init__.py lib (rename import)
panos-xenos Nov 28, 2024
82ca8fc
WIP trafo
hilbrich Nov 28, 2024
3d6d9d3
WIP trafo phase shifter reworking
hilbrich Nov 29, 2024
b90ac2b
update auxiliary.py function (fix bug); update testing libraries
panos-xenos Nov 29, 2024
56a5731
update create.py, diagnostic.py & test_tap_dependent_impedance.py lib…
panos-xenos Nov 30, 2024
0b6459b
rename tap related parameters; update/replace related tests
panos-xenos Dec 2, 2024
aa0dd4b
Merge branch 'feature/shunt-characteristics' into feature/pst_logic
hilbrich Dec 3, 2024
0d7b6ec
change data type from 'i4' to 'u4'
panos-xenos Dec 3, 2024
2b95817
Merge branch 'refs/heads/develop' into feature/shunt-characteristics
panos-xenos Dec 3, 2024
999e1ea
WIP trafo phase shifter reworking
hilbrich Dec 4, 2024
64437e3
Merge branch 'feature/shunt-characteristics' into feature/pst_logic
hilbrich Dec 4, 2024
39cbc67
WIP trafo phase shifter reworking
hilbrich Dec 4, 2024
da21da8
Final Implementation
hilbrich Dec 4, 2024
ee9d456
Trafo adaption bugfix and adjusted some tests
hilbrich Dec 5, 2024
a3a45a6
WIP Station Controllers Options
hilbrich Dec 5, 2024
9c9c8ab
remove commented code
panos-xenos Dec 5, 2024
f34b40e
Merge branch 'feature/pst_logic' into feature/shunt-characteristics
hilbrich Dec 5, 2024
ea61e91
get p and q values for shunts from characteristics
JakobKirschner Dec 4, 2024
697dfb9
add tap_phase_shifter_type parameter for trafo3w in create.py lib
panos-xenos Dec 5, 2024
a6bd8db
make build bus backward compatible for shunts
JakobKirschner Dec 5, 2024
5c95d3e
update std_types.py for trafo3w
panos-xenos Dec 5, 2024
73f555b
Update on shunts
hilbrich Dec 5, 2024
35611fa
Update on shunts
hilbrich Dec 5, 2024
924208b
Merge remote-tracking branch 'jakob/feature/shunt-characteristics' in…
hilbrich Dec 5, 2024
1b540e6
fix loadflow tests
panos-xenos Dec 6, 2024
d016080
minor PEP8 fix
panos-xenos Dec 6, 2024
9348373
revert changes in old_versions json files
panos-xenos Dec 9, 2024
6fdd6b2
add tests and warnings for shunt characteristics
JakobKirschner Dec 9, 2024
fb185d1
fix bug in create.py
JakobKirschner Dec 10, 2024
80c0e9c
update for pytests
panos-xenos Dec 10, 2024
9b3e405
remove required columns in trafo, trafo3w std types
JakobKirschner Dec 10, 2024
da909dd
merge develop into feature/shunt-characteristics
JakobKirschner Dec 10, 2024
785fa95
fix create trafos and std types
JakobKirschner Dec 10, 2024
242e768
fix tap dependency in build branch
JakobKirschner Dec 10, 2024
01ef52a
Revert "fix tap dependency in build branch"
JakobKirschner Dec 11, 2024
69e7dc3
fix get equivalent tests
JakobKirschner Dec 11, 2024
df354e0
remove todo from test_tap_dependent_impedance.py lib
panos-xenos Dec 11, 2024
6abdada
amend pytests / fix bugs to remove pytest fails
panos-xenos Dec 12, 2024
9e1bda2
Merge branch 'refs/heads/develop' into feature/shunt-characteristics
panos-xenos Dec 12, 2024
08f4a19
fix bug in _convert_trafo_pst_logic function
panos-xenos Dec 13, 2024
f5ab980
Merge branch 'refs/heads/develop' into feature/shunt-characteristics
panos-xenos Dec 13, 2024
bbbb184
fix pandapower PR issues; fix bug in build_branch.py; updates to pass…
panos-xenos Dec 13, 2024
9c6ea93
fix pandapower PR issue - remove unused import
panos-xenos Dec 13, 2024
3319170
address Thomas comments
panos-xenos Dec 16, 2024
05fc525
resolve codacy issue - move import to test lib
panos-xenos Dec 16, 2024
eb3e62d
removed creation of empty characteristic table in json files
panos-xenos Dec 16, 2024
4eae525
amend test_create_trafo_characteristics test to also include a non li…
panos-xenos Dec 16, 2024
a2a538a
re-introduce test_tap_phase_shifter_type_default function but re-purp…
panos-xenos Dec 16, 2024
8867abd
renaming: phase_shifter_type to tap_changer_type and 0,1,2 to "Ratio"…
Dec 16, 2024
62512c4
documentation typos
panos-xenos Dec 16, 2024
9611a14
Merge branch 'fork/JakobKirschner/feature/shunt-characteristics' into…
Dec 16, 2024
a0dea88
all but 10 tests are running after renaming. Missing is matpower and …
Dec 16, 2024
afdb27a
debugging updates
panos-xenos Dec 17, 2024
0c41923
Merge branch 'develop' into feature/shunt-characteristics
vogt31337 Dec 17, 2024
42c05db
fix bug in test_shunt_step_dependency_warning() function
panos-xenos Dec 17, 2024
462e871
fix deprecation warnings
panos-xenos Dec 17, 2024
906b121
add shunt_characteristic_table_diagnostic function
panos-xenos Dec 18, 2024
6cfd2a7
fix bug in build_bus.py
panos-xenos Dec 18, 2024
cb45c18
fix bug in cgmes converter
panos-xenos Dec 18, 2024
86f66f1
WIP pf_converter
hilbrich Dec 18, 2024
ca4a0eb
improve control/util/diagnostic.py lib
panos-xenos Dec 18, 2024
a8a3b63
update documentation for trafo characteristics
panos-xenos Dec 18, 2024
147d41f
update docstrings in create.py
panos-xenos Dec 18, 2024
377d409
all test running locally
Dec 18, 2024
668f03c
Merge branch 'fork/JakobKirschner/feature/shunt-characteristics' into…
Dec 18, 2024
ecc8578
merge to latest and again fixing tests
Dec 18, 2024
e8a03aa
add documentation for shunt_characteristic_table
panos-xenos Dec 18, 2024
3cc601b
fix codacy minor issue
panos-xenos Dec 18, 2024
28715ed
Merge branch 'fork/JakobKirschner/feature/shunt-characteristics' into…
Dec 19, 2024
905c9f0
Merge pull request #3 from JakobKirschner/fork/JakobKirschner/feature…
JakobKirschner Dec 19, 2024
485bbea
Merge remote-tracking branch 'jakob/feature/shunt-characteristics' in…
hilbrich Dec 19, 2024
e8a6239
fix contingency and tap_dependent_impedance tests
panos-xenos Dec 19, 2024
2318af3
Merge branch 'develop' into feature/shunt-characteristics
JakobKirschner Dec 19, 2024
151c973
fix run_contingency_ls2g, _convert_trafo_phase_shifter & test_lightsi…
panos-xenos Dec 19, 2024
91fa21d
minor fixes
panos-xenos Dec 19, 2024
c1a1666
add Int64 to sql bigint dtypes and convert pd.NA to None for postgres…
JakobKirschner Dec 19, 2024
4f44236
add temporary tap_phase_shifter column to trafo df for lightsim2grid …
JakobKirschner Dec 19, 2024
2d50f10
Merge branch 'develop' into feature/shunt-characteristics
JakobKirschner Dec 19, 2024
8ca7fdc
fix lightsim2grid dependency; fix codacy issues
panos-xenos Dec 19, 2024
95412fc
attempt to fix codacy issues
panos-xenos Dec 19, 2024
abd849d
update documentation to reflect tap_changer_type name change
panos-xenos Dec 19, 2024
762158a
2nd attempt to resolve codacy issue
panos-xenos Dec 19, 2024
3b622f4
3rd attempt to resolve codacy issue
panos-xenos Dec 19, 2024
bf57ba2
add test_shunt_characteristic_table_diagnostic test function
panos-xenos Dec 20, 2024
435a728
revert json files back (because current status was only half-updated …
Dec 20, 2024
fc62209
Merge remote-tracking branch 'jakob/feature/shunt-characteristics' in…
hilbrich Dec 20, 2024
97d1836
updated docu for phase shifter
Dec 20, 2024
6f97e61
Completed pf_converter for adjusted trafo tap changer working
hilbrich Dec 20, 2024
a247d4f
Merge branch 'feature/shunt-characteristics' into feature/shunt-chara…
Dec 20, 2024
85bf778
revert json in converter
Dec 20, 2024
92e78c0
panos comment, change not necessary
Dec 20, 2024
08c4ac7
panos comment, change not necessary
Dec 20, 2024
a410405
update std_types documentation
panos-xenos Dec 20, 2024
9d06d5e
Merge pull request #4 from JakobKirschner/feature/shunt-characteristi…
panos-xenos Dec 20, 2024
21fc04d
docu for tap_changer_type
Dec 20, 2024
4ac812a
update std_types documentation v2
panos-xenos Dec 20, 2024
97b539b
Merge pull request #5 from JakobKirschner/feature/shunt-characteristi…
panos-xenos Dec 20, 2024
a1fb810
update update30.rst
panos-xenos Dec 20, 2024
246efc2
delete "characteristic" from json file
Dec 20, 2024
9279b7b
Merge branch 'feature/shunt-characteristics' into feature/shunt-chara…
Dec 20, 2024
996a7f2
Merge pull request #6 from JakobKirschner/feature/shunt-characteristi…
panos-xenos Dec 20, 2024
c1a0aaf
test pf_converter for adjusted trafo tap changer working and small bu…
hilbrich Dec 20, 2024
e9911ed
Merge remote-tracking branch 'jakob/feature/shunt-characteristics' in…
hilbrich Dec 20, 2024
99373b2
if ("tap_changer_type" in net.trafo3w.columns)
Dec 20, 2024
18ba569
fix bug in contingency.py
panos-xenos Dec 20, 2024
aada180
updated CHANGELOG.rst
panos-xenos Dec 20, 2024
d02ee5b
Bugfix in pf import and pf import test for tap changer finalisation
hilbrich Dec 20, 2024
80499f2
test merge charactersitc
Dec 20, 2024
bb013bb
Merge branch 'feature/shunt-characteristics' into feature/shunt-chara…
Dec 20, 2024
c123fad
Merge pull request #8 from JakobKirschner/feature/shunt-characteristi…
panos-xenos Dec 20, 2024
77a775c
Added some warnings and improvements in build branch
hilbrich Dec 20, 2024
d8f1f98
Merge branch 'refs/heads/develop' into feature/shunt-characteristics
panos-xenos Dec 20, 2024
4b01bf6
Merge remote-tracking branch 'jakob/feature/shunt-characteristics' in…
hilbrich Dec 20, 2024
f572297
remove n/a tests
panos-xenos Dec 20, 2024
4d07b7c
FIX: Tap dependent impedance of transformers tutorial test
Ghanshyam-grid Dec 20, 2024
b3864df
FIX: Tap dependent impedance of transformers tutorial test
Ghanshyam-grid Dec 20, 2024
d882ebf
CHG: Description of tap dependent impedance of transformers tutorial …
Ghanshyam-grid Jan 2, 2025
ba0efeb
Merge branch 'refs/heads/develop' into feature/shunt-characteristics
panos-xenos Jan 8, 2025
6f6e667
extract measurements from more elements from CGMES
panos-xenos Jan 9, 2025
acc8b7c
fix in pandapower converter to understand tap changer side from table…
Jan 9, 2025
4d7fcd8
Merge remote-tracking branch 'JakobKirschner/feature/shunt-characteri…
Jan 9, 2025
ce083f3
revert changes for old_versions json files
panos-xenos Jan 9, 2025
280aaf5
add bus key in sc dict for extracting measurements of additional elem…
panos-xenos Jan 9, 2025
d183810
drop measurements of elements connected to buses
panos-xenos Jan 9, 2025
3770d88
update create.py lib to make it backward compatible for older logic o…
panos-xenos Jan 9, 2025
c632939
Merge branch 'refs/heads/develop' into feature/shunt-characteristics
panos-xenos Jan 9, 2025
0e65371
improve deprecation warning messages in create.py
panos-xenos Jan 10, 2025
b4f023d
Added depreciated warnings in build_bus.py and build_branch.py, remov…
hilbrich Jan 10, 2025
a90cff0
Removed a bug in build branch.
hilbrich Jan 13, 2025
bc15e9e
Merge branch 'refs/heads/develop' into feature/shunt-characteristics
panos-xenos Jan 13, 2025
49e6acd
typo in comment in build_branch.py
panos-xenos Jan 13, 2025
0b08364
Added test for validating tap table order for transformers
hilbrich Jan 14, 2025
4696efe
Merge remote-tracking branch 'jakob/feature/shunt-characteristics' in…
hilbrich Jan 14, 2025
6148814
Removed variable direction from build_branch as it is not used for tr…
hilbrich Jan 14, 2025
f32f8a4
Merge branch 'refs/heads/develop' into feature/shunt-characteristics
panos-xenos Jan 15, 2025
157291d
typo in build_branch.py
panos-xenos Jan 16, 2025
213524c
typos in build_branch.py
panos-xenos Jan 16, 2025
7123f71
BugFix in pf and cgmes converter
hilbrich Jan 17, 2025
3d7a3ac
Merge remote-tracking branch 'jakob/feature/shunt-characteristics' in…
hilbrich Jan 17, 2025
7928003
BugFix in cgmes converter
hilbrich Jan 17, 2025
19ebbda
Small Refactoring of build branch
hilbrich Jan 17, 2025
0572ae5
Small Refactoring of pf import
hilbrich Jan 17, 2025
9f8ab09
Refactoring of build branch
hilbrich Jan 17, 2025
57b8841
typos in trafo.rst
panos-xenos Jan 21, 2025
6011e22
redundant line of code
panos-xenos Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions doc/control/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ SplineCharacteristic
.. autoclass:: pandapower.control.util.characteristic.SplineCharacteristic
:members:

The following controllers are used for the representation of station controllers as used in PowerFactory


Station Controller
==================
The following controllers are used for the representation of station controllers as used in PowerFactory

**********************
Binary Search Control
Expand Down
330 changes: 243 additions & 87 deletions pandapower/build_branch.py

Large diffs are not rendered by default.

29 changes: 26 additions & 3 deletions pandapower/build_bus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

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

Expand Down Expand Up @@ -640,8 +640,31 @@ def _calc_shunts_and_add_on_ppc(net, ppc):
if len(s) > 0:
vl = _is_elements["shunt"]
v_ratio = (ppc["bus"][bus_lookup[s["bus"].values], BASE_KV] / s["vn_kv"].values) ** 2 * base_multiplier
q = np.hstack([q, s["q_mvar"].values * s["step"].values * v_ratio * vl])
p = np.hstack([p, s["p_mw"].values * s["step"].values * v_ratio * vl])

if "step_dependency_table" in s:
if np.any(vl & (s.step_dependency_table == True) & (s.id_characteristic_table.isna())):
raise UserWarning("Shunts with step_dependency_table True and id_characteristic_table NA detected.\n"
"Please set an id_characteristic_table or set step_dependency_table to False.")
elif (np.any(vl & s.step_dependency_table == False
& ~s.id_characteristic_table.isna())):
warnings.warn("Shunts with step_dependency_table False but id_characteristic_table detected.",
category=UserWarning)
s.step_dependency_table.fillna(False)
if s.step_dependency_table.any():
s_tmp = s.merge(net.shunt_characteristic_table, how="left", left_on="id_characteristic_table",
right_on="id_characteristic", suffixes=("", "_table"))
s = s_tmp.loc[(s_tmp["step"] == s_tmp["step_table"]) | ~s_tmp["step_dependency_table"]]

q = np.hstack([q, s["q_mvar"].values * s["step"].values * v_ratio * vl * ~s["step_dependency_table"]])
p = np.hstack([p, s["p_mw"].values * s["step"].values * v_ratio * vl * ~s["step_dependency_table"]])
q = q + s["q_mvar_table"].fillna(0).to_numpy() * v_ratio * vl
p = p + s["p_mw_table"].fillna(0).to_numpy() * v_ratio * vl
else:
q = np.hstack([q, s["q_mvar"].values * s["step"].values * v_ratio * vl])
p = np.hstack([p, s["p_mw"].values * s["step"].values * v_ratio * vl])
else:
q = np.hstack([q, s["q_mvar"].values * s["step"].values * v_ratio * vl])
p = np.hstack([p, s["p_mw"].values * s["step"].values * v_ratio * vl])
b = np.hstack([b, s["bus"].values])

w = net["ward"]
Expand Down
18 changes: 10 additions & 8 deletions pandapower/contingency/contingency.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ def run_contingency_ls2g(net, nminus1_cases, contingency_evaluation_function=pp.
contingency_evaluation_function(net, **kwargs)

trafo_flag = False
if np.any(net.trafo.tap_phase_shifter):
trafo_flag = True
tap_phase_shifter, tap_pos, shift_degree = _convert_trafo_phase_shifter(net)
if "tap_phase_shifter_type" in net.trafo.columns:
if np.any(net.trafo.tap_phase_shifter_type == 2):
trafo_flag = True
tap_phase_shifter_type, tap_pos, shift_degree = _convert_trafo_phase_shifter(net)

# setting "slack" back-and-forth is due to the difference in interpretation of generators as "distributed slack"
if net._options.get("distributed_slack", False):
Expand All @@ -197,7 +198,7 @@ def run_contingency_ls2g(net, nminus1_cases, contingency_evaluation_function=pp.
solver_type = SolverType.KLUSingleSlack if KLU_solver_available else SolverType.SparseLUSingleSlack

if trafo_flag:
net.trafo.tap_phase_shifter = tap_phase_shifter
net.trafo.tap_phase_shifter_type = tap_phase_shifter_type
net.trafo.tap_pos = tap_pos
net.trafo.shift_degree = shift_degree

Expand Down Expand Up @@ -293,7 +294,7 @@ def run_contingency_ls2g(net, nminus1_cases, contingency_evaluation_function=pp.


def _convert_trafo_phase_shifter(net):
tap_phase_shifter = net.trafo.tap_phase_shifter.values.copy()
tap_phase_shifter_type = net.trafo.tap_phase_shifter_type.values.copy()
# vn_hv_kv = net.trafo.vn_hv_kv.values.copy()
shift_degree = net.trafo.shift_degree.values.copy()

Expand All @@ -302,11 +303,12 @@ def _convert_trafo_phase_shifter(net):
tap_diff = tap_pos - tap_neutral
tap_step_degree = net.trafo.tap_step_degree.values.copy()

net.trafo.loc[tap_phase_shifter, 'shift_degree'] += tap_diff[tap_phase_shifter] * tap_step_degree[tap_phase_shifter]
net.trafo.loc[tap_phase_shifter_type == 2, 'shift_degree'] += (tap_diff[tap_phase_shifter_type == 2] *
panos-xenos marked this conversation as resolved.
Show resolved Hide resolved
tap_step_degree[tap_phase_shifter_type == 2])
net.trafo["tap_pos"] = 0
net.trafo["tap_phase_shifter"] = False
net.trafo["tap_phase_shifter_type"] = pd.NA
panos-xenos marked this conversation as resolved.
Show resolved Hide resolved

return tap_phase_shifter, tap_pos, shift_degree
return tap_phase_shifter_type, tap_pos, shift_degree


def _update_contingency_results(net, contingency_results, result_variables, nminus1, cause_element=None,
Expand Down
5 changes: 3 additions & 2 deletions pandapower/control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
# --- Other ---
from pandapower.control.run_control import *
from pandapower.control.util.characteristic import Characteristic, SplineCharacteristic
from pandapower.control.util.auxiliary import get_controller_index, plot_characteristic, create_trafo_characteristics
from pandapower.control.util.diagnostic import control_diagnostic, trafo_characteristics_diagnostic
from pandapower.control.util.auxiliary import (get_controller_index, plot_characteristic, _create_trafo_characteristics,
create_trafo_characteristic_object)
from pandapower.control.util.diagnostic import control_diagnostic, trafo_characteristic_table_diagnostic
2 changes: 1 addition & 1 deletion pandapower/control/controller/station_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BinarySearchControl(Controller):
reactive power control or voltage control. in case of voltage control, the input parameter voltage_ctrl must be
set to true. Input and output elements and indexes can be lists. Input elements can be transformers, switches,
lines or busses (only in case of voltage control). in case of voltage control, a bus_index must be present,
where the voltage will be controlled.Output elements are sgens, where active and reactive power can be set. The
where the voltage will be controlled. Output elements are sgens, where active and reactive power can be set. The
output value distribution describes the distribution of reactive power provision between multiple
output_elements and must sum up to 1.

Expand Down
Loading
Loading