Skip to content

Commit

Permalink
WIP added a NotImplementedError for when 2 VSC share 1 AC bus but hav…
Browse files Browse the repository at this point in the history
…e different AC control modes
  • Loading branch information
rbolgaryn committed Nov 13, 2023
1 parent 91c5227 commit b17933a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
13 changes: 12 additions & 1 deletion pandapower/pd2ppc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pandapower.pypower.idx_ssc import SSC_STATUS, SSC_BUS, SSC_INTERNAL_BUS
from pandapower.pypower.idx_tcsc import TCSC_STATUS, TCSC_F_BUS, TCSC_T_BUS
from pandapower.pypower.idx_svc import SVC_STATUS, SVC_BUS
from pandapower.pypower.idx_vsc import VSC_BUS_DC, VSC_STATUS
from pandapower.pypower.idx_vsc import VSC_BUS_DC, VSC_STATUS, VSC_MODE_AC
from pandapower.pypower.run_userfcn import run_userfcn


Expand Down Expand Up @@ -72,6 +72,16 @@ def _check_line_dc_at_b2b_buses(ppci):
"part of a Back-To-Back configuration.")


def _check_vsc_different_ac_control_modes_at_same_bus(ppci):
ac_vm_pu_buses = ppci["vsc"][ppci["vsc"][:, VSC_MODE_AC] == 0, VSC_BUS]
ac_q_mvar_buses = ppci["vsc"][ppci["vsc"][:, VSC_MODE_AC] == 1, VSC_BUS]
ac_bus_intersection = np.intersect1d(ac_vm_pu_buses, ac_q_mvar_buses)
if len(ac_bus_intersection) != 0:
raise NotImplementedError("Found multiple VSC converters that share the same AC bus and have "
"different AC control modes - not implemented. VSC converters can only "
"have the same AC control mode if they share the same AC bus.")


def _pd2ppc(net, sequence=None):
"""
Converter Flow:
Expand Down Expand Up @@ -190,6 +200,7 @@ def _pd2ppc(net, sequence=None):
ppci = _ppc2ppci(ppc, net)

_check_line_dc_at_b2b_buses(ppci)
_check_vsc_different_ac_control_modes_at_same_bus(ppci)

if mode == "pf":
# check if any generators connected to the same bus have different voltage setpoints
Expand Down
12 changes: 10 additions & 2 deletions pandapower/test/loadflow/test_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,11 @@ def test_2vsc_1ac_2dc(control_mode_ac, control_mode_dc):
pp.create_vsc(net, 1, 0, 0.1, 5, control_mode_ac=control_mode_ac[0], control_value_ac=val_ac[control_mode_ac[0]], control_mode_dc=control_mode_dc[0], control_value_dc=val_dc[control_mode_dc[0]])
pp.create_vsc(net, 1, 1, 0.1, 5, control_mode_ac=control_mode_ac[1], control_value_ac=val_ac[control_mode_ac[1]], control_mode_dc=control_mode_dc[1], control_value_dc=val_dc[control_mode_dc[1]])

runpp_with_consistency_checks(net)
if control_mode_ac[0] == control_mode_ac[1]:
runpp_with_consistency_checks(net)
else:
with pytest.raises(NotImplementedError, match="share the same AC bus"):
pp.runpp(net)


@pytest.mark.parametrize("control_mode_ac", list(product(['vm_pu', 'q_mvar'], repeat=2)))
Expand Down Expand Up @@ -2334,7 +2338,11 @@ def test_2vsc_1ac_1dc(control_mode_ac, control_mode_dc):
pp.create_vsc(net, 1, 0, 0.1, 5, control_mode_ac=control_mode_ac[0], control_value_ac=val_ac[control_mode_ac[0]], control_mode_dc=control_mode_dc[0], control_value_dc=val_dc[control_mode_dc[0]])
pp.create_vsc(net, 1, 0, 0.1, 5, control_mode_ac=control_mode_ac[1], control_value_ac=val_ac[control_mode_ac[1]], control_mode_dc=control_mode_dc[1], control_value_dc=val_dc[control_mode_dc[1]])

runpp_with_consistency_checks(net)
if control_mode_ac[0] == control_mode_ac[1]:
runpp_with_consistency_checks(net)
else:
with pytest.raises(NotImplementedError, match="share the same AC bus"):
pp.runpp(net)



Expand Down

0 comments on commit b17933a

Please sign in to comment.