def test_case3120sp():
    net = pn.case3120sp()
    assert net.converged
    pp.runpp(net, trafo_model='pi')
    assert len(net.bus) == 3120
    assert len(net.line) + len(net.trafo) == 3693
    assert len(net.ext_grid) + len(net.gen) + len(net.sgen) == 505
    assert net.converged
Exemplo n.º 2
0
def main():

    # net = nw.case14()
    # net = nw.case1354pegase()
    net = nw.case3120sp()
    print(net)

    unsupported = False
    unsupported |= net.ward.shape[0] > 0
    unsupported |= net.xward.shape[0] > 0
    unsupported |= net.dcline.shape[0] > 0
    unsupported |= net.storage.shape[0] > 0
    unsupported |= net.load.const_z_percent.sum() > 0
    unsupported |= net.load.const_i_percent.sum() > 0
    gen_buses = net.gen.bus.tolist() + net.ext_grid.bus.tolist()
    unsupported |= len(gen_buses) != len(set(gen_buses))
    if unsupported:
        print('Unsupported elements exist in the network')

    pp.runpp(net)
    ybus = np.array(net._ppc["internal"]["Ybus"].todense())
    v = np.squeeze(np.array(net._ppc["internal"]["V"]))  # solved bus voltages

    # Convert loads to admittances. More stable matrix inversion, and no
    # current injection required.
    ybus += get_load_admittances(np.zeros_like(ybus), net)

    # Check that we can calculate an I vector and use it to recalculate V.
    # This is really a check of numerical stability.
    i_ = np.squeeze(ybus @ v)
    v_ = np.squeeze(np.linalg.inv(ybus) @ i_)
    print('Reconstructed voltage is the same?', np.allclose(v, v_))

    i = np.zeros(ybus.shape[0], dtype=ybus.dtype)
    i += get_i(np.zeros_like(i), net)

    t1 = time.perf_counter()
    calculated_v = np.squeeze(np.linalg.inv(ybus) @ i)
    t_inv = time.perf_counter() - t1

    t1 = time.perf_counter()
    calculated_v_solved = np.squeeze(np.linalg.solve(ybus, i))
    t_solve = time.perf_counter() - t1

    print("Is calculated V same as load flow solved V?",
          np.allclose(v, calculated_v), f'in {t_inv} seconds, and with'
          f' a different of ', np.sum(np.abs(v - calculated_v)))
    print("Is calculated V by solve same as load flow solved V?",
          np.allclose(v, calculated_v_solved), f'in {t_solve} seconds'
          f' a different of ', np.sum(np.abs(v - calculated_v_solved)))
Exemplo n.º 3
0
def test_case3120sp():
    net = pn.case3120sp()
    assert net.converged
    _ppc_element_test(net, 3120, 3693, 505, True)