Skip to content

Commit b0a735b

Browse files
authored
Merge pull request #2502 from ajazHameed/develop
- avail iteration count for convergence as an output dict parameter f…
2 parents 5486565 + 6c1a461 commit b0a735b

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Change Log
33

44
[upcoming release] - 2025-..-..
55
-------------------------------
6+
- [ADDED] iteration count for convergence as an output dict parameter
67
- [FIXED] pf2pp converter - corrected consideration of line temperature during import
78
- [FIXED] corrected create_continuous_elements_index to consider trafo_characteristic_tables correctly
89
- [FIXED] pp control - handle NaN in 'enabled' column when computing 'controlEnabled' to ensure safe boolean evaluation

pandapower/pf/run_bfswpf.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pandapower.pypower.pfsoln import pfsoln
2222
from pandapower.pf.run_newton_raphson_pf import _get_Y_bus
2323
from pandapower.pf.runpf_pypower import _import_numba_extensions_if_flag_is_true
24-
from pandapower.pf.ppci_variables import _get_pf_variables_from_ppci
24+
from pandapower.pf.ppci_variables import _get_pf_variables_from_ppci, _store_results_from_pf_in_ppci
2525

2626

2727
def _make_bibc_bcbv(bus, branch, graph):
@@ -344,7 +344,7 @@ def _bfswpf(DLF, bus, gen, branch, baseMVA, Ybus, Sbus, V0, ref, pv, pq, buses_o
344344
# updating injected currents
345345
Iinj = np.conj(Sbus / V) - Ysh * V
346346

347-
return V, converged
347+
return V, converged, n_iter
348348

349349

350350
def _get_options(options):
@@ -366,7 +366,7 @@ def _run_bfswpf(ppci, options, **kwargs):
366366
367367
:param ppci: matpower-style case data
368368
:param options: pf options
369-
:return: results (pypower style), success (flag about PF convergence)
369+
:return: ppci (dict)
370370
"""
371371
time_start = perf_counter() # starting pf calculation timing
372372

@@ -409,7 +409,7 @@ def _run_bfswpf(ppci, options, **kwargs):
409409
Ybus_noshift = Ybus.copy()
410410

411411
# #----- run the power flow -----
412-
V_final, success = _bfswpf(DLF, bus, gen, branch, baseMVA, Ybus_noshift,
412+
V_final, success, iterations = _bfswpf(DLF, bus, gen, branch, baseMVA, Ybus_noshift,
413413
Sbus, V0, ref, pv, pq, buses_ordered_bfs_nets,
414414
options, **kwargs)
415415

@@ -441,13 +441,11 @@ def _run_bfswpf(ppci, options, **kwargs):
441441
V_final[buses_shifted_from_root] *= np.exp(1j * np.pi / 180 * shift_degree)
442442

443443
# #----- output results to ppc ------
444-
ppci["et"] = perf_counter() - time_start # pf time end
444+
et = perf_counter() - time_start # pf time end
445445

446446
bus, gen, branch = pfsoln(baseMVA, bus, gen, branch, svc, tcsc, ssc, vsc, Ybus, Yf, Yt, V_final, ref, ref_gens)
447447
# bus, gen, branch = pfsoln_bfsw(baseMVA, bus, gen, branch, V_final, ref, pv, pq, BIBC, ysh_f,ysh_t,Iinj, Sbus)
448448

449-
ppci["success"] = success
449+
ppci = _store_results_from_pf_in_ppci(ppci, bus, gen, branch, success, iterations, et)
450450

451-
ppci["bus"], ppci["gen"], ppci["branch"] = bus, gen, branch
452-
453-
return ppci, success
451+
return ppci

pandapower/powerflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _run_pf_algorithm(ppci, options, **kwargs):
145145
# ommission not correct if distributed slack is used or facts devices are present
146146
result = _bypass_pf_and_set_results(ppci, options)
147147
elif algorithm == 'bfsw': # forward/backward sweep power flow algorithm
148-
result = _run_bfswpf(ppci, options, **kwargs)[0]
148+
result = _run_bfswpf(ppci, options, **kwargs)
149149
elif algorithm in ['nr', 'iwamoto_nr']:
150150
result = _run_newton_raphson_pf(ppci, options)
151151
elif algorithm in ['fdbx', 'fdxb', 'gs']: # algorithms existing within pypower

0 commit comments

Comments
 (0)