2121from pandapower .pypower .pfsoln import pfsoln
2222from pandapower .pf .run_newton_raphson_pf import _get_Y_bus
2323from 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
2727def _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
350350def _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
0 commit comments