예제 #1
0
def test_PTDF():
    net = nw.case9()
    pp.rundcpp(net)
    _, ppci = _pd2ppc(net)

    ptdf = makePTDF(ppci["baseMVA"],
                    ppci["bus"],
                    ppci["branch"],
                    using_sparse_solver=False)
    _ = makePTDF(ppci["baseMVA"],
                 ppci["bus"],
                 ppci["branch"],
                 result_side=1,
                 using_sparse_solver=False)
    ptdf_sparse = makePTDF(ppci["baseMVA"],
                           ppci["bus"],
                           ppci["branch"],
                           using_sparse_solver=True)

    if not np.allclose(ptdf, ptdf_sparse):
        raise AssertionError(
            "Sparse PTDF has differenct result against dense PTDF")
    if not ptdf.shape == (ppci["bus"].shape[0], ppci["branch"].shape[0]):
        raise AssertionError("PTDF has wrong dimension")
    if not np.all(~np.isnan(ptdf)):
        raise AssertionError("PTDF has NaN value")
예제 #2
0
def test_LODF():
    net = nw.case9()
    pp.rundcpp(net)
    _, ppci = _pd2ppc(net)

    ptdf = makePTDF(ppci["baseMVA"], ppci["bus"], ppci["branch"])
    lodf = makeLODF(ppci["branch"], ptdf)
    if not lodf.shape == (ppci["branch"].shape[0], ppci["branch"].shape[0]):
        raise AssertionError("LODF has wrong dimension")
예제 #3
0
파일: pandapower.py 프로젝트: CURENT/andes
def make_GSF(ppn, verify=True, using_sparse_solver=False):
    """
    Build the Generation Shift Factor matrix of a pandapower net.

    Parameters
    ----------
    ppn : pandapower.network.Network
        Pandapower network
    verify : bool
        True to verify the GSF with that from DC power flow
    using_sparse_solver : bool
        True to use a sparse solver for pandapower maktPTDF

    Returns
    -------
    np.ndarray
        The GSF array
    """

    from pandapower.pypower.makePTDF import makePTDF
    from pandapower.pd2ppc import _pd2ppc

    # --- run DCPF ---
    pp.rundcpp(ppn)

    # --- compute PTDF ---
    _, ppci = _pd2ppc(ppn)
    ptdf = makePTDF(ppci["baseMVA"],
                    ppci["bus"],
                    ppci["branch"],
                    using_sparse_solver=using_sparse_solver)

    # --- get the gsf ---
    line_size = ppn.line.shape[0]
    gsf = ptdf[0:line_size, :]

    if verify:
        _verifyGSF(ppn, gsf)

    return gsf