From 2093700fff38a84148f4b04f3b0ce09ed0f103cd Mon Sep 17 00:00:00 2001 From: Roman Bolgaryn Date: Thu, 9 Nov 2023 13:28:06 +0100 Subject: [PATCH] fix for the Q setpoint for VSCs --- pandapower/converter/powerfactory/pp_import_functions.py | 7 ++++--- pandapower/pypower/newtonpf.py | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pandapower/converter/powerfactory/pp_import_functions.py b/pandapower/converter/powerfactory/pp_import_functions.py index 32a57f612..e0e5ba3cf 100644 --- a/pandapower/converter/powerfactory/pp_import_functions.py +++ b/pandapower/converter/powerfactory/pp_import_functions.py @@ -430,7 +430,8 @@ def get_pf_bus_results(net, item, bid, is_unbalanced, system_type): res = np.nan if item.HasResults(0): res = ga(item, res_var_pf) - net[bus_type].at[bid, res_var_pp] = res + # dc bus voltage can be negative: + net[bus_type].at[bid, res_var_pp] = np.abs(res) if "vm_pu" in res_var_pp else res # # This one deletes all the results :( @@ -2768,8 +2769,8 @@ def create_vsc(net, item): res = ga(item, res_var_pf) net.res_vsc.at[vid_1, res_var_pp] = -res / 2 net.res_vsc.at[vid_2, res_var_pp] = -res / 2 - net.res_vsc.at[vid_1, "pf_p_dc_mw"] = -ga(item, "m:P:busdm") / 2 - net.res_vsc.at[vid_2, "pf_p_dc_mw"] = -ga(item, "m:P:busdp") / 2 + net.res_vsc.at[vid_1, "pf_p_dc_mw"] = -ga(item, "m:P:busdm") + net.res_vsc.at[vid_2, "pf_p_dc_mw"] = -ga(item, "m:P:busdp") else: net.res_vsc.loc[vid_1, ["pf_p_mw", "pf_q_mvar", "pf_p_dc_mw"]] = np.nan net.res_vsc.loc[vid_2, ["pf_p_mw", "pf_q_mvar", "pf_p_dc_mw"]] = np.nan diff --git a/pandapower/pypower/newtonpf.py b/pandapower/pypower/newtonpf.py index efbeea6df..7c02a463d 100644 --- a/pandapower/pypower/newtonpf.py +++ b/pandapower/pypower/newtonpf.py @@ -619,15 +619,18 @@ def _evaluate_Fx_facts(V,pq ,svc_buses=None, svc_set_vm_pu=None, tcsc_controllab ac_mode_v = vsc_mode_ac == 0 mis_vsc_v = np.abs(V[vsc_fb[ac_mode_v]]) - vsc_value_ac[ac_mode_v] old_F[-len(pq)+pq_lookup[vsc_tb[ac_mode_v]]] = mis_vsc_v + + # Mismatch for Q: ac_mode_q = vsc_mode_ac == 1 + unique_vsc_q_bus, c_q, _ = _sum_by_group(vsc_fb[ac_mode_q], np.ones_like(vsc_fb[ac_mode_q]), np.ones_like(vsc_fb[ac_mode_q])) + count_q = np.zeros(vsc_fb.max() + 1, dtype=np.int64) + count_q[unique_vsc_q_bus] = c_q Sbus_vsc = V * conj(Ybus_vsc * V) - mis_vsc_q = Sbus_vsc[vsc_fb[ac_mode_q]].imag * 0.5 - vsc_value_ac[ac_mode_q] # todo test for when they share same bus + mis_vsc_q = Sbus_vsc[vsc_fb[ac_mode_q]].imag / count_q[vsc_fb[ac_mode_q]] - vsc_value_ac[ac_mode_q] # todo test for when they share same bus old_F[-len(pq) + pq_lookup[vsc_tb[ac_mode_q]]] = mis_vsc_q ##### Mismatch for the second VSC variable: - # coupling of P with VSC happens here: - Sbus_vsc = V * conj(Ybus_vsc * V) # AC side # find the connection between the DC buses and VSC buses # find the slack DC buses # find the P DC buses