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_against_single_sc_results_line(three_bus_permuted_index): 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_single_sc(net, bus=bus) line_bus_indices = [(line, bus) for line in net.line.index] single_result = net.res_line_sc.i_ka.values multi_result = multi_results.ikss_ka.loc[line_bus_indices].values assert np.allclose(single_result, multi_result)
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_single_sc(net, bus=sc_bus, inverse_y=inv_y) assert np.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 np.isclose(line_flow_into_sc, ik, atol=2e-3)
def test_big_gen_network(three_bus_big_sgen_example): net = three_bus_big_sgen_example sc_bus = 0 sc.calc_single_sc(net, sc_bus, inverse_y=True) assert np.isclose(net.res_line_sc.i_ka.at[0], 1.25967331, atol=1e-3) assert np.isclose(net.res_line_sc.i_ka.at[1], 0., atol=1e-3) sc_bus = 2 sc.calc_single_sc(net, sc_bus, inverse_y=True) assert np.isclose(net.res_line_sc.i_ka.at[0], 0.46221808, atol=1e-3) assert np.isclose(net.res_line_sc.i_ka.at[1], 1.72233192, atol=1e-3)
def test_big_gen_network_no_y_inv(three_bus_big_sgen_example): # ("TODO: Fix the bug in the single sc mode without Yinv") net = three_bus_big_sgen_example sc_bus = 0 sc.calc_single_sc(net, sc_bus, inverse_y=False) assert np.isclose(net.res_line_sc.i_ka.at[0], 1.25967331, atol=1e-3) assert np.isclose(net.res_line_sc.i_ka.at[1], 0., atol=1e-3) sc_bus = 2 sc.calc_single_sc(net, sc_bus, inverse_y=False) assert np.isclose(net.res_line_sc.i_ka.at[0], 0.46221808, atol=1e-3) assert np.isclose(net.res_line_sc.i_ka.at[1], 1.72233192, atol=1e-3)
def test_against_single_sc_results_trafo(net_transformer): net = net_transformer sc.calc_sc(net, case="max", branch_results=True, return_all_currents=True) multi_results = net.res_trafo_sc.copy() for bus in net.bus.index[net.bus.in_service]: sc.calc_single_sc(net, bus=bus) trafo_bus_indices = [(trafo, bus) for trafo in net.trafo.index] single_result_lv = net.res_trafo_sc.i_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.i_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_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_single_sc(net, bus=sc_bus) assert isclose(net.res_bus_sc.vm_pu.at[sc_bus], 0) assert isclose(net.res_line_sc.i_ka.at[1], ik) assert isclose(net.res_line_sc.i_ka.at[0], ik) assert isclose(net.res_trafo_sc.i_lv_ka.at[0], ik) trafo_ratio = net.trafo.vn_lv_kv.values / net.trafo.vn_hv_kv.values assert isclose(net.res_trafo_sc.i_hv_ka.at[0], ik * trafo_ratio) sc_bus = 2 sc.calc_sc(net) 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) assert isclose(net.res_line_sc.i_ka.at[1], 0) assert isclose(net.res_line_sc.i_ka.at[0], ik) assert isclose(net.res_trafo_sc.i_lv_ka.at[0], ik) trafo_ratio = net.trafo.vn_lv_kv.values / net.trafo.vn_hv_kv.values assert isclose(net.res_trafo_sc.i_hv_ka.at[0], ik * trafo_ratio)