def test_iec_60909_4_2ph(): net = iec_60909_4() sc.calc_sc(net, fault="2ph", case="max", ip=True, tk_s=0.1, kappa_method="C") ikss = [ 35.1994, 27.5249, 17.0373, 14.0536, 28.7429, 32.5304, 22.1611, 11.7586, 45.4177, 69.7774 ] ip = [ 87.0941, 69.8085, 39.6736, 31.9067, 72.2294, 84.9946, 44.7648, 31.9760, 118.0221, 182.1389 ] # No ib for 2ph sc calculation skss = [ 7722.50, 1748.07, 1082.01, 892.52, 1825.42, 187.81, 127.95, 203.67, 524.44, 402.86 ] assert np.allclose(net.res_bus_sc.ikss_ka.values[:10], np.array(ikss), atol=1e-3) assert np.allclose(net.res_bus_sc.ip_ka.values[:10], np.array(ip), atol=1e-3) assert np.allclose(net.res_bus_sc.skss_mw.values[:10], np.array(skss), atol=1e-1)
def test_1ph_shortcircuit_min(): results = { "Yy": [0.52209346201, 0.66632662571, 0.66756160176, 0.72517293174], "Yyn": [0.52209346201, 2.4135757259, 1.545054139, 0.99373917957], "Yd": [0.52209346201, 0.66632662571, 0.66756160176, 0.72517293174], "YNy": [0.62316686505, 0.66632662571, 0.66756160176, 0.72517293174], "YNyn": [0.620287259, 2.9155736491, 1.7561556936, 1.0807305212], "YNd": [0.75434229157, 0.66632662571, 0.66756160176, 0.72517293174], "Dy": [0.52209346201, 0.66632662571, 0.66756160176, 0.72517293174], "Dyn": [0.52209346201, 3.4393798093, 1.9535982949, 1.1558364456], "Dd": [0.52209346201, 0.66632662571, 0.66756160176, 0.72517293174] } for inv_y in (False, True): net = pp.create_empty_network() for vc in results.keys(): add_network(net, vc) try: sc.calc_sc(net, fault="1ph", case="min", inverse_y=inv_y) except: raise UserWarning( "Did not converge after adding transformer with vector group %s" % vc) for vc, result in results.items(): check_results(net, vc, result)
def test_branch_results_closed_ring(ring_network): net = ring_network net.switch.closed = True sc.calc_sc(net, branch_results=True) assert np.allclose(net.res_trafo_sc.ikss_lv_ka.values, [0.47705988]) assert np.allclose(net.res_line_sc.ikss_ka.values, [0.17559325, 0.29778739, 0.40286545])
def test_close_to_gen_simple(): # from pandapower.shortcircuit import calc_sc # vars = {name: getattr(calc_sc, name) for name in # dir(calc_sc) if not name.startswith('__')} # globals().update(vars) # del vars, calc_sc # WIP net = pp.create_empty_network() b1, b2, b3, b4, b5 = pp.create_buses(net, 5, 20) # skss = np.sqrt(3) * 400 * 40 # we assume 40 kA sc current in the 400-kV EHV grid # pp.create_ext_grid(net, b1, s_sc_max_mva=skss, s_sc_min_mva=0.8 * skss, rx_min=0.2, rx_max=0.4) pp.create_gen(net, b3, vn_kv=20, xdss_pu=0.2, rdss_pu=0.2 * 0.07, cos_phi=0.8, p_mw=5, sn_mva=5) pp.create_gen(net, b5, vn_kv=20, xdss_pu=0.2, rdss_pu=0.2 * 0.07, cos_phi=0.8, p_mw=10, sn_mva=10) pp.create_line(net, b1, b2, std_type="305-AL1/39-ST1A 110.0", length_km=10) pp.create_line(net, b2, b3, std_type="305-AL1/39-ST1A 110.0", length_km=10) pp.create_line(net, b3, b4, std_type="305-AL1/39-ST1A 110.0", length_km=50) pp.create_line(net, b4, b5, std_type="305-AL1/39-ST1A 110.0", length_km=10) # sc.calc_single_sc(net, b5) sc.calc_sc(net, tk_s=5e-2)
def one_line_one_generator(): net = pp.create_empty_network() b1 = pp.create_bus(net, vn_kv=10.) b2 = pp.create_bus(net, vn_kv=10.) b3 = pp.create_bus(net, vn_kv=10.) pp.create_bus(net, vn_kv=0.4, in_service=False) pp.create_gen(net, b1, vn_kv=10.5, xdss=0.2, rdss=0.001, cos_phi=0.8, p_kw=100, sn_kva=2500) pp.create_gen(net, b1, vn_kv=10.5, xdss=0.2, rdss=0.001, cos_phi=0.8, p_kw=100, sn_kva=2500) l = pp.create_line_from_parameters(net, b2, b1, length_km=1.0, max_i_ka=0.29, r_ohm_per_km=0.1548, x_ohm_per_km=0.0816814, c_nf_per_km=165) net.line.loc[l, "endtemp_degree"] = 165 pp.create_switch(net, b3, b1, et="b") sc.calc_sc(net) return net
def test_closed_ring(ring_network): net = ring_network net.switch.closed = True sc.calc_sc(net, ip=True, ith=True) assert np.allclose(net.res_trafo_sc.ikss_lv_ka.values, [0.4745379023]) assert np.allclose(net.res_line_sc.ikss_ka.values, [0.26039497, 0.20831598, 0.36590236])
def test_min_10_trafo_2ph(net_transformer): net = net_transformer sc.calc_sc(net, fault="2ph", case='min', ip=True, ith=True, lv_tol_percent = 10.) assert (abs(net.res_bus_sc.ikss_ka.at[0] - 2.0000000702) <1e-5) assert (abs(net.res_bus_sc.ikss_ka.at[2] - 11.182525915) <1e-5) assert (abs(net.res_bus_sc.ip_ka.at[0] - 4.9384391739) <1e-5) assert (abs(net.res_bus_sc.ip_ka.at[2] - 28.063977154) <1e-5)
def test_kappa_methods(ring_network): net = ring_network net.switch.closed = True sc.calc_sc(net, kappa_method="B", ip=True) assert np.allclose(net.res_bus_sc.ip_ka.values, [0.48810547956, 0.91192962511, 1.0264898716, 1.0360554521]) sc.calc_sc(net, kappa_method="C", ip=True, topology="auto") assert np.allclose(net.res_bus_sc.ip_ka.values, [0.48810547956, 0.91192962511, 0.89331396461, 0.90103415924])
def test_iec60909_example_4_two_trafo3w(): net = iec_60909_4_small(n_t3=2) ikss_pf_2t3 = [24.5772, 14.7247, 8.1060, 15.2749] sc.calc_sc(net, fault="1ph") assert np.allclose(net.res_bus_sc.ikss_ka.values[:4], np.array(ikss_pf_2t3), atol=1e-4)
def test_generator_book(): net=pp.create_empty_network() b1= pp.create_bus(net, 110) b2= pp.create_bus(net, 6) pp.create_ext_grid(net, b1, s_sc_max_mva=300, rx_max=0.1, s_sc_min_mva=250, rx_min=0.1) pp.create_transformer_from_parameters(net, b1, b2, 25, 110, 6, 0.5, 15, 15,0.1) pp.create_shunt(net, b2, 25, 0, 6) pp.create_gen(net, b2, 0, 1, sn_mva=25, vn_kv=6.3, xdss_pu=0.11, cos_phi=np.cos(np.arcsin(0.8))) sc.calc_sc(net, tk_s=2.5e-2)
def test_iec60909_example_4(): file = os.path.join(pp.pp_dir, "test", "test_files", "IEC60909-4_example.json") net = pp.from_json(file) sc.calc_sc(net, fault="1ph") assert np.isclose(net.res_bus_sc[net.bus.name=="Q"].ikss_ka.values[0], 10.05957231) assert np.isclose(net.res_bus_sc[net.bus.name=="T2LV"].ikss_ka.values[0], 34.467353142) assert np.isclose(net.res_bus_sc[net.bus.name=="F1"].ikss_ka.values[0], 35.53066312) assert np.isclose(net.res_bus_sc[net.bus.name=="F2"].ikss_ka.values[0], 34.89135137) assert np.isclose(net.res_bus_sc[net.bus.name=="F3"].ikss_ka.values[0], 5.0321033105) assert np.isclose(net.res_bus_sc[net.bus.name=="Cable/Line IC"].ikss_ka.values[0], 16.362586813)
def test_shunt(): net = pp.create_empty_network() b1 = pp.create_bus(net, 110) b2 = pp.create_bus(net, 110) pp.create_ext_grid(net, b1, s_sc_max_mva=300, rx_max=0.1) # pp.create_shunt(net, b2, 25, 0, 6) pp.create_line(net, b1, b2, std_type="305-AL1/39-ST1A 110.0", length_km=10) sc.calc_sc(net, tk_s=2.5e-2)
def test_1ph_with_switches(): net = pp.create_empty_network() vc = "Yy" l1, l2, _ = add_network(net, vc) sc.calc_sc(net, fault="1ph", case="max") pp.create_line(net, net.line.to_bus.at[l2], net.line.from_bus.at[l1], length_km=15, std_type="unsymmetric_line_type", parallel=2.) pp.add_zero_impedance_parameters(net) pp.create_switch(net, bus=net.line.to_bus.at[l2], element=l2, et="l", closed=False) sc.calc_sc(net, fault="1ph", case="max") check_results(net, vc, [0.52209347338, 2.0620266652, 2.3255761263, 2.3066467489])
def test_iec_60909_4_small_with_gen_ps_unit_1ph(): net = iec_60909_4_small(n_t3=2, num_earth=1, with_gen=True) sc.calc_sc(net, fault="1ph", case="max", ip=True, tk_s=0.1, kappa_method="C") ikss_max = [24.6109, 17.4363, 12.7497, 18.6883]
def test_meshed_network(meshed_grid): net = meshed_grid sc.calc_sc(net) sc_bus = 5 ik = net.res_bus_sc.ikss_ka.at[sc_bus] sc.calc_single_sc(net, bus=sc_bus) assert isclose(net.res_bus_sc.vm_pu.at[sc_bus], 0) line_flow_into_sc = net.res_line_sc.i_ka[(net.line.to_bus == sc_bus) | ( net.line.from_bus == sc_bus)].sum() assert isclose(line_flow_into_sc, ik, atol=2e-3)
def test_meshed_network(meshed_grid): net = meshed_grid sc.calc_sc(net) sc_bus = 5 ik = net.res_bus_sc.ikss_ka.at[sc_bus] for inv_y in (False, True): sc.calc_sc(net, bus=sc_bus, inverse_y=inv_y, branch_results=True) line_flow_into_sc = net.res_line_sc.ikss_ka[( net.line.to_bus == sc_bus) | (net.line.from_bus == sc_bus)].sum() assert np.isclose(line_flow_into_sc, ik, atol=2e-3)
def test_against_single_sc_results_line(): net = three_bus_permuted_index() sc.calc_sc(net, case="max", branch_results=True, return_all_currents=True) multi_results = net.res_line_sc.copy() for bus in net.bus.index: sc.calc_sc(net, bus=bus, case="max", branch_results=True, return_all_currents=True) line_bus_indices = [(line, bus) for line in net.line.index] single_result = net.res_line_sc.ikss_ka.values multi_result = multi_results.ikss_ka.loc[line_bus_indices].values assert np.allclose(single_result, multi_result)
def test_iec_60909_4_3ph_small_with_gen_xward(): net = iec_60909_4_small(with_xward=True) sc.calc_sc(net, fault="3ph", case="max", ip=True, tk_s=0.1, kappa_method="C") ikss_pf = [40.6422, 31.6394, 16.7409, 33.2808] assert np.allclose(net.res_bus_sc.ikss_ka.values[:4], np.array(ikss_pf), atol=1e-3)
def test_iec60909_example_4_one_trafo3w(): net = iec_60909_4_small(n_t3=1) # r0 = 2.378330877 # x0 = 17.335578502 # r = 0.59621204768 # x = 6.0598429694 ikss_pf = [24.4009, 8.2481, 6.1728, 10.1851] sc.calc_sc(net, fault="1ph") assert np.allclose(net.res_bus_sc.ikss_ka.values[:4], np.array(ikss_pf), atol=1e-4)
def test_close_to_gen_simple2(): # WIP net = pp.create_empty_network() # b1, b2 = pp.create_buses(net, 2, 110) b1 = pp.create_bus(net, 70) # skss = np.sqrt(3) * 400 * 40 # we assume 40 kA sc current in the 400-kV EHV grid # pp.create_ext_grid(net, b1, s_sc_max_mva=skss, s_sc_min_mva=0.8 * skss, rx_min=0.2, rx_max=0.4) pp.create_gen(net, b1, vn_kv=70, xdss_pu=0.2, rdss_pu=0.2*0.07, cos_phi=0.8, p_mw=0, sn_mva=50) # pp.create_gen(net, b3, vn_kv=70, xdss_pu=0.2, rdss_pu=0.001, cos_phi=0.8, p_mw=50, sn_mva=60) # pp.create_line(net, b1, b2, std_type="305-AL1/39-ST1A 110.0", length_km=10) # pp.create_line(net, b2, b3, std_type="305-AL1/39-ST1A 110.0", length_km=10) # sc.calc_single_sc(net, b2) sc.calc_sc(net, tk_s=5e-2)
def test_radial_network(radial_grid): net = radial_grid sc_bus = 3 sc.calc_sc(net) ik = net.res_bus_sc.ikss_ka.at[sc_bus] sc.calc_sc(net, bus=sc_bus, inverse_y=False, branch_results=True, return_all_currents=True) assert np.isclose(net.res_bus_sc.ikss_ka.at[sc_bus], ik) assert np.isclose(net.res_line_sc.ikss_ka.loc[(1, sc_bus)], ik) assert np.isclose(net.res_line_sc.ikss_ka.loc[(0, sc_bus)], ik) assert np.isclose(net.res_trafo_sc.ikss_lv_ka.loc[(0, sc_bus)], ik) trafo_ratio = net.trafo.vn_lv_kv.values / net.trafo.vn_hv_kv.values assert np.isclose(net.res_trafo_sc.ikss_hv_ka.loc[(0, sc_bus)], ik * trafo_ratio) sc_bus = 2 sc.calc_sc(net) ik = net.res_bus_sc.ikss_ka.at[sc_bus] sc.calc_sc(net, bus=sc_bus, inverse_y=False, branch_results=True, return_all_currents=True) assert np.isclose(net.res_bus_sc.ikss_ka.at[sc_bus], ik) assert np.isclose(net.res_line_sc.ikss_ka.loc[(1, sc_bus)], 0) assert np.isclose(net.res_line_sc.ikss_ka.loc[(0, sc_bus)], ik) assert np.isclose(net.res_trafo_sc.ikss_lv_ka.loc[(0, sc_bus)], ik) trafo_ratio = net.trafo.vn_lv_kv.values / net.trafo.vn_hv_kv.values assert np.isclose(net.res_trafo_sc.ikss_hv_ka.loc[(0, sc_bus)], ik * trafo_ratio)
def test_branch_results_open_ring_with_impedance(ring_network): net = ring_network sc.calc_sc(net, branch_results=True, inverse_y=False) res_line_no_imp = net.res_line_sc.ikss_ka.values.copy() # Make sure that with fault impedance, the total current should be smaller sc.calc_sc(net, branch_results=True, inverse_y=False, r_fault_ohm=1, x_fault_ohm=5) non_null_flag = np.abs(res_line_no_imp) > 1e-10 assert np.all(net.res_line_sc.ikss_ka.values[non_null_flag] < res_line_no_imp[non_null_flag])
def test_big_gen_network_calc_sc(): net = three_bus_big_sgen_example() for inv_y in (False, True): sc_bus = 0 sc.calc_sc(net, bus=sc_bus, branch_results=True, inverse_y=inv_y) assert np.isclose(net.res_line_sc.ikss_ka.at[0], 1.25967331, atol=1e-3) assert np.isclose(net.res_line_sc.ikss_ka.at[1], 0., atol=1e-3) sc_bus = 2 sc.calc_sc(net, bus=sc_bus, branch_results=True, inverse_y=inv_y) assert np.isclose(net.res_line_sc.ikss_ka.at[0], 0.46221808, atol=1e-3) assert np.isclose(net.res_line_sc.ikss_ka.at[1], 1.72233192, atol=1e-3)
def test_iec60909_example_4_bus_selection(): file = os.path.join(pp.pp_dir, "test", "test_files", "IEC60909-4_example.json") net = pp.from_json(file) for inv_y in (False, True): sc.calc_sc(net, fault="1ph", inverse_y=inv_y, bus=net.bus[net.bus.name.isin(("F1", "F2"))].index) assert np.isclose( net.res_bus_sc.at[net.bus[net.bus.name == "F1"].index[0], "ikss_ka"], 35.53066312) assert np.isclose( net.res_bus_sc.at[net.bus[net.bus.name == "F2"].index[0], "ikss_ka"], 34.89135137)
def test_iec_60909_4_small_with_t2_1ph(): net = iec_60909_4_small(n_t3=2, num_earth=1, with_gen=True) net.gen = net.gen.iloc[0:0, :] sc.calc_sc(net, fault="1ph", case="max", ip=True, tk_s=0.1, kappa_method="C") ikss_max = [24.57717, 16.96235, 11.6109, 18.07836] # ikss_min = [3.5001, 8.4362, 7.4743, 7.7707] assert np.allclose(net.res_bus_sc.ikss_ka.values[:4], np.array(ikss_max), atol=1e-4)
def test_against_single_sc_results_trafo(): net = net_transformer() sc.calc_sc(net, case="max", branch_results=True, return_all_currents=True, inverse_y=False) multi_results = net.res_trafo_sc.copy() for bus in net.bus.index[net.bus.in_service]: sc.calc_sc(net, bus=bus, case="max", branch_results=True, return_all_currents=True, inverse_y=False) trafo_bus_indices = [(trafo, bus) for trafo in net.trafo.index] single_result_lv = net.res_trafo_sc.ikss_lv_ka.values multi_result_lv = multi_results.ikss_lv_ka.loc[trafo_bus_indices].values assert np.allclose(single_result_lv, multi_result_lv) single_result_hv = net.res_trafo_sc.ikss_hv_ka.values multi_result_hv = multi_results.ikss_hv_ka.loc[trafo_bus_indices].values assert np.allclose(single_result_hv, multi_result_hv)
def test_power_station_unit(): net = pp.create_empty_network() b1, b2, b3, b4 = pp.create_buses(net, 4, 20) b5 = pp.create_bus(net, 10) pp.create_ext_grid(net, b1, s_sc_max_mva=250, rx_max=0.1) pp.create_line(net, b1, b2, std_type="305-AL1/39-ST1A 110.0", length_km=10) pp.create_line(net, b2, b3, std_type="305-AL1/39-ST1A 110.0", length_km=10) pp.create_line(net, b3, b4, std_type="305-AL1/39-ST1A 110.0", length_km=50) pp.create_transformer_from_parameters(net, b4, b5, 25, 20, 10, 0.41104, 10.3, 0.1, 0.1) pp.create_gen(net, b5, vn_kv=10, xdss_pu=0.12, cos_phi=0.8, p_mw=0, sn_mva=10) sc.calc_sc(net)
def test_1ph_shortcircuit(): results = { "Yy": [0.52209347337, 0.74400073149, 0.74563682772, 0.81607276962], "Yyn": [0.52209347337, 2.5145986133, 1.6737892808, 1.1117955913], "Yd": [0.52209347337, 0.74400073149, 0.74563682772, 0.81607276962], "YNy": [0.6291931171, 0.74400073149, 0.74563682772, 0.81607276962], "YNyn": [0.62623661918, 2.9829679356, 1.8895041867, 1.2075537026], "YNd": [0.75701600162, 0.74400073149, 0.74563682772, 0.81607276962], "Dy": [0.52209347337, 0.74400073149, 0.74563682772, 0.81607276962], "Dyn": [0.52209347337, 3.5054043285, 2.1086590382, 1.2980120038], "Dd": [0.52209347337, 0.74400073149, 0.74563682772, 0.81607276962] } net = pp.create_empty_network() for vc in results.keys(): add_network(net, vc) try: sc.calc_sc(net, fault="1ph", case="max") except: raise UserWarning( "Did not converge after adding transformer with vector group %s" % vc) for vc, result in results.items(): check_results(net, vc, result)
def test_iec_60909_4_small_with_gen_1ph_no_ps_detection(): net = iec_60909_4_small(n_t3=2, num_earth=1, with_gen=True) net.gen.power_station_trafo = np.nan sc.calc_sc(net, fault="1ph", case="max", ip=True, tk_s=0.1, kappa_method="C") ikss_max = [24.60896, 17.2703, 12.3771, 18.4723] # ikss_min = [3.5001, 8.4362, 7.4743, 7.7707] # ip_min = [8.6843, 21.6173, 18.0242, 19.4261] assert np.allclose(net.res_bus_sc.ikss_ka.values[:4], np.array(ikss_max), atol=1e-4)
def test_iec_60909_4_3ph_2gen_no_ps_detection(): net = iec_60909_4_2gen() net.gen.power_station_trafo = np.nan net.gen.at[0, "in_service"] = False net.gen = net.gen.query("in_service") sc.calc_sc(net, fault="3ph", case="max", ip=True, tk_s=0.1, kappa_method="C") ikss_pf = [1.8460, 1.6715, 6.8953, 39.5042] assert np.allclose(net.res_bus_sc.ikss_ka[:4].values, np.array(ikss_pf), atol=1e-3)