Skip to content

Commit

Permalink
fix the configuration with multiple VSC connected to the same DC bus …
Browse files Browse the repository at this point in the history
…(but not in B2B configuration)
  • Loading branch information
rbolgaryn committed Oct 26, 2023
1 parent 6cda71a commit 26d657e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pandapower/pypower/newtonpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,26 +637,29 @@ def _evaluate_Fx_facts(V,pq ,svc_buses=None, svc_set_vm_pu=None, tcsc_controllab
vsc_dc_b2b_bus = np.intersect1d(vsc_dc_bus[vsc_controllable], dc_b2b) # DC B2B buses

vsc_p = np.isin(vsc_dc_bus, vsc_dc_p_bus)
vsc_ref = vsc_mode_dc == 0
vsc_ref = np.isin(vsc_dc_bus, vsc_dc_ref_bus)
vsc_b2b_p = np.isin(vsc_dc_bus, vsc_dc_b2b_bus) & (vsc_mode_dc == 1)
vsc_b2b_ref = np.isin(vsc_dc_bus, vsc_dc_b2b_bus) & (vsc_mode_dc == 0)

bbb, _, count_b2b_ref = _sum_by_group(vsc_dc_bus, vsc_b2b_ref.astype(np.float64), vsc_b2b_ref.astype(np.float64))
factor_b2b_ref = np.ones(sum(vsc_b2b_ref), dtype=np.float64)
factor_b2b_ref = count_b2b_ref[vsc_dc_bus[vsc_b2b_ref]]
unique_vsc_dc_bus, c_ref, c_b2b_ref = _sum_by_group(vsc_dc_bus, vsc_ref.astype(np.float64), vsc_b2b_ref.astype(np.float64))
count_ref = np.zeros(vsc_dc_bus.max()+1, dtype=np.int64)
count_b2b_ref = np.zeros(vsc_dc_bus.max()+1, dtype=np.int64)
count_ref[unique_vsc_dc_bus] = c_ref
count_b2b_ref[unique_vsc_dc_bus] = c_b2b_ref


# todo fix this part
# a configuration of B2B bus connecting also with DC lines could be implemented here in the future if needed:
if len(dc_p):
vsc_set_p_pu[vsc_p] = -P_dc[dc_p][dc_p_lookup[vsc_dc_p_bus]] # dc_p
# vsc_set_p_pu[vsc_p] = -P_dc[dc_p][dc_p_lookup[vsc_dc_p_bus]]
vsc_set_p_pu[vsc_p] = vsc_value_dc[vsc_p]
if len(dc_ref):
# vsc_set_p_pu[vsc_mode_dc == 1] = -P_dc[dc_ref][dc_ref_lookup[vsc_dc_ref_bus]] # dc_p
vsc_set_p_pu[vsc_ref] = -Pbus_hvdc[dc_ref][dc_ref_lookup[vsc_dc_ref_bus]]
vsc_set_p_pu[vsc_ref] = -Pbus_hvdc[dc_ref][dc_ref_lookup[vsc_dc_ref_bus]] / count_ref[vsc_dc_bus[vsc_ref]]
if len(dc_b2b):
# vsc_set_p_pu[vsc_mode_dc == 1] = -P_dc[dc_ref][dc_ref_lookup[vsc_dc_ref_bus]] # dc_p
vsc_set_p_pu[vsc_b2b_p] = vsc_value_dc[vsc_b2b_p]
vsc_set_p_pu[vsc_b2b_ref] = P_dc[dc_b2b][dc_b2b_lookup[vsc_dc_b2b_bus]] / factor_b2b_ref
vsc_set_p_pu[vsc_b2b_ref] = P_dc[dc_b2b][dc_b2b_lookup[vsc_dc_b2b_bus]] / count_b2b_ref[vsc_dc_bus[vsc_b2b_ref]]
#### here used vsc_tb refereing to the q bus
mis_vsc_p = Sbus_vsc[vsc_tb[vsc_controllable]].real - vsc_set_p_pu # this is coupling the AC and the DC sides
# todo: adjust the lookup to work with 1) VSC at ext_grid bus 2) only 1 VSC connected to HVDC line
Expand Down
50 changes: 50 additions & 0 deletions pandapower/test/loadflow/test_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,56 @@ def test_b2b_line_dc_raise():
pp.runpp(net)


def test_line_dc_and_2_vsc1():
net = pp.create_empty_network()
# AC part
pp.create_buses(net, 4, 110)
pp.create_line_from_parameters(net, 0, 1, 30, 0.0487, 0.13823, 160, 0.664)
pp.create_line_from_parameters(net, 0, 2, 30, 0.0487, 0.13823, 160, 0.664)
pp.create_line_from_parameters(net, 2, 3, 30, 0.0487, 0.13823, 160, 0.664)
pp.create_ext_grid(net, 0)
pp.create_load(net, 2, 10)

# DC part
pp.create_bus_dc(net, 110, 'A')
pp.create_bus_dc(net, 110, 'B')

pp.create_line_dc(net, 0, 1, 100, std_type="2400-CU")

pp.create_vsc(net, 1, 0, 0.1, 5, control_mode_ac="vm_pu", control_value_ac=1, control_mode_dc="vm_pu",
control_value_dc=1.02)
pp.create_vsc(net, 2, 0, 0.1, 5, control_mode_ac="vm_pu", control_value_ac=1, control_mode_dc="vm_pu",
control_value_dc=1.02)
pp.create_vsc(net, 3, 1, 0.1, 5, control_mode_ac="vm_pu", control_value_ac=1, control_mode_dc="p_mw",
control_value_dc=2)

runpp_with_consistency_checks(net)


def test_line_dc_and_2_vsc2():
net = pp.create_empty_network()
# AC part
pp.create_buses(net, 4, 110)
pp.create_line_from_parameters(net, 0, 1, 30, 0.0487, 0.13823, 160, 0.664)
pp.create_line_from_parameters(net, 0, 2, 30, 0.0487, 0.13823, 160, 0.664)
pp.create_line_from_parameters(net, 2, 3, 30, 0.0487, 0.13823, 160, 0.664)
pp.create_ext_grid(net, 0)
pp.create_load(net, 2, 10)

# DC part
pp.create_bus_dc(net, 110, 'A')
pp.create_bus_dc(net, 110, 'B')

pp.create_line_dc(net, 0, 1, 100, std_type="2400-CU")

pp.create_vsc(net, 1, 0, 0.1, 5, control_mode_ac="vm_pu", control_value_ac=1, control_mode_dc="p_mw",
control_value_dc=2)
pp.create_vsc(net, 2, 0, 0.1, 5, control_mode_ac="vm_pu", control_value_ac=1, control_mode_dc="p_mw",
control_value_dc=2)
pp.create_vsc(net, 3, 1, 0.1, 5, control_mode_ac="vm_pu", control_value_ac=1, control_mode_dc="vm_pu",
control_value_dc=1.02)

runpp_with_consistency_checks(net)


# TODO VSC as slack - cannot work because slack is a Vm-Va bus,
Expand Down

0 comments on commit 26d657e

Please sign in to comment.