Skip to content

Commit

Permalink
fix for the Q setpoint for VSCs
Browse files Browse the repository at this point in the history
  • Loading branch information
rbolgaryn committed Nov 9, 2023
1 parent b82b024 commit 2093700
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions pandapower/converter/powerfactory/pp_import_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 :(
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions pandapower/pypower/newtonpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2093700

Please sign in to comment.