Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- avail iteration count for convergence as an output dict parameter f… #2502

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions pandapower/pf/run_bfswpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pandapower.pypower.pfsoln import pfsoln
from pandapower.pf.run_newton_raphson_pf import _get_Y_bus
from pandapower.pf.runpf_pypower import _import_numba_extensions_if_flag_is_true
from pandapower.pf.ppci_variables import _get_pf_variables_from_ppci
from pandapower.pf.ppci_variables import _get_pf_variables_from_ppci, _store_results_from_pf_in_ppci


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

return V, converged
return V, converged, n_iter


def _get_options(options):
Expand All @@ -366,7 +366,7 @@ def _run_bfswpf(ppci, options, **kwargs):

:param ppci: matpower-style case data
:param options: pf options
:return: results (pypower style), success (flag about PF convergence)
:return: ppci (dict)
"""
time_start = perf_counter() # starting pf calculation timing

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

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

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

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

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

ppci["success"] = success
ppci = _store_results_from_pf_in_ppci(ppci, bus, gen, branch, success, iterations, et)

ppci["bus"], ppci["gen"], ppci["branch"] = bus, gen, branch

return ppci, success
return ppci
2 changes: 1 addition & 1 deletion pandapower/powerflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _run_pf_algorithm(ppci, options, **kwargs):
# ommission not correct if distributed slack is used or facts devices are present
result = _bypass_pf_and_set_results(ppci, options)
elif algorithm == 'bfsw': # forward/backward sweep power flow algorithm
result = _run_bfswpf(ppci, options, **kwargs)[0]
result = _run_bfswpf(ppci, options, **kwargs)
elif algorithm in ['nr', 'iwamoto_nr']:
result = _run_newton_raphson_pf(ppci, options)
elif algorithm in ['fdbx', 'fdxb', 'gs']: # algorithms existing within pypower
Expand Down
Loading