def test_merge_asymmetric(): """Test that merging nets properly handles bus IDs for asymmetric elements """ net1 = nw.ieee_european_lv_asymmetric() net2 = nw.ieee_european_lv_asymmetric() n_load_busses = len(net1.asymmetric_load.bus.unique()) n_sgen_busses = len(net1.asymmetric_sgen.bus.unique()) net3 = pp.merge_nets(net1, net2) assert len(net3.asymmetric_load.bus.unique()) == 2 * n_load_busses assert len(net3.asymmetric_sgen.bus.unique()) == 2 * n_sgen_busses
def test_merge_and_split_nets(): net1 = nw.mv_oberrhein() # TODO there are some geodata values in oberrhein without corresponding lines net1.line_geodata.drop(set(net1.line_geodata.index) - set(net1.line.index), inplace=True) n1 = len(net1.bus) pp.runpp(net1) net2 = nw.create_cigre_network_mv() pp.runpp(net2) net = pp.merge_nets(net1, net2) pp.runpp(net) assert np.allclose(net.res_bus.vm_pu.iloc[:n1].values, net1.res_bus.vm_pu.values) assert np.allclose(net.res_bus.vm_pu.iloc[n1:].values, net2.res_bus.vm_pu.values) net3 = pp.select_subnet(net, net.bus.index[:n1], include_results=True) assert pp.dataframes_equal(net3.res_bus[["vm_pu"]], net1.res_bus[["vm_pu"]]) net4 = pp.select_subnet(net, net.bus.index[n1:], include_results=True) assert np.allclose(net4.res_bus.vm_pu.values, net2.res_bus.vm_pu.values)