Skip to content

Commit

Permalink
Merge remote-tracking branch 'en2IEE/facts_vsc_hvdc' into facts_vsc_hvdc
Browse files Browse the repository at this point in the history
  • Loading branch information
rbolgaryn committed Nov 30, 2023
2 parents fd838b8 + eb0093c commit e0aa30a
Show file tree
Hide file tree
Showing 2 changed files with 503 additions and 170 deletions.
13 changes: 12 additions & 1 deletion pandapower/pypower/newtonpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,18 @@ def _evaluate_Fx_facts(V,pq ,svc_buses=None, svc_set_vm_pu=None, tcsc_controllab
# P_dc[dc_p] = -Sbus_vsc[vsc_tb[vsc_controllable]].real[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]] / count_ref[vsc_dc_bus[vsc_ref]]

# Create a list of tuples containing the original value and its index
vsc_dc_bus_idx = np.array(list(enumerate(vsc_dc_bus)))[vsc_ref] ##TODO: consider define the vscs indices list instead

# Sort the list of tuples based on the values
vsc_dc_bus_sorted = sorted(vsc_dc_bus_idx, key=lambda x: x[1])

# Create the output array by extracting the indices from the sorted list of tuples
vsc_dc_bus_sorted_idx = [i for i, value in vsc_dc_bus_sorted]

vsc_set_p_pu[vsc_dc_bus_sorted_idx] = -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]
Expand Down
Loading

0 comments on commit e0aa30a

Please sign in to comment.