def test_init_results(): net = pp.create_empty_network() add_test_line(net) #line network with switch at to bus assert_init_results(net) net.switch.at[0, "bus"] = 0 #switch at from bus assert_init_results(net) add_test_trafo(net) #trafo network with switch at lv bus assert_init_results(net) net.switch.at[0, "bus"] = 7 #switch at hv bus assert_init_results(net) add_test_xward(net) #xward with internal node assert_init_results(net) add_test_trafo3w(net) #trafo3w with internal node assert_init_results(net) t3idx = net.trafo3w.index[0] t3_switch = pp.create_switch(net, bus=net.trafo3w.hv_bus.at[t3idx], element=t3idx, et="t3", closed=False) #trafo3w switch at hv side assert_init_results(net) net.switch.bus.at[t3_switch] = net.trafo3w.mv_bus.at[ t3idx] #trafo3w switch at mv side assert_init_results(net) net.switch.bus.at[t3_switch] = net.trafo3w.lv_bus.at[ t3idx] #trafo3w switch at lv side assert_init_results(net)
def test_trafo(): net = pp.create_empty_network() add_test_trafo(net) for library in libraries: trafo, open_loop_trafo, oos_trafo = net.trafo.index f, t = net.trafo.hv_bus.at[trafo], net.trafo.lv_bus.at[trafo] # check that oos trafos are neglected and switches are respected mg = create_nxgraph(net, library=library) assert set(mg.get_edge_data(f, t).keys()) == {("trafo", trafo)} assert set(mg.nodes()) == set(net.bus.index) # check respect_switches mg = create_nxgraph(net, respect_switches=False, library=library) assert set(mg.get_edge_data(f, t).keys()) == {("trafo", trafo), ("trafo", open_loop_trafo)} assert set(mg.nodes()) == set(net.bus.index) # check not including trafos mg = create_nxgraph(net, include_trafos=False, library=library) assert mg.get_edge_data(f, t) is None assert set(mg.nodes()) == set(net.bus.index) # check edge attributes net.trafo.vn_hv_kv = 20 net.trafo.vn_lv_kv = 0.4 net.trafo.pfe_kw = 0 net.trafo.i0_percent = 0 mg = create_nxgraph(net, calc_branch_impedances=True, library=library) trafo_tab = net.trafo.loc[trafo] par = mg.get_edge_data(f, t, key=("trafo", trafo)) base_Z = (trafo_tab.sn_mva) / (trafo_tab.vn_hv_kv**2) r = (trafo_tab.vkr_percent / 100) / base_Z / trafo_tab.parallel z = (trafo_tab.vk_percent / 100) / base_Z / trafo_tab.parallel assert np.isclose(par["r_ohm"], r) assert np.isclose(par["z_ohm"], z) assert par["weight"] == 0 assert par["path"] == 1 mg = create_nxgraph(net, calc_branch_impedances=True, branch_impedance_unit="pu", library=library) par = mg.get_edge_data(f, t, key=("trafo", trafo)) pp.runpp(net) f, t = net._pd2ppc_lookups["branch"]["trafo"] assert np.isclose(par["r_pu"], net._ppc["branch"][f, BR_R]) assert np.isclose(par["x_pu"], net._ppc["branch"][f, BR_X])
def network_with_trafo3ws(): net = pp.create_empty_network() add_test_trafo(net) slack, hv, ln = add_grid_connection(net, zone="test_trafo3w") for _ in range(2): mv = pp.create_bus(net, vn_kv=0.6, zone="test_trafo3w") pp.create_load(net, mv, p_mw=0.8, q_mvar=0) lv = pp.create_bus(net, vn_kv=0.4, zone="test_trafo3w") pp.create_load(net, lv, p_mw=0.5, q_mvar=0) t3 = pp.create_transformer3w_from_parameters(net, hv_bus=hv, mv_bus=mv, lv_bus=lv, vn_hv_kv=22, vn_mv_kv=.64, vn_lv_kv=.42, sn_hv_mva=1, sn_mv_mva=0.7, sn_lv_mva=0.3, vk_hv_percent=1., vkr_hv_percent=.03, vk_mv_percent=.5, vkr_mv_percent=.02, vk_lv_percent=.25, vkr_lv_percent=.01, pfe_kw=.5, i0_percent=0.1, name="test", index=pp.get_free_id(net.trafo3w) + 1, tap_side="hv", tap_pos=2, tap_step_percent=1.25, tap_min=-5, tap_neutral=0, tap_max=5) return (net, t3, hv, mv, lv)
def test_trafo3w_switches(): net = pp.create_empty_network() add_test_trafo(net) slack, hv, ln = add_grid_connection(net, zone="test_trafo3w") for _ in range(2): mv = pp.create_bus(net, vn_kv=0.6, zone="test_trafo3w") pp.create_load(net, mv, p_kw=800, q_kvar=0) lv = pp.create_bus(net, vn_kv=0.4, zone="test_trafo3w") pp.create_load(net, lv, p_kw=500, q_kvar=0) t3 = pp.create_transformer3w_from_parameters( net, hv_bus=hv, mv_bus=mv, lv_bus=lv, vn_hv_kv=22, vn_mv_kv=.64, vn_lv_kv=.42, sn_hv_kva=1000, sn_mv_kva=700, sn_lv_kva=300, vsc_hv_percent=1., vscr_hv_percent=.03, vsc_mv_percent=.5, vscr_mv_percent=.02, vsc_lv_percent=.25, vscr_lv_percent=.01, pfe_kw=.5, i0_percent=0.1, name="test", index=pp.get_free_id(net.trafo3w) + 1, tp_side="hv", tp_pos=2, tp_st_percent=1.25, tp_min=-5, tp_mid=0, tp_max=5) # open switch at hv side - t3 is disconnected s1 = pp.create_switch(net, bus=hv, element=t3, et="t3", closed=False) runpp_with_consistency_checks(net) assert np.isnan(net.res_bus.vm_pu.at[mv]) assert np.isnan(net.res_bus.vm_pu.at[lv]) assert np.isnan(net.res_trafo3w.p_hv_kw.at[t3]) == 0 # open switch at mv side - mv is disconnected, lv is connected net.switch.bus.at[s1] = mv runpp_with_consistency_checks(net) assert np.isnan(net.res_bus.vm_pu.at[mv]) assert not np.isnan(net.res_bus.vm_pu.at[lv]) assert net.res_trafo3w.i_lv_ka.at[t3] > 1e-5 assert net.res_trafo3w.i_mv_ka.at[t3] < 1e-5 assert 490 < net.res_trafo3w.p_hv_kw.at[t3] < 510 # open switch at lv side - lv is disconnected, mv is connected net.switch.bus.at[s1] = lv runpp_with_consistency_checks(net) assert np.isnan(net.res_bus.vm_pu.at[lv]) assert not np.isnan(net.res_bus.vm_pu.at[mv]) assert net.res_trafo3w.i_lv_ka.at[t3] < 1e-5 assert net.res_trafo3w.i_mv_ka.at[t3] > 1e-5 assert 790 < net.res_trafo3w.p_hv_kw.at[t3] < 810 # open switch at lv and mv side - lv and mv is disconnected, t3 in open loop pp.create_switch(net, bus=mv, element=t3, et="t3", closed=False) runpp_with_consistency_checks(net) assert np.isnan(net.res_bus.vm_pu.at[lv]) assert np.isnan(net.res_bus.vm_pu.at[mv]) assert net.res_trafo3w.i_lv_ka.at[t3] < 1e-5 assert net.res_trafo3w.i_mv_ka.at[t3] < 1e-5 assert 0 < net.res_trafo3w.p_hv_kw.at[t3] < 1