コード例 #1
0
def test_pypower_cases():
    # check pypower cases
    name = [
        'case4gs', 'case6ww', 'case24_ieee_rts', 'case30', 'case39', 'case118',
        'case300'
    ]
    for i in name:
        ppc = get_testgrids(i, 'pypower_cases.p')
        net = from_ppc(ppc, f_hz=60)
        assert validate_from_ppc(ppc, net, max_diff_values=max_diff_values1)
        logger.debug('%s has been checked successfully.' % i)
    # --- Because there is a pypower power flow failure in generator results in case9 (which is not
    # in matpower) another max_diff_values must be used to receive an successful validation
    max_diff_values2 = {
        "vm_pu": 1e-6,
        "va_degree": 1e-5,
        "p_branch_kw": 1e-3,
        "q_branch_kvar": 1e-3,
        "p_gen_kw": 1e3,
        "q_gen_kvar": 1e3
    }
    ppc = get_testgrids('case9', 'pypower_cases.p')
    net = from_ppc(ppc, f_hz=60)
    assert validate_from_ppc(ppc, net, max_diff_values=max_diff_values2)
    logger.debug('case9 has been checked successfully.')
コード例 #2
0
ファイル: from_mpc.py プロジェクト: Tooblippe/pandapower
def from_mpc(mpc_file,
             f_hz=50,
             casename_mpc_file='mpc',
             validate_conversion=False):
    """
    This function converts a matpower case file (.mat) version 2 to a pandapower net.
    Note: python is 0-based while Matlab is 1-based.

    INPUT:

        **mpc_file** - path to a matpower case file (.mat).

    OPTIONAL:

        **f_hz** (int, 50) - The frequency of the network.

        **casename_mpc_file** (str, 'mpc') - If mpc_file does not contain the arrays "gen", "branch" and "bus" it will use the
            sub-struct casename_mpc_file

    OUTPUT:

        **net** - The pandapower network

    EXAMPLE:

        import pandapower.converter as pc

        pp_net = cv.from_ppc('case9.mat', f_hz=60)

    """
    ppc = _mpc2ppc(mpc_file, casename_mpc_file)
    net = from_ppc(ppc, f_hz, validate_conversion)

    return net
コード例 #3
0
def test_ppc_testgrids():
    # check ppc_testgrids
    name = ['case2_1', 'case2_2', 'case2_3', 'case2_4', 'case3_1', 'case3_2', 'case6', 'case14',
            'case57']
    for i in name:
        ppc = get_testgrids(i, 'ppc_testgrids.p')
        net = from_ppc(ppc, f_hz=60)
        assert validate_from_ppc(ppc, net, max_diff_values=max_diff_values1)
        logger.debug('%s has been checked successfully.' % i)
コード例 #4
0
def test_from_ppc():
    ppc = get_testgrids('case2_2', 'ppc_testgrids.p')
    net_by_ppc = from_ppc(ppc)
    net_by_code = pp.from_json(os.path.join(os.path.split(pp.__file__)[0], 'test', 'converter', 'case2_2_by_code.json'))
    pp.set_user_pf_options(net_by_code)  # for assertion of nets_equal
    pp.runpp(net_by_ppc, trafo_model="pi")
    pp.runpp(net_by_code, trafo_model="pi")

    assert type(net_by_ppc) == type(net_by_code)
    assert net_by_ppc.converged
    assert len(net_by_ppc.bus) == len(net_by_code.bus)
    assert len(net_by_ppc.trafo) == len(net_by_code.trafo)
    assert len(net_by_ppc.ext_grid) == len(net_by_code.ext_grid)
    assert pp.nets_equal(net_by_ppc, net_by_code, check_only_results=True, tol=1.e-9)
コード例 #5
0
def test_from_ppc():
    ppc = get_testgrids('case2_2', 'ppc_testgrids.p')
    net_by_ppc = from_ppc(ppc)
    net_by_code = get_testgrids('case2_2_by_code', 'ppc_testgrids.p')
    pp.runpp(net_by_ppc, trafo_model="pi")
    pp.runpp(net_by_code, trafo_model="pi")

    assert type(net_by_ppc) == type(net_by_code)
    assert net_by_ppc.converged
    assert len(net_by_ppc.bus) == len(net_by_code.bus)
    assert len(net_by_ppc.trafo) == len(net_by_code.trafo)
    assert len(net_by_ppc.ext_grid) == len(net_by_code.ext_grid)
    assert pp.nets_equal(net_by_ppc,
                         net_by_code,
                         check_only_results=True,
                         tol=1.e-9)
コード例 #6
0
def test_case9_conversion():
    net = pn.case9()
    ppc = to_ppc(net)
    # correction because to_ppc do net export max_loading_percent:
    ppc["branch"][:, 5] = [250, 250, 150, 300, 150] + [250] * 4
    # correction because voltage limits are set to 1.0 at slack buses
    ppc["bus"][0, 11] = 0.9
    ppc["bus"][0, 12] = 1.1

    net2 = from_ppc(ppc)

    pp.runpp(net)
    pp.runpp(net2)
    assert pp.nets_equal(net, net2, check_only_results=True, tol=1e-10)

    pp.runopp(net)
    pp.runopp(net2)
    assert pp.nets_equal(net, net2, check_only_results=True, tol=1e-10)
コード例 #7
0
def create_pp_from_ppc():
    # create ppc
    ppc = create_ppc()
    # convert it to a pandapower net
    net = cv.from_ppc(ppc, validate_conversion=False)
    # run a power flow
    pp.runpp(net)
    vm_pu_before = net.res_bus.vm_pu.values
    # manual corrections and additional information such as line length in km and names
    net = add_additional_information(net)
    # run power flow again and validate results
    pp.runpp(net)
    vm_pu_after = net.res_bus.vm_pu.values
    # power flow results should not change
    assert np.allclose(vm_pu_after, vm_pu_before)
    # save it
    pp.to_json(net, "pandapower_net.json")
    # plot it :)
    plot_net(net)
コード例 #8
0
ファイル: test_from_ppc.py プロジェクト: yliu33/pandapower
def test_case9_conversion():
    net = pn.case9()
    # set max_loading_percent to enable line limit conversion
    net.line["max_loading_percent"] = 100
    ppc = to_ppc(net, mode="opf")
    # correction because voltage limits are set to 1.0 at slack buses
    ppc["bus"][0, 12] = 0.9
    ppc["bus"][0, 11] = 1.1

    net2 = from_ppc(ppc, f_hz=net.f_hz)
    # again add max_loading_percent to enable valid comparison
    net2.line["max_loading_percent"] = 100

    # compare loadflow results
    pp.runpp(net)
    pp.runpp(net2)
    assert pp.nets_equal(net, net2, check_only_results=True, tol=1e-10)

    # compare optimal powerflow results
    pp.runopp(net)
    pp.runopp(net2)
    assert pp.nets_equal(net, net2, check_only_results=True, tol=1e-10)
コード例 #9
0
ファイル: test_from_ppc.py プロジェクト: zzn1220/pandapower
def test_case24():
    net = from_ppc(c24.case24_ieee_rts())
    pp.runopp(net)
    assert net.OPF_converged