コード例 #1
0
def _run_pf_algorithm(ppci, options, **kwargs):
    algorithm = options["algorithm"]
    ac = options["ac"]

    if ac:
        _, pv, pq = bustypes(ppci["bus"], ppci["gen"])
        # ----- run the powerflow -----
        if pq.shape[0] == 0 and pv.shape[
                0] == 0 and not options['distributed_slack']:
            # ommission not correct if distributed slack is used
            result = _bypass_pf_and_set_results(ppci, options)
        elif algorithm == 'bfsw':  # forward/backward sweep power flow algorithm
            result = _run_bfswpf(ppci, options, **kwargs)[0]
        elif algorithm in ['nr', 'iwamoto_nr']:
            result = _run_newton_raphson_pf(ppci, options)
        elif algorithm in ['fdbx', 'fdxb',
                           'gs']:  # algorithms existing within pypower
            result = _runpf_pypower(ppci, options, **kwargs)[0]
        else:
            raise AlgorithmUnknown(
                "Algorithm {0} is unknown!".format(algorithm))
    else:
        result = _run_dc_pf(ppci)

    return result
コード例 #2
0
ファイル: powerflow.py プロジェクト: yliu33/pandapower
def _run_pf_algorithm(ppci, options, **kwargs):
    algorithm = options["algorithm"]
    ac = options["ac"]

    if ac:
        # ----- run the powerflow -----
        if algorithm == 'bfsw':  # forward/backward sweep power flow algorithm
            result = _run_bfswpf(ppci, options, **kwargs)[0]
        elif algorithm == 'nr':
            result = _run_newton_raphson_pf(ppci, options)
        elif algorithm in ['fdbx', 'fdxb', 'gs']:  # algorithms existing within pypower
            result = _runpf_pypower(ppci, options, **kwargs)[0]
        else:
            raise AlgorithmUnknown("Algorithm {0} is unknown!".format(algorithm))
    else:
        result = _run_dc_pf(ppci)

    return result
コード例 #3
0
def test_to_ppc_and_mpc():
    # pypower cases to validate
    functions = ['case4gs', 'case6ww', 'case30', 'case39']
    for fn in functions:
        # get pypower grids with results
        ppc_net = get_testgrids(fn, 'pypower_cases.p')

        # get pandapower grids
        pandapower_module = __import__('pandapower', fromlist=['networks'])
        pandapower_function = getattr(pandapower_module.networks, fn)
        net = pandapower_function()
        reset_results(net)

        # This should be reviewed
        pp.runpp(net)

        # convert pandapower grids to ppc
        ppc = cv.to_ppc(net)
        # convert pandapower grids to mpc (no result validation)
        mpc = cv.to_mpc(net)

        # validate voltage results of pandapower-to-ppc-converted grids vs. original pypower results
        net["_options"]['ac'] = True
        net["_options"]['numba'] = True
        net["_options"]['tolerance_mva'] = 1e-8
        net["_options"]['algorithm'] = "fdbx"
        net["_options"]['max_iteration'] = 30
        net["_options"]['enforce_q_lims'] = False
        net["_options"]['calculate_voltage_angles'] = True
        res_converted_pp, status_converted_pp = _runpf_pypower(
            ppc, net["_options"])

        if status_converted_pp:
            # get lookup pp2ppc
            bus_lookup = net["_pd2ppc_lookups"]["bus"]
            # check for equality in bus voltages
            pp_buses = bus_lookup[res_converted_pp['bus'][:,
                                                          BUS_I].astype(int)]
            res1 = res_converted_pp['bus'][pp_buses, VM:VA + 1]
            res2 = ppc_net['bus'][:, VM:VA + 1]
            assert np.allclose(res1, res2)
        else:
            raise LoadflowNotConverged("Loadflow did not converge!")
コード例 #4
0
ファイル: powerflow.py プロジェクト: venidera/pandapower
def _run_pf_algorithm(ppci, options, **kwargs):
    algorithm = options["algorithm"]
    ac = options["ac"]

    if ac:
        # ----- run the powerflow -----
        if ppci["branch"].shape[0] == 0:
            result = _pf_without_branches(ppci, options)
        elif algorithm == 'bfsw':  # forward/backward sweep power flow algorithm
            result = _run_bfswpf(ppci, options, **kwargs)[0]
        elif algorithm in ['nr', 'iwamoto_nr']:
            result = _run_newton_raphson_pf(ppci, options)
        elif algorithm in ['fdbx', 'fdxb']:  # fdbx/xb new algos
            # this implematation will much like be the newton_raphson
            result = _run_fast_decoupled_pf(ppci, options)
        elif algorithm == 'gs':  # last algorithm imported from pypower
            result = _runpf_pypower(ppci, options, **kwargs)[0]
        else:
            raise AlgorithmUnknown(
                "Algorithm {0} is unknown!".format(algorithm))
    else:
        result = _run_dc_pf(ppci)

    return result