def add_test_shunt_split(net): b1, b2, ln = add_grid_connection(net, zone="test_shunt_split") pz = 120 qz = -1200 # one shunt at a bus pp.create_shunt(net, b2, p_kw=pz / 2, q_kvar=qz / 2) pp.create_shunt(net, b2, p_kw=pz / 2, q_kvar=qz / 2) return net
def add_test_shunt(net): b1, b2, ln = add_grid_connection(net, zone="test_shunt") pz = 120 qz = -1200 # one shunt at a bus pp.create_shunt(net, b2, p_kw=pz, q_kvar=qz) # add out of service shunt shuold not change the result pp.create_shunt(net, b2, p_kw=pz, q_kvar=qz, in_service=False) return net
def add_test_shunt_split(net): b1, b2, ln = add_grid_connection(net, zone="test_shunt_split") pz = 0.120 qz = -1.200 # one shunt at a bus pp.create_shunt(net, b2, p_mw=pz / 2, q_mvar=qz / 2) pp.create_shunt(net, b2, p_mw=pz / 2, q_mvar=qz / 2) net.last_added_case = "test_shunt_split" return net
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_oos_bus(): net = pp.create_empty_network() add_test_oos_bus_with_is_element(net) assert runpp_with_consistency_checks(net) # test for pq-node result pp.create_shunt(net, 6, q_kvar=-800) assert runpp_with_consistency_checks(net) # 1test for pv-node result pp.create_gen(net, 4, p_kw=-500) assert runpp_with_consistency_checks(net)
def add_test_shunt(net): b1, b2, ln = add_grid_connection(net, zone="test_shunt") pz = 120 qz = -1200 # one shunt at a bus pp.create_shunt_as_condensator(net, b2, q_kvar=1200, loss_factor=0.1, vn_kv=22., step=2) # add out of service shunt shuold not change the result pp.create_shunt(net, b2, p_kw=pz, q_kvar=qz, in_service=False) return net
def net_transformer(): net = pp.create_empty_network(sn_kva=2e3) b1a = pp.create_bus(net, vn_kv=10.) b1b = pp.create_bus(net, vn_kv=10.) b2 = pp.create_bus(net, vn_kv=.4) pp.create_bus(net, vn_kv=0.4, in_service=False) #add out of service bus to test oos indexing pp.create_ext_grid(net, b1a, s_sc_max_mva=100., s_sc_min_mva=40., rx_min=0.1, rx_max=0.1) pp.create_switch(net, b1a, b1b, et="b") pp.create_transformer_from_parameters(net, b1b, b2, vn_hv_kv=11., vn_lv_kv=0.42, vsc_percent=6., vscr_percent=0.5, pfe_kw=1.4, shift_degree=0.0, tp_side="hv", tp_mid=0, tp_min=-2, tp_max=2, tp_pos=2, tp_st_percent=2.5, parallel=2, sn_kva=400, i0_percent=0.5) pp.create_shunt(net, b2, q_kvar=500, p_kw=500) #adding a shunt shouldn't change the result return net
def add_test_shunt(net): b1, b2, ln = add_grid_connection(net, zone="test_shunt") pz = 0.12 qz = -1.2 # one shunt at a bus pp.create_shunt_as_capacitor(net, b2, q_mvar=1.2, loss_factor=0.1, vn_kv=22., step=2) # add out of service shunt shuold not change the result pp.create_shunt(net, b2, p_mw=pz, q_mvar=qz, in_service=False) net.last_added_case = "test_shunt" return net
def test_xward_manually(): net_1 = small_example_grid() # pp.create_xward(net, 2, 0, 0, 0, 0, 0.02, 0.2, 1, slack_weight=2) pp.create_xward(net_1, 2, 200, 20, 10, 1, 0.02, 0.2, 1, slack_weight=2) run_and_assert_numba(net_1) slack_power = (net_1.res_gen.p_mw.at[0] - net_1.gen.p_mw.at[0]) * 3 # factor 3 since gen has # slack_weight==1 and xward has slack_weight==2 # xward behavior is a bit different due to the shunt component of the xward # so we check the results by hand for the case when shunt values are != 0 net = small_example_grid() pp.create_bus(net, 20) pp.create_load(net, 2, 200, 20) pp.create_shunt(net, 2, 1, 10) pp.create_gen(net, 3, 0, 1, slack_weight=2) pp.create_line_from_parameters(net, 2, 3, 1, 0.02, 0.2, 0, 1) net.load.at[1, 'p_mw'] = net_1._ppc['bus'][net_1.xward.bus.at[0], PD] assert np.isclose(200 - net.load.at[1, 'p_mw'], slack_power * 2 / 3, rtol=0, atol=1e-6) pp.runpp(net) assert np.isclose(net_1.res_gen.at[0, 'p_mw'], net.res_gen.at[0, 'p_mw'], rtol=0, atol=1e-6) assert np.isclose(net_1.res_gen.at[0, 'q_mvar'], net.res_gen.at[0, 'q_mvar'], rtol=0, atol=1e-6) assert np.isclose(net_1.res_bus.at[2, 'p_mw'], net.res_bus.at[2, 'p_mw'] + net.res_line.at[3, 'p_from_mw'], rtol=0, atol=1e-6) assert np.allclose(net_1.res_bus.vm_pu, net.res_bus.loc[0:2, 'vm_pu'], rtol=0, atol=1e-6) assert np.allclose(net_1.res_bus.va_degree, net.res_bus.loc[0:2, 'va_degree'], rtol=0, atol=1e-6)
def add_test_oos_bus_with_is_element(net): b1, b2, ln = add_grid_connection(net, zone="test_oos_bus_with_is_element") pl = 1200 ql = 1100 ps = -500 u_set = 1.0 pz = 1200 qz = 1100 qs = 200 vm_pu = 1.06 r_ohm = 50 x_ohm = 70 # OOS buses b3 = pp.create_bus(net, zone="test_oos_bus_with_is_element", vn_kv=0.4, in_service=False) b4 = pp.create_bus(net, zone="test_oos_bus_with_is_element", vn_kv=0.4, in_service=False) b5 = pp.create_bus(net, zone="test_oos_bus_with_is_element", vn_kv=0.4, in_service=False) pp.create_line_from_parameters(net, b2, b3, 12.2, r_ohm_per_km=0.08, x_ohm_per_km=0.12, c_nf_per_km=300, max_i_ka=.2, df=.8) pp.create_line_from_parameters(net, b2, b4, 12.2, r_ohm_per_km=0.08, x_ohm_per_km=0.12, c_nf_per_km=300, max_i_ka=.2, df=.8) pp.create_line_from_parameters(net, b2, b5, 12.2, r_ohm_per_km=0.08, x_ohm_per_km=0.12, c_nf_per_km=300, max_i_ka=.2, df=.8) # in service elements pp.create_load(net, b3, p_kw=pl, q_kvar=ql) pp.create_gen(net, b4, p_kw=ps, vm_pu=u_set) pp.create_sgen(net, b5, p_kw=ps, q_kvar=ql) pp.create_ward(net, b3, pz_kw=pz, qz_kvar=qz, ps_kw=ps, qs_kvar=qs) pp.create_xward(net, b4, pz_kw=0.5 * pz, qz_kvar=0.5 * qz, ps_kw=0.5 * ps, qs_kvar=0.5 * qs, vm_pu=vm_pu, x_ohm=x_ohm, r_ohm=r_ohm) pp.create_shunt(net, b5, q_kvar=-800, p_kw=0) net.last_added_case = "test_oos_bus_with_is_element" return net
def test_continuos_bus_numbering(): net = pp.create_empty_network() bus0 = pp.create_bus(net, 0.4, index=12) pp.create_load(net, bus0, p_mw=0.) pp.create_load(net, bus0, p_mw=0.) pp.create_load(net, bus0, p_mw=0.) pp.create_load(net, bus0, p_mw=0.) bus0 = pp.create_bus(net, 0.4, index=42) pp.create_sgen(net, bus0, p_mw=0.) pp.create_sgen(net, bus0, p_mw=0.) pp.create_sgen(net, bus0, p_mw=0.) bus0 = pp.create_bus(net, 0.4, index=543) pp.create_shunt(net, bus0, 2, 1) pp.create_shunt(net, bus0, 2, 1) pp.create_shunt(net, bus0, 2, 1) bus0 = pp.create_bus(net, 0.4, index=5675) pp.create_ward(net, bus0, 2, 1, 1, 2) pp.create_ward(net, bus0, 2, 1, 1, 2) pp.create_ward(net, bus0, 2, 1, 1, 2) tb.create_continuous_bus_index(net) buses = net.bus.index assert all(buses[i] <= buses[i + 1] for i in range(len(buses) - 1)) # is ordered assert all(buses[i] + 1 == buses[i + 1] for i in range(len(buses) - 1)) # is consecutive assert buses[0] == 0 # starts at zero used_buses = [] for element in net.keys(): try: used_buses.extend(net[element].bus.values) except AttributeError: try: used_buses.extend(net[element].from_bus.values) used_buses.extend(net[element].to_bus.values) except AttributeError: try: used_buses.extend(net[element].hv_bus.values) used_buses.extend(net[element].lv_bus.values) except AttributeError: continue # assert that no buses were used except the ones in net.bus assert set(list(used_buses)) - set(list(net.bus.index.values)) == set()
def case34_3ph(): """ Create the IEEE 34 bus from IEEE PES Test Feeders: "https://site.ieee.org/pes-testfeeders/resources/”. OUTPUT: **net** - The pandapower format network. """ net = pp.create_empty_network() # Linedata # CF-300 line_data = { 'c_nf_per_km': 3.8250977, 'r_ohm_per_km': 0.69599766, 'x_ohm_per_km': 0.5177677, 'c0_nf_per_km': 1.86976748, 'r0_ohm_per_km': 1.08727498, 'x0_ohm_per_km': 1.47374703, 'max_i_ka': 0.23, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-300', element='line') # CF-301 line_data = { 'c_nf_per_km': 3.66884364, 'r_ohm_per_km': 1.05015841, 'x_ohm_per_km': 0.52265586, 'c0_nf_per_km': 1.82231544, 'r0_ohm_per_km': 1.48350255, 'x0_ohm_per_km': 1.60203942, 'max_i_ka': 0.18, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-301', element='line') # CF-302 line_data = { 'c_nf_per_km': 0.8751182, 'r_ohm_per_km': 0.5798427, 'x_ohm_per_km': 0.30768221, 'c0_nf_per_km': 0.8751182, 'r0_ohm_per_km': 0.5798427, 'x0_ohm_per_km': 0.30768221, 'max_i_ka': 0.14, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-302', element='line') # CF-303 line_data = { 'c_nf_per_km': 0.8751182, 'r_ohm_per_km': 0.5798427, 'x_ohm_per_km': 0.30768221, 'c0_nf_per_km': 0.8751182, 'r0_ohm_per_km': 0.5798427, 'x0_ohm_per_km': 0.30768221, 'max_i_ka': 0.14, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-303', element='line') # CF-304 line_data = { 'c_nf_per_km': 0.90382554, 'r_ohm_per_km': 0.39802955, 'x_ohm_per_km': 0.29436416, 'c0_nf_per_km': 0.90382554, 'r0_ohm_per_km': 0.39802955, 'x0_ohm_per_km': 0.29436416, 'max_i_ka': 0.18, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-304', element='line') # Busses bus0 = pp.create_bus(net, name='Bus 0', vn_kv=24.9, type='n', zone='34_BUS') bus_800 = pp.create_bus(net, name='Bus 800', vn_kv=24.9, type='n', zone='34_BUS') bus_802 = pp.create_bus(net, name='Bus 802', vn_kv=24.9, type='n', zone='34_BUS') bus_806 = pp.create_bus(net, name='Bus 806', vn_kv=24.9, type='n', zone='34_BUS') bus_808 = pp.create_bus(net, name='Bus 808', vn_kv=24.9, type='n', zone='34_BUS') bus_810 = pp.create_bus(net, name='Bus 810', vn_kv=24.9, type='n', zone='34_BUS') bus_812 = pp.create_bus(net, name='Bus 812', vn_kv=24.9, type='n', zone='34_BUS') bus_814 = pp.create_bus(net, name='Bus 814', vn_kv=24.9, type='n', zone='34_BUS') bus_850 = pp.create_bus(net, name='Bus 850', vn_kv=24.9, type='n', zone='34_BUS') bus_816 = pp.create_bus(net, name='Bus 816', vn_kv=24.9, type='n', zone='34_BUS') bus_818 = pp.create_bus(net, name='Bus 818', vn_kv=24.9, type='n', zone='34_BUS') bus_820 = pp.create_bus(net, name='Bus 820', vn_kv=24.9, type='n', zone='34_BUS') bus_822 = pp.create_bus(net, name='Bus 822', vn_kv=24.9, type='n', zone='34_BUS') bus_824 = pp.create_bus(net, name='Bus 824', vn_kv=24.9, type='n', zone='34_BUS') bus_826 = pp.create_bus(net, name='Bus 826', vn_kv=24.9, type='n', zone='34_BUS') bus_828 = pp.create_bus(net, name='Bus 828', vn_kv=24.9, type='n', zone='34_BUS') bus_830 = pp.create_bus(net, name='Bus 830', vn_kv=24.9, type='n', zone='34_BUS') bus_854 = pp.create_bus(net, name='Bus 854', vn_kv=24.9, type='n', zone='34_BUS') bus_852 = pp.create_bus(net, name='Bus 852', vn_kv=24.9, type='n', zone='34_BUS') bus_832 = pp.create_bus(net, name='Bus 832', vn_kv=24.9, type='n', zone='34_BUS') bus_858 = pp.create_bus(net, name='Bus 858', vn_kv=24.9, type='n', zone='34_BUS') bus_834 = pp.create_bus(net, name='Bus 834', vn_kv=24.9, type='n', zone='34_BUS') bus_842 = pp.create_bus(net, name='Bus 842', vn_kv=24.9, type='n', zone='34_BUS') bus_844 = pp.create_bus(net, name='Bus 844', vn_kv=24.9, type='n', zone='34_BUS') bus_846 = pp.create_bus(net, name='Bus 846', vn_kv=24.9, type='n', zone='34_BUS') bus_848 = pp.create_bus(net, name='Bus 848', vn_kv=24.9, type='n', zone='34_BUS') bus_860 = pp.create_bus(net, name='Bus 860', vn_kv=24.9, type='n', zone='34_BUS') bus_836 = pp.create_bus(net, name='Bus 836', vn_kv=24.9, type='n', zone='34_BUS') bus_840 = pp.create_bus(net, name='Bus 840', vn_kv=24.9, type='n', zone='34_BUS') bus_862 = pp.create_bus(net, name='Bus 862', vn_kv=24.9, type='n', zone='34_BUS') bus_838 = pp.create_bus(net, name='Bus 838', vn_kv=24.9, type='n', zone='34_BUS') bus_864 = pp.create_bus(net, name='Bus 864', vn_kv=24.9, type='n', zone='34_BUS') bus_888 = pp.create_bus(net, name='Bus 888', vn_kv=4.16, type='n', zone='34_BUS') bus_890 = pp.create_bus(net, name='Bus 890', vn_kv=4.16, type='n', zone='34_BUS') bus_856 = pp.create_bus(net, name='Bus 856', vn_kv=24.9, type='n', zone='34_BUS') # Lines pp.create_line(net, bus_800, bus_802, length_km=0.786384, std_type='CF-300', name='Line 0') pp.create_line(net, bus_802, bus_806, length_km=0.527304, std_type='CF-300', name='Line 1') pp.create_line(net, bus_806, bus_808, length_km=9.823704, std_type='CF-300', name='Line 2') pp.create_line(net, bus_808, bus_810, length_km=1.769059, std_type='CF-303', name='Line 3') pp.create_line(net, bus_808, bus_812, length_km=11.43000, std_type='CF-300', name='Line 4') pp.create_line(net, bus_812, bus_814, length_km=9.061704, std_type='CF-300', name='Line 5') # pp.create_line(net, bus_814, bus_850, length_km=0.003048, std_type='CF-301', # name='Line 6') pp.create_line(net, bus_816, bus_818, length_km=0.521208, std_type='CF-302', name='Line 7') pp.create_line(net, bus_816, bus_824, length_km=3.112008, std_type='CF-301', name='Line 8') pp.create_line(net, bus_818, bus_820, length_km=14.67612, std_type='CF-302', name='Line 9') pp.create_line(net, bus_820, bus_822, length_km=4.187952, std_type='CF-302', name='Line 10') pp.create_line(net, bus_824, bus_826, length_km=0.923544, std_type='CF-303', name='Line 11') pp.create_line(net, bus_824, bus_828, length_km=0.256032, std_type='CF-301', name='Line 12') pp.create_line(net, bus_828, bus_830, length_km=6.230112, std_type='CF-301', name='Line 13') pp.create_line(net, bus_830, bus_854, length_km=0.158496, std_type='CF-301', name='Line 14') pp.create_line(net, bus_832, bus_858, length_km=1.493520, std_type='CF-301', name='Line 15') pp.create_line(net, bus_834, bus_860, length_km=0.615696, std_type='CF-301', name='Line 16') pp.create_line(net, bus_834, bus_842, length_km=0.085344, std_type='CF-301', name='Line 17') pp.create_line(net, bus_836, bus_840, length_km=0.262128, std_type='CF-301', name='Line 18') pp.create_line(net, bus_836, bus_862, length_km=0.085344, std_type='CF-301', name='Line 19') pp.create_line(net, bus_842, bus_844, length_km=0.411480, std_type='CF-301', name='Line 20') pp.create_line(net, bus_844, bus_846, length_km=1.109472, std_type='CF-301', name='Line 21') pp.create_line(net, bus_846, bus_848, length_km=0.161544, std_type='CF-301', name='Line 22') pp.create_line(net, bus_850, bus_816, length_km=0.094488, std_type='CF-301', name='Line 23') # pp.create_line(net, bus_852, bus_832, length_km=0.003048, std_type='CF-301', # name='Line 24') pp.create_line(net, bus_854, bus_856, length_km=7.110984, std_type='CF-303', name='Line 25') pp.create_line(net, bus_854, bus_852, length_km=11.22578, std_type='CF-301', name='Line 26') pp.create_line(net, bus_858, bus_864, length_km=0.493776, std_type='CF-302', name='Line 27') pp.create_line(net, bus_858, bus_834, length_km=1.776984, std_type='CF-301', name='Line 28') pp.create_line(net, bus_860, bus_836, length_km=0.816864, std_type='CF-301', name='Line 29') pp.create_line(net, bus_860, bus_838, length_km=1.481328, std_type='CF-304', name='Line 30') pp.create_line(net, bus_888, bus_890, length_km=3.218688, std_type='CF-300', name='Line 31') # Substation pp.create_transformer_from_parameters(net, bus0, bus_800, sn_mva=2.5, vn_hv_kv=24.9, vn_lv_kv=24.9, vkr_percent=1.0, vk_percent=8.062257, pfe_kw=0.0, i0_percent=0.0, shift_degree=0.0, vkr0_percent=1.0, vk0_percent=8.062257, vector_group='YNyn', mag0_percent=100.0, mag0_rx=0, si0_hv_partial=0.9, tap_side='lv', tap_neutral=0, tap_max=2, tap_min=-2, tap_step_percent=2.5, tap_pos=-2, name='Substation') # Regulator 1 pp.create_transformer_from_parameters(net, bus_814, bus_850, sn_mva=1, vn_hv_kv=24.9, vn_lv_kv=24.9, vkr_percent=0.320088, vk_percent=0.357539, pfe_kw=0.0, i0_percent=0.0, shift_degree=0.0, vkr0_percent=0.452171, vk0_percent=0.665505, vector_group='YNyn', mag0_percent=100.0, mag0_rx=0, si0_hv_partial=0.9, tap_side='lv', tap_neutral=0, tap_max=16, tap_min=-16, tap_step_percent=0.625, tap_pos=0, tap_phase_shifter=False, name='Regulator 1') # Regulator 2 pp.create_transformer_from_parameters(net, bus_852, bus_832, sn_mva=1, vn_hv_kv=24.9, vn_lv_kv=24.9, vkr_percent=0.320088, vk_percent=0.357539, pfe_kw=0.0, i0_percent=0.0, shift_degree=0.0, vkr0_percent=0.452171, vk0_percent=0.665505, vector_group='YNyn', mag0_percent=100.0, mag0_rx=0, si0_hv_partial=0.9, tap_side='lv', tap_neutral=0, tap_max=16, tap_min=-16, tap_step_percent=0.625, tap_pos=0, tap_phase_shifter=False, name='Regulator 2') # Traformer pp.create_transformer_from_parameters(net, bus_832, bus_888, sn_mva=0.5, vn_hv_kv=24.9, vn_lv_kv=4.16, vkr_percent=1.9, vk_percent=4.5, pfe_kw=0.0, i0_percent=0.0, shift_degree=0.0, vkr0_percent=1.9, vk0_percent=4.5, vector_group='YNyn', mag0_percent=100.0, mag0_rx=0, si0_hv_partial=0.9, name='Traformer') # Loads pp.create_asymmetric_load(net, bus_806, p_a_mw=0, p_b_mw=0.03, p_c_mw=0.025, q_a_mvar=0, q_b_mvar=0.015, q_c_mvar=0.014, name='Load 806', type='wye') pp.create_asymmetric_load(net, bus_810, p_a_mw=0, p_b_mw=0.016, p_c_mw=0, q_a_mvar=0, q_b_mvar=0.008, q_c_mvar=0, name='Load 810', type='wye') pp.create_asymmetric_load(net, bus_820, p_a_mw=0.034, p_b_mw=0, p_c_mw=0, q_a_mvar=0.017, q_b_mvar=0, q_c_mvar=0, name='Load 820', type='wye') pp.create_asymmetric_load(net, bus_822, p_a_mw=0.135, p_b_mw=0, p_c_mw=0, q_a_mvar=0.07, q_b_mvar=0, q_c_mvar=0, name='Load 822', type='wye') pp.create_asymmetric_load(net, bus_824, p_a_mw=0, p_b_mw=0.005, p_c_mw=0, q_a_mvar=0, q_b_mvar=0.002, q_c_mvar=0, name='Load 824', type='delta') pp.create_asymmetric_load(net, bus_826, p_a_mw=0, p_b_mw=0.04, p_c_mw=0, q_a_mvar=0, q_b_mvar=0.02, q_c_mvar=0, name='Load 826', type='wye') pp.create_asymmetric_load(net, bus_828, p_a_mw=0, p_b_mw=0, p_c_mw=0.004, q_a_mvar=0, q_b_mvar=0, q_c_mvar=0.002, name='Load 828', type='wye') pp.create_asymmetric_load(net, bus_830, p_a_mw=0.007, p_b_mw=0, p_c_mw=0, q_a_mvar=0.003, q_b_mvar=0, q_c_mvar=0, name='Load 830', type='wye') pp.create_asymmetric_load(net, bus_856, p_a_mw=0, p_b_mw=0.004, p_c_mw=0, q_a_mvar=0, q_b_mvar=0.002, q_c_mvar=0, name='Load 856', type='wye') pp.create_asymmetric_load(net, bus_858, p_a_mw=0.007, p_b_mw=0.002, p_c_mw=0.006, q_a_mvar=0.003, q_b_mvar=0.001, q_c_mvar=0.003, name='Load 858', type='delta') pp.create_asymmetric_load(net, bus_864, p_a_mw=0.002, p_b_mw=0, p_c_mw=0, q_a_mvar=0.001, q_b_mvar=0, q_c_mvar=0, name='Load 864', type='wye') pp.create_asymmetric_load(net, bus_834, p_a_mw=0.004, p_b_mw=0.015, p_c_mw=0.013, q_a_mvar=0.002, q_b_mvar=0.008, q_c_mvar=0.007, name='Load 834', type='delta') pp.create_asymmetric_load(net, bus_860, p_a_mw=0.016, p_b_mw=0.02, p_c_mw=0.11, q_a_mvar=0.008, q_b_mvar=0.01, q_c_mvar=0.055, name='Load 860', type='delta') pp.create_asymmetric_load(net, bus_836, p_a_mw=0.03, p_b_mw=0.01, p_c_mw=0.042, q_a_mvar=0.015, q_b_mvar=0.006, q_c_mvar=0.022, name='Load 836', type='delta') pp.create_asymmetric_load(net, bus_840, p_a_mw=0.018, p_b_mw=0.022, p_c_mw=0, q_a_mvar=0.009, q_b_mvar=0.011, q_c_mvar=0, name='Load 840', type='delta') pp.create_asymmetric_load(net, bus_838, p_a_mw=0, p_b_mw=0.028, p_c_mw=0, q_a_mvar=0, q_b_mvar=0.014, q_c_mvar=0, name='Load 838', type='wye') pp.create_asymmetric_load(net, bus_844, p_a_mw=0.009, p_b_mw=0, p_c_mw=0, q_a_mvar=0.005, q_b_mvar=0, q_c_mvar=0, name='Load 844', type='wye') pp.create_asymmetric_load(net, bus_846, p_a_mw=0, p_b_mw=0.025, p_c_mw=0.012, q_a_mvar=0, q_b_mvar=0.02, q_c_mvar=0.011, name='Load 846', type='wye') pp.create_asymmetric_load(net, bus_848, p_a_mw=0, p_b_mw=0.023, p_c_mw=0, q_a_mvar=0, q_b_mvar=0.011, q_c_mvar=0, name='Load 848', type='wye') pp.create_asymmetric_load(net, bus_860, p_a_mw=0.02, p_b_mw=0.02, p_c_mw=0.02, q_a_mvar=0.016, q_b_mvar=0.016, q_c_mvar=0.016, name='Load 860 spot', type='wye') pp.create_asymmetric_load(net, bus_840, p_a_mw=0.009, p_b_mw=0.009, p_c_mw=0.009, q_a_mvar=0.007, q_b_mvar=0.007, q_c_mvar=0.007, name='Load 840 spot', type='wye') pp.create_asymmetric_load(net, bus_844, p_a_mw=0.135, p_b_mw=0.135, p_c_mw=0.135, q_a_mvar=0.105, q_b_mvar=0.105, q_c_mvar=0.105, name='Load 844 spot', type='wye') pp.create_asymmetric_load(net, bus_848, p_a_mw=0.02, p_b_mw=0.02, p_c_mw=0.02, q_a_mvar=0.016, q_b_mvar=0.016, q_c_mvar=0.016, name='Load 848 spot', type='delta') pp.create_asymmetric_load(net, bus_890, p_a_mw=0.15, p_b_mw=0.15, p_c_mw=0.15, q_a_mvar=0.075, q_b_mvar=0.075, q_c_mvar=0.075, name='Load 890 spot', type='delta') pp.create_asymmetric_load(net, bus_830, p_a_mw=0.01, p_b_mw=0.01, p_c_mw=0.025, q_a_mvar=0.005, q_b_mvar=0.005, q_c_mvar=0.01, name='Load 830 spot', type='delta') # External grid pp.create_ext_grid(net, bus0, vm_pu=1.0, va_degree=0.0, s_sc_max_mva=10.0, s_sc_min_mva=10.0, rx_max=1, rx_min=1, r0x0_max=1, x0x_max=1) # Distributed generators pp.create_sgen(net, bus_848, p_mw=0.66, q_mvar=0.500, name='DG 1', max_p_mw=0.66, min_p_mw=0, max_q_mvar=0.5, min_q_mvar=0) pp.create_sgen(net, bus_890, p_mw=0.50, q_mvar=0.375, name='DG 2', max_p_mw=0.50, min_p_mw=0, max_q_mvar=0.375, min_q_mvar=0) pp.create_sgen(net, bus_822, p_mw=0.2, type='PV', name='PV 1', max_p_mw=0.2, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_856, p_mw=0.2, type='PV', name='PV 2', max_p_mw=0.2, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_838, p_mw=0.2, type='PV', name='PV 3', max_p_mw=0.2, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_822, p_mw=0.3, type='WP', name='WP 1', max_p_mw=0.3, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_826, p_mw=0.3, type='WP', name='WP 2', max_p_mw=0.3, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_838, p_mw=0.3, type='WP', name='WP 3', max_p_mw=0.3, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) # Shunt capacity bank pp.create_shunt(net, bus_840, q_mvar=-0.12, name='SCB 1', step=4, max_step=4) pp.create_shunt(net, bus_864, q_mvar=-0.12, name='SCB 2', step=4, max_step=4) # storage pp.create_storage(net, bus_810, p_mw=0.2, max_e_mwh=1.0, sn_mva=1.0, soc_percent=50, min_e_mwh=0.2, name='Storage') pp.add_zero_impedance_parameters(net) return net # net = case34_3ph() # pp.pf.runpp_3ph.runpp_3ph(net) # print(net.res_bus_3ph) # print(net.sn_mva)
def example_multivoltage(): """ Returns the multivoltage example network from the pandapower tutorials. OUTPUT: net - multivoltage example network EXAMPLE: >>> import pandapower.networks >>> net = pandapower.networks.example_multivoltage() """ net = pp.create_empty_network() # --- Busses # HV # Double busbar pp.create_bus(net, name='Double Busbar 1', vn_kv=380, type='b') pp.create_bus(net, name='Double Busbar 2', vn_kv=380, type='b') for i in range(10): pp.create_bus(net, name='Bus DB T%s' % i, vn_kv=380, type='n') for i in range(1, 5): pp.create_bus(net, name='Bus DB %s' % i, vn_kv=380, type='n') # Single busbar pp.create_bus(net, name='Single Busbar', vn_kv=110, type='b') for i in range(1, 6): pp.create_bus(net, name='Bus SB %s' % i, vn_kv=110, type='n') for i in range(1, 6): for j in [1, 2]: pp.create_bus(net, name='Bus SB T%s.%s' % (i, j), vn_kv=110, type='n') # Remaining for i in range(1, 5): pp.create_bus(net, name='Bus HV%s' % i, vn_kv=110, type='n') # MV pp.create_bus(net, name='Bus MV0 20kV', vn_kv=20, type='n') for i in range(8): pp.create_bus(net, name='Bus MV%s' % i, vn_kv=10, type='n') # LV pp.create_bus(net, name='Bus LV0', vn_kv=0.4, type='n') for i in range(1, 6): pp.create_bus(net, name='Bus LV1.%s' % i, vn_kv=0.4, type='m') for i in range(1, 5): pp.create_bus(net, name='Bus LV2.%s' % i, vn_kv=0.4, type='m') pp.create_bus(net, name='Bus LV2.2.1', vn_kv=0.4, type='m') pp.create_bus(net, name='Bus LV2.2.2', vn_kv=0.4, type='m') # --- Lines # HV hv_lines = pd.DataFrame() hv_lines['line_name'] = ['HV Line%s' % i for i in range(1, 7)] hv_lines['from_bus'] = [ 'Bus SB 2', 'Bus HV1', 'Bus HV2', 'Bus HV1', 'Bus HV3', 'Bus SB 3' ] hv_lines['to_bus'] = [ 'Bus HV1', 'Bus HV2', 'Bus HV4', 'Bus HV4', 'Bus HV4', 'Bus HV3' ] hv_lines['std_type'] = '184-AL1/30-ST1A 110.0' hv_lines['length'] = [30, 20, 30, 15, 25, 30] hv_lines['parallel'] = [1, 1, 1, 1, 1, 2] for _, hv_line in hv_lines.iterrows(): from_bus = pp.get_element_index(net, "bus", hv_line.from_bus) to_bus = pp.get_element_index(net, "bus", hv_line.to_bus) pp.create_line(net, from_bus, to_bus, length_km=hv_line.length, std_type=hv_line.std_type, name=hv_line.line_name, parallel=hv_line.parallel) # MV mv_lines = pd.DataFrame() mv_lines['line_name'] = ['MV Line%s' % i for i in range(1, 9)] mv_lines['from_bus'] = ['Bus MV%s' % i for i in list(range(7)) + [0]] mv_lines['to_bus'] = ['Bus MV%s' % i for i in list(range(1, 8)) + [7]] mv_lines['length'] = 1.5 mv_lines['std_type'] = 'NA2XS2Y 1x185 RM/25 12/20 kV' for _, mv_line in mv_lines.iterrows(): from_bus = pp.get_element_index(net, "bus", mv_line.from_bus) to_bus = pp.get_element_index(net, "bus", mv_line.to_bus) pp.create_line(net, from_bus, to_bus, length_km=mv_line.length, std_type=mv_line.std_type, name=mv_line.line_name) # LV lv_lines = pd.DataFrame() lv_line_idx = [ '1.1', '1.2', '1.3', '1.4', '1.6', '2.1', '2.2', '2.3', '2.4', '2.2.1', '2.2.2' ] lv_lines['line_name'] = ['LV Line%s' % i for i in lv_line_idx] lv_line_idx = [ '0', '1.1', '1.2', '1.3', '1.4', '0', '2.1', '2.2', '2.3', '2.2', '2.2.1' ] lv_lines['from_bus'] = ['Bus LV%s' % i for i in lv_line_idx] lv_line_idx = [ '1.1', '1.2', '1.3', '1.4', '1.5', '2.1', '2.2', '2.3', '2.4', '2.2.1', '2.2.2' ] lv_lines['to_bus'] = ['Bus LV%s' % i for i in lv_line_idx] lv_lines['length'] = [0.08] * 5 + [0.12] * 6 lv_lines['std_type'] = ['NAYY 4x120 SE'] * 7 + ['15-AL1/3-ST1A 0.4'] * 4 for _, lv_line in lv_lines.iterrows(): from_bus = pp.get_element_index(net, "bus", lv_line.from_bus) to_bus = pp.get_element_index(net, "bus", lv_line.to_bus) pp.create_line(net, from_bus, to_bus, length_km=lv_line.length, std_type=lv_line.std_type, name=lv_line.line_name) # --- Transformer hv_bus = pp.get_element_index(net, "bus", "Bus DB 2") lv_bus = pp.get_element_index(net, "bus", "Bus SB 1") pp.create_transformer_from_parameters(net, hv_bus, lv_bus, sn_kva=300000, vn_hv_kv=380, vn_lv_kv=110, vscr_percent=0.06, vsc_percent=8, pfe_kw=0, i0_percent=0, tp_pos=0, shift_degree=0, name='EHV-HV-Trafo') hv_bus = pp.get_element_index(net, "bus", "Bus MV4") lv_bus = pp.get_element_index(net, "bus", "Bus LV0") pp.create_transformer_from_parameters(net, hv_bus, lv_bus, sn_kva=400, vn_hv_kv=10, vn_lv_kv=0.4, vscr_percent=1.325, vsc_percent=4, pfe_kw=0.95, i0_percent=0.2375, tp_side="hv", tp_mid=0, tp_min=-2, tp_max=2, tp_st_percent=2.5, tp_pos=0, shift_degree=150, name='MV-LV-Trafo') # Trafo3w hv_bus = pp.get_element_index(net, "bus", "Bus HV2") mv_bus = pp.get_element_index(net, "bus", "Bus MV0 20kV") lv_bus = pp.get_element_index(net, "bus", "Bus MV0") pp.create_transformer3w_from_parameters(net, hv_bus, mv_bus, lv_bus, vn_hv_kv=110, vn_mv_kv=20, vn_lv_kv=10, sn_hv_kva=40000, sn_mv_kva=15000, sn_lv_kva=25000, vsc_hv_percent=10.1, vsc_mv_percent=10.1, vsc_lv_percent=10.1, vscr_hv_percent=0.266667, vscr_mv_percent=0.033333, vscr_lv_percent=0.04, pfe_kw=0, i0_percent=0, shift_mv_degree=30, shift_lv_degree=30, tp_side="hv", tp_mid=0, tp_min=-8, tp_max=8, tp_st_percent=1.25, tp_pos=0, name='HV-MV-MV-Trafo') # --- Static generators # HV pp.create_sgen(net, pp.get_element_index(net, "bus", 'Bus SB 5'), p_kw=-20000, q_kvar=-4000, sn_kva=45000, type='WP', name='Wind Park') # MV mv_sgens = pd.DataFrame() mv_sgens['sgen_name'] = [ 'Biogas plant', 'Further MV Generator', 'Industry Generator', 'PV Park' ] mv_sgens['bus'] = ['Bus MV6', 'Bus MV0', 'Bus MV0 20kV', 'Bus MV5'] mv_sgens['p'] = [-500, -500, -15000, -2000] mv_sgens['q'] = [0, -50, -3000, -100] mv_sgens['sn'] = [750, 1000, 20000, 5000] mv_sgens['type'] = ['SGEN', 'SGEN', 'SGEN', 'PV'] for _, sgen in mv_sgens.iterrows(): bus_idx = pp.get_element_index(net, "bus", sgen.bus) pp.create_sgen(net, bus_idx, p_kw=sgen.p, q_kvar=sgen.q, sn_kva=sgen.sn, type=sgen.type, name=sgen.sgen_name) # LV lv_sgens = pd.DataFrame() lv_sgens['sgen_name'] = ['PV'] + ['PV(%s)' % i for i in range(1, 6)] lv_sgens['bus'] = [ 'Bus LV%s' % i for i in ['1.1', '1.3', '2.3', '2.4', '2.2.1', '2.2.2'] ] lv_sgens['p'] = [-6, -5, -5, -5, -5, -5] lv_sgens['q'] = 0 lv_sgens['sn'] = [12, 10, 10, 10, 10, 10] lv_sgens['type'] = 'PV' for _, sgen in lv_sgens.iterrows(): bus_idx = pp.get_element_index(net, "bus", sgen.bus) pp.create_sgen(net, bus_idx, p_kw=sgen.p, q_kvar=sgen.q, sn_kva=sgen.sn, type=sgen.type, name=sgen.sgen_name) # --- Loads # HV hv_loads = pd.DataFrame() hv_loads['load_name'] = ['MV Net %s' % i for i in range(5)] hv_loads['bus'] = ['Bus SB 4', 'Bus HV1', 'Bus HV2', 'Bus HV3', 'Bus HV4'] hv_loads['p'] = 38000 hv_loads['q'] = 6000 for _, load in hv_loads.iterrows(): bus_idx = pp.get_element_index(net, "bus", load.bus) pp.create_load(net, bus_idx, p_kw=load.p, q_kvar=load.q, name=load.load_name) # MV mv_loads = pd.DataFrame() mv_loads['load_name'] = ['Further MV-Rings', 'Industry Load' ] + ['LV Net %s' % i for i in [1, 2, 3, 5, 6, 7]] mv_loads['bus'] = ['Bus MV0', 'Bus MV0 20kV' ] + ['Bus MV%s' % i for i in [1, 2, 3, 5, 6, 7]] mv_loads['p'] = [6000, 18000, 400, 400, 400, 400, 400, 400] mv_loads['q'] = [2000, 4000, 100, 60, 60, 60, 60, 60] for _, load in mv_loads.iterrows(): bus_idx = pp.get_element_index(net, "bus", load.bus) pp.create_load(net, bus_idx, p_kw=load.p, q_kvar=load.q, name=load.load_name) # LV lv_loads = pd.DataFrame() idx = ['', '(1)', '(2)', '(3)', '(4)', '(5)'] lv_loads['load_name'] = ['Further LV-Feeders Load'] + [ 'Residential Load%s' % i for i in idx[0:5] ] + ['Rural Load%s' % i for i in idx[0:6]] lv_loads['bus'] = [ 'Bus LV%s' % i for i in [ '0', '1.1', '1.2', '1.3', '1.4', '1.5', '2.1', '2.2', '2.3', '2.4', '2.2.1', '2.2.2' ] ] lv_loads['p'] = [100] + [10] * 11 lv_loads['q'] = [10] + [3] * 11 for _, load in lv_loads.iterrows(): bus_idx = pp.get_element_index(net, "bus", load.bus) pp.create_load(net, bus_idx, p_kw=load.p, q_kvar=load.q, name=load.load_name) # --- Other # Shunt pp.create_shunt(net, pp.get_element_index(net, "bus", 'Bus HV1'), p_kw=0, q_kvar=-960, name='Shunt') # ExtGrids pp.create_ext_grid(net, pp.get_element_index(net, "bus", 'Double Busbar 1'), vm_pu=1.03, va_degree=0, name='External grid', s_sc_max_mva=10000, rx_max=0.1, rx_min=0.1) # Gen pp.create_gen(net, pp.get_element_index(net, "bus", 'Bus HV4'), vm_pu=1.03, p_kw=-1e5, name='Gas turbine') # Impedance pp.create_impedance(net, pp.get_element_index(net, "bus", 'Bus HV3'), pp.get_element_index(net, "bus", 'Bus HV1'), rft_pu=0.074873, xft_pu=0.198872, sn_kva=100000, name='Impedance') # xwards pp.create_xward(net, pp.get_element_index(net, "bus", 'Bus HV3'), ps_kw=23942, qs_kvar=-12241.87, pz_kw=2814.571, qz_kvar=0, r_ohm=0, x_ohm=12.18951, vm_pu=1.02616, name='XWard 1') pp.create_xward(net, pp.get_element_index(net, "bus", 'Bus HV1'), ps_kw=3776, qs_kvar=-7769.979, pz_kw=9174.917, qz_kvar=0, r_ohm=0, x_ohm=50.56217, vm_pu=1.024001, name='XWard 2') # --- Switches # HV # Bus-bus switches hv_bus_sw = pd.DataFrame() hv_bus_sw['bus_name'] = ['DB DS%s' % i for i in range(14)] + \ ['DB CB%s' % i for i in range(5)] + \ ['SB DS%s.%s' % (i, j) for i in range(1, 6) for j in range(1, 3)] + \ ['SB CB%s' % i for i in range(1, 6)] hv_bus_sw['from_bus'] = ['Double Busbar %s' % i for i in [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]] + \ ['Bus DB T%s' % i for i in [2, 4, 6, 8, 0, 3, 5, 7, 9]] + \ ['Bus SB T1.1', 'Single Busbar', 'Bus SB T2.1', 'Single Busbar', 'Bus SB T3.1', 'Single Busbar', 'Bus SB T4.1', 'Single Busbar', 'Bus SB T5.1', 'Single Busbar'] + \ ['Bus SB T%s.2' % i for i in range(1, 6)] hv_bus_sw['to_bus'] = ['Bus DB %s' % i for i in ['T0', 'T1', 'T3', 'T3', 'T5', 'T5', 'T7', 'T7', 'T9', 'T9', '1', '2', '3', '4', 'T1', 'T2', 'T4', 'T6', 'T8']] + \ ['Bus SB %s' % i for i in ['1', 'T1.2', '2', 'T2.2', '3', 'T3.2', '4', 'T4.2', '5', 'T5.2']] + \ ['Bus SB T%s.1' % i for i in range(1, 6)] hv_bus_sw['type'] = ['DS'] * 14 + ['CB'] * 5 + ['DS'] * 10 + ['CB'] * 5 hv_bus_sw['et'] = 'b' hv_bus_sw['closed'] = [ bool(i) for i in [1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1] + [1] * 15 ] for _, switch in hv_bus_sw.iterrows(): from_bus = pp.get_element_index(net, "bus", switch.from_bus) to_bus = pp.get_element_index(net, "bus", switch.to_bus) pp.create_switch(net, from_bus, to_bus, et=switch.et, closed=switch.closed, type=switch.type, name=switch.bus_name) # Bus-Line switches hv_buses = net.bus[(net.bus.vn_kv == 380) | (net.bus.vn_kv == 110)].index hv_ls = net.line[(net.line.from_bus.isin(hv_buses)) & (net.line.to_bus.isin(hv_buses))] for _, line in hv_ls.iterrows(): for bus in [line.from_bus, line.to_bus]: pp.create_switch(net, bus, line.name, et='l', closed=True, type='LBS', name='Switch %s - %s' % (net.bus.name.at[bus], line['name'])) # MV # Bus-line switches mv_buses = net.bus[(net.bus.vn_kv == 10) | (net.bus.vn_kv == 20)].index mv_ls = net.line[(net.line.from_bus.isin(mv_buses)) & (net.line.to_bus.isin(mv_buses))] for _, line in mv_ls.iterrows(): for bus in [line.from_bus, line.to_bus]: pp.create_switch(net, bus, line.name, et='l', closed=True, type='LBS', name='Switch %s - %s' % (net.bus.name.at[bus], line['name'])) open_switch_id = net.switch[( net.switch.name == 'Switch Bus MV5 - MV Line5')].index net.switch.closed.loc[open_switch_id] = False # LV # Bus-line switches lv_buses = net.bus[net.bus.vn_kv == 0.4].index lv_ls = net.line[(net.line.from_bus.isin(lv_buses)) & (net.line.to_bus.isin(lv_buses))] for _, line in lv_ls.iterrows(): for bus in [line.from_bus, line.to_bus]: pp.create_switch(net, bus, line.name, et='l', closed=True, type='LBS', name='Switch %s - %s' % (net.bus.name.at[bus], line['name'])) # Trafoswitches # HV pp.create_switch(net, pp.get_element_index(net, "bus", 'Bus DB 2'), pp.get_element_index(net, "trafo", 'EHV-HV-Trafo'), et='t', closed=True, type='LBS', name='Switch DB2 - EHV-HV-Trafo') pp.create_switch(net, pp.get_element_index(net, "bus", 'Bus SB 1'), pp.get_element_index(net, "trafo", 'EHV-HV-Trafo'), et='t', closed=True, type='LBS', name='Switch SB1 - EHV-HV-Trafo') # LV pp.create_switch(net, pp.get_element_index(net, "bus", 'Bus MV4'), pp.get_element_index(net, "trafo", 'MV-LV-Trafo'), et='t', closed=True, type='LBS', name='Switch MV4 - MV-LV-Trafo') pp.create_switch(net, pp.get_element_index(net, "bus", 'Bus LV0'), pp.get_element_index(net, "trafo", 'MV-LV-Trafo'), et='t', closed=True, type='LBS', name='Switch LV0 - MV-LV-Trafo') # --- Powerflow # run power flow and generate result tables pp.runpp(net, init='dc', calculate_voltage_angles=True, Numba=False) return net
def test_pm_dc_powerflow_shunt(): net = nw.simple_four_bus_system() pp.create_shunt(net, 2, q_mvar=-0.5) net.trafo.loc[0, "shift_degree"] = 0. assert_pf(net, dc=True)
pp.create_shunt(net, b2, p_kw=pz / 2, q_kvar=qz / 2) return net def add_test_two_open_switches_on_deactive_line(net): b1, b2, l1 = add_grid_connection(net, zone="two_open_switches_on_deactive_line") b3 = pp.create_bus(net, vn_kv=20.) l2 = create_test_line(net, b2, b3, in_service=False) create_test_line(net, b3, b1) pp.create_switch(net, b2, l2, et="l", closed=False) pp.create_switch(net, b3, l2, et="l", closed=False) return net if __name__ == '__main__': net = pp.create_empty_network() b1, b2, ln = add_grid_connection(net, zone="test_shunt") pz = 120 qz = -1200 # one shunt at a bus pp.create_shunt_as_condensator(net, b2, q_kvar=1200, loss_factor=0.1, vn_kv=20., step=1) # add out of service shunt shuold not change the result pp.create_shunt(net, b2, p_kw=pz, q_kvar=qz, in_service=False) # add out of service shunt shuold not change the result pp.runpp(net)
def example_simple(): """ Returns the simple example network from the pandapower tutorials. OUTPUT: net - simple example network EXAMPLE: >>> import pandapower.networks >>> net = pandapower.networks.example_simple() """ net = pp.create_empty_network() # create buses bus1 = pp.create_bus(net, name="HV Busbar", vn_kv=110., type="b") bus2 = pp.create_bus(net, name="HV Busbar 2", vn_kv=110., type="b") bus3 = pp.create_bus(net, name="HV Transformer Bus", vn_kv=110., type="n") bus4 = pp.create_bus(net, name="MV Transformer Bus", vn_kv=20., type="n") bus5 = pp.create_bus(net, name="MV Main Bus", vn_kv=20., type="b") bus6 = pp.create_bus(net, name="MV Bus 1", vn_kv=20., type="b") bus7 = pp.create_bus(net, name="MV Bus 2", vn_kv=20., type="b") # create external grid pp.create_ext_grid(net, bus1, vm_pu=1.02, va_degree=50) # create transformer trafo1 = pp.create_transformer(net, bus3, bus4, name="110kV/20kV transformer", std_type="25 MVA 110/20 kV") # create lines line1 = pp.create_line(net, bus1, bus2, length_km=10, std_type="N2XS(FL)2Y 1x300 RM/35 64/110 kV", name="Line 1") line2 = pp.create_line(net, bus5, bus6, length_km=2.0, std_type="NA2XS2Y 1x240 RM/25 12/20 kV", name="Line 2") line3 = pp.create_line(net, bus6, bus7, length_km=3.5, std_type="48-AL1/8-ST1A 20.0", name="Line 3") line4 = pp.create_line(net, bus7, bus5, length_km=2.5, std_type="NA2XS2Y 1x240 RM/25 12/20 kV", name="Line 4") # create bus-bus switches sw1 = pp.create_switch(net, bus2, bus3, et="b", type="CB") sw2 = pp.create_switch(net, bus4, bus5, et="b", type="CB") # create bus-line switches sw3 = pp.create_switch(net, bus5, line2, et="l", type="LBS", closed=True) sw4 = pp.create_switch(net, bus6, line2, et="l", type="LBS", closed=True) sw5 = pp.create_switch(net, bus6, line3, et="l", type="LBS", closed=True) sw6 = pp.create_switch(net, bus7, line3, et="l", type="LBS", closed=False) sw7 = pp.create_switch(net, bus7, line4, et="l", type="LBS", closed=True) sw8 = pp.create_switch(net, bus5, line4, et="l", type="LBS", closed=True) # create load pp.create_load(net, bus7, p_kw=2000, q_kvar=4000, scaling=0.6, name="load") # create generator pp.create_gen(net, bus6, p_kw=-6000, max_q_kvar=3000, min_q_kvar=-3000, vm_pu=1.03, name="generator") # create static generator pp.create_sgen(net, bus7, p_kw=-2000, q_kvar=500, name="static generator") # create shunt pp.create_shunt(net, bus3, q_kvar=-960, p_kw=0, name='Shunt') return net
def build_pandapower(self, ac_line_segment_list_topology, busbar_section_list_topology, power_transformer_list_topology, synchronous_machine_list_topology, shunt_compensator_list_topology, energy_consumer_list_topology, breaker_list_topology): # Create buses in pandapower network from the internal data structure for bb_top in busbar_section_list_topology: pp.create_bus(self.net, bb_top.u_nom_kv, name=bb_top.name) # Create lines in pandapower network from the internal data structure for al_top in ac_line_segment_list_topology: for bb_top in busbar_section_list_topology: if bb_top.id_ == al_top.bus_1_id: from_bus = pp.get_element_index(self.net, 'bus', bb_top.name) if bb_top.id_ == al_top.bus_2_id: to_bus = pp.get_element_index(self.net, 'bus', bb_top.name) pp.create_line_from_parameters(self.net, from_bus, to_bus, al_top.length_km, al_top.r_ohm, al_top.x_ohm, 0.0, al_top.i_max_ka, name=al_top.name) # Create transformers in pandapower network from the internal data structure for tr_top in power_transformer_list_topology: for bb_top in busbar_section_list_topology: if bb_top.id_ == tr_top.bus_hv_id: hv_bus = pp.get_element_index(self.net, 'bus', bb_top.name) for bb_top in busbar_section_list_topology: if bb_top.id_ == tr_top.bus_lv_id: lv_bus = pp.get_element_index(self.net, 'bus', bb_top.name) # From the transformer documentation power_transformer_z = (tr_top.r**2 + tr_top.x**2)**0.5 power_transformer_vsc = 100 * power_transformer_z * tr_top.s_nom_mva power_transformer_vscr = 100 * tr_top.r * tr_top.s_nom_mva # Neglect the iron losses if ('hv_bus' or 'lv_bus') in locals(): pp.create_transformer_from_parameters(self.net, hv_bus, lv_bus, tr_top.s_nom_mva, tr_top.hv_nom_kv, tr_top.lv_nom_kv, power_transformer_vscr, power_transformer_vsc, 0, 0, name=tr_top.name) del hv_bus del lv_bus # Create generators in pandapower network from the internal data structure for sm_top in synchronous_machine_list_topology: for bb_top in busbar_section_list_topology: if bb_top.id_ == sm_top.bus_id: sm_bus = pp.get_element_index(self.net, 'bus', bb_top.name) pp.create_gen(self.net, sm_bus, sm_top.p_rated, name=sm_top.name) # Create shunt in pandapower network from the internal data structure for sh_top in shunt_compensator_list_topology: for bb_top in busbar_section_list_topology: if bb_top.id_ == sh_top.bus_id: sh_bus = pp.get_element_index(self.net, 'bus', bb_top.name) pp.create_shunt(self.net, sh_bus, sh_top.q_rated_mvar, vn_kv=sh_top.u_nom_kv, name=sh_top.name) # Create loads in pandapower network from the internal data structure for ec_top in energy_consumer_list_topology: for bb_top in busbar_section_list_topology: if bb_top.id_ == ec_top.bus_id: ec_bus = pp.get_element_index(self.net, 'bus', bb_top.name) pp.create_load(self.net, ec_bus, ec_top.p, ec_top.q, name=ec_top.name) # Comment this part if the extended XML files are used # Create switches for br_top in breaker_list_topology: for bb_top in busbar_section_list_topology: if bb_top.id_ == br_top.bus_id: br_bb = pp.get_element_index(self.net, 'bus', bb_top.name) for al_top in ac_line_segment_list_topology: if al_top.id_ == br_top.element_id: br_el = pp.get_element_index( self.net, 'line', al_top.name) pp.create_switch(self.net, br_bb, br_el, et='l', name=br_top.name) for tr_top in power_transformer_list_topology: if tr_top.id_ == br_top.element_id: br_el = pp.get_element_index( self.net, 'trafo', tr_top.name) pp.create_switch(self.net, br_bb, br_el, et='t', name=br_top.name) print('Pandapower network has been created')
def from_ppc(ppc, f_hz=50, validate_conversion=False): """ This function converts pypower case files to pandapower net structure. INPUT: **ppc** - The pypower case file. OPTIONAL: **f_hz** - The frequency of the network. OUTPUT: **net** EXAMPLE: import pandapower.converter as pc from pypower import case4gs ppc_net = case4gs.case4gs() pp_net = cv.from_ppc(ppc_net, f_hz=60) """ # --- catch common failures if Series(ppc['bus'][:, 9] <= 0).any(): logger.info('There are false baseKV given in the pypower case file.') # --- general_parameters baseMVA = ppc['baseMVA'] # MVA omega = pi * f_hz # 1/s MAX_VAL = 99999. net = pp.create_empty_network(f_hz=f_hz) # --- bus data -> create buses, sgen, load, shunt for i in range(len(ppc['bus'])): # create buses pp.create_bus(net, name=int(ppc['bus'][i, 0]), vn_kv=ppc['bus'][i, 9], type="b", zone=ppc['bus'][i, 6], in_service=bool(ppc['bus'][i, 1] != 4), max_vm_pu=ppc['bus'][i, 11], min_vm_pu=ppc['bus'][i, 12]) # create sgen, load if ppc['bus'][i, 2] > 0: pp.create_load(net, i, p_kw=ppc['bus'][i, 2] * 1e3, q_kvar=ppc['bus'][i, 3] * 1e3) elif ppc['bus'][i, 2] < 0: pp.create_sgen(net, i, p_kw=ppc['bus'][i, 2] * 1e3, q_kvar=ppc['bus'][i, 3] * 1e3, type="") elif ppc['bus'][i, 3] != 0: pp.create_load(net, i, p_kw=ppc['bus'][i, 2] * 1e3, q_kvar=ppc['bus'][i, 3] * 1e3) # create shunt if ppc['bus'][i, 4] != 0 or ppc['bus'][i, 5] != 0: pp.create_shunt(net, i, p_kw=ppc['bus'][i, 4] * 1e3, q_kvar=-ppc['bus'][i, 5] * 1e3) # unused data of ppc: Vm, Va (partwise: in ext_grid), zone # --- gen data -> create ext_grid, gen, sgen for i in range(len(ppc['gen'])): # if in ppc is only one gen -> numpy initially uses one dim array -> change to two dim array if len(ppc["gen"].shape) == 1: ppc["gen"] = array(ppc["gen"], ndmin=2) current_bus_idx = pp.get_element_index(net, 'bus', name=int(ppc['gen'][i, 0])) current_bus_type = int(ppc['bus'][current_bus_idx, 1]) # create ext_grid if current_bus_type == 3: if len(pp.get_connected_elements(net, 'ext_grid', current_bus_idx)) > 0: logger.info('At bus %d an ext_grid already exists. ' % current_bus_idx + 'Because of that generator %d ' % i + 'is converted not as an ext_grid but as a sgen') current_bus_type = 1 else: pp.create_ext_grid(net, bus=current_bus_idx, vm_pu=ppc['gen'][i, 5], va_degree=ppc['bus'][current_bus_idx, 8], in_service=bool(ppc['gen'][i, 7] > 0), max_p_kw=-ppc['gen'][i, 9] * 1e3, min_p_kw=-ppc['gen'][i, 8] * 1e3, max_q_kvar=ppc['gen'][i, 3] * 1e3, min_q_kvar=ppc['gen'][i, 4] * 1e3) if ppc['gen'][i, 4] > ppc['gen'][i, 3]: logger.info( 'min_q_kvar of gen %d must be less than max_q_kvar but is not.' % i) if -ppc['gen'][i, 9] < -ppc['gen'][i, 8]: logger.info( 'max_p_kw of gen %d must be less than min_p_kw but is not.' % i) # create gen elif current_bus_type == 2: pp.create_gen(net, bus=current_bus_idx, vm_pu=ppc['gen'][i, 5], p_kw=-ppc['gen'][i, 1] * 1e3, in_service=bool(ppc['gen'][i, 7] > 0), max_p_kw=-ppc['gen'][i, 9] * 1e3, min_p_kw=-ppc['gen'][i, 8] * 1e3, max_q_kvar=ppc['gen'][i, 3] * 1e3, min_q_kvar=ppc['gen'][i, 4] * 1e3, controllable=True) if ppc['gen'][i, 4] > ppc['gen'][i, 3]: logger.info( 'min_q_kvar of gen %d must be less than max_q_kvar but is not.' % i) if -ppc['gen'][i, 9] < -ppc['gen'][i, 8]: logger.info( 'max_p_kw of gen %d must be less than min_p_kw but is not.' % i) # create sgen if current_bus_type == 1: pp.create_sgen(net, bus=current_bus_idx, p_kw=-ppc['gen'][i, 1] * 1e3, q_kvar=-ppc['gen'][i, 2] * 1e3, type="", in_service=bool(ppc['gen'][i, 7] > 0), max_p_kw=-ppc['gen'][i, 9] * 1e3, min_p_kw=-ppc['gen'][i, 8] * 1e3, max_q_kvar=ppc['gen'][i, 3] * 1e3, min_q_kvar=ppc['gen'][i, 4] * 1e3, controllable=True) if ppc['gen'][i, 4] > ppc['gen'][i, 3]: logger.info( 'min_q_kvar of gen %d must be less than max_q_kvar but is not.' % i) if -ppc['gen'][i, 9] < -ppc['gen'][i, 8]: logger.info( 'max_p_kw of gen %d must be less than min_p_kw but is not.' % i) # unused data of ppc: Vg (partwise: in ext_grid and gen), mBase, Pc1, Pc2, Qc1min, Qc1max, # Qc2min, Qc2max, ramp_agc, ramp_10, ramp_30,ramp_q, apf # --- branch data -> create line, trafo for i in range(len(ppc['branch'])): from_bus = pp.get_element_index(net, 'bus', name=int(ppc['branch'][i, 0])) to_bus = pp.get_element_index(net, 'bus', name=int(ppc['branch'][i, 1])) from_vn_kv = ppc['bus'][from_bus, 9] to_vn_kv = ppc['bus'][to_bus, 9] if (from_vn_kv == to_vn_kv) & ((ppc['branch'][i, 8] == 0) | (ppc['branch'][i, 8] == 1)) & \ (ppc['branch'][i, 9] == 0): Zni = ppc['bus'][to_bus, 9]**2 / baseMVA # ohm max_i_ka = ppc['branch'][i, 5] / ppc['bus'][to_bus, 9] if max_i_ka == 0.0: max_i_ka = MAX_VAL logger.debug( "ppc branch rateA is zero -> Using MAX_VAL instead to calculate " + "maximum branch flow") pp.create_line_from_parameters( net, from_bus=from_bus, to_bus=to_bus, length_km=1, r_ohm_per_km=ppc['branch'][i, 2] * Zni, x_ohm_per_km=ppc['branch'][i, 3] * Zni, c_nf_per_km=ppc['branch'][i, 4] / Zni / omega * 1e9 / 2, max_i_ka=max_i_ka, type='ol', in_service=bool(ppc['branch'][i, 10])) else: if from_vn_kv >= to_vn_kv: hv_bus = from_bus vn_hv_kv = from_vn_kv lv_bus = to_bus vn_lv_kv = to_vn_kv tp_side = 'hv' else: hv_bus = to_bus vn_hv_kv = to_vn_kv lv_bus = from_bus vn_lv_kv = from_vn_kv tp_side = 'lv' if from_vn_kv == to_vn_kv: logger.warning( 'The pypower branch %d (from_bus, to_bus)=(%d, %d) is considered' ' as a transformer because of a ratio != 0 | 1 but it connects ' 'the same voltage level', i, ppc['branch'][i, 0], ppc['branch'][i, 1]) rk = ppc['branch'][i, 2] xk = ppc['branch'][i, 3] zk = (rk**2 + xk**2)**0.5 sn = ppc['branch'][i, 5] * 1e3 if sn == 0.0: sn = MAX_VAL logger.debug( "ppc branch rateA is zero -> Using MAX_VAL instead to calculate " + "apparent power") ratio_1 = 0 if ppc['branch'][i, 8] == 0 else (ppc['branch'][i, 8] - 1) * 100 i0_percent = -ppc['branch'][i, 4] * 100 * baseMVA * 1e3 / sn if i0_percent < 0: logger.info( 'A transformer always behaves inductive consumpting but the ' 'susceptance of pypower branch %d (from_bus, to_bus)=(%d, %d) is ' 'positive.', i, ppc['branch'][i, 0], ppc['branch'][i, 1]) pp.create_transformer_from_parameters( net, hv_bus=hv_bus, lv_bus=lv_bus, sn_kva=sn, vn_hv_kv=vn_hv_kv, vn_lv_kv=vn_lv_kv, vsc_percent=zk * sn / 1e3, vscr_percent=rk * sn / 1e3, pfe_kw=0, i0_percent=i0_percent, shift_degree=ppc['branch'][i, 9], tp_st_percent=abs(ratio_1) if ratio_1 else nan, tp_pos=sign(ratio_1) if ratio_1 else nan, tp_side=tp_side if ratio_1 else None, tp_mid=0 if ratio_1 else nan) # unused data of ppc: rateB, rateC # ToDo: gencost, areas are currently unconverted if validate_conversion: # set logger level to debug logger.setLevel(10) if not validate_from_ppc(ppc, net): logger.error("Validation failed.") return net
def create_cigre_network_hv(length_km_6a_6b=0.1): net_cigre_hv = pp.create_empty_network() # Linedata # Line220kV line_data = {'c_nf_per_km': 9.08, 'r_ohm_per_km': 0.0653, 'x_ohm_per_km': 0.398, 'imax_ka': 1.14, 'type': 'ol'} pp.create_std_type(net_cigre_hv, line_data, 'Line220kV', element='line') # Line380kV line_data = {'c_nf_per_km': 11.5, 'r_ohm_per_km': 0.0328, 'x_ohm_per_km': 0.312, 'imax_ka': 1.32, 'type': 'ol'} pp.create_std_type(net_cigre_hv, line_data, 'Line380kV', element='line') # Busses bus1 = pp.create_bus(net_cigre_hv, name='Bus 1', vn_kv=220, type='b', zone='CIGRE_HV') bus2 = pp.create_bus(net_cigre_hv, name='Bus 2', vn_kv=220, type='b', zone='CIGRE_HV') bus3 = pp.create_bus(net_cigre_hv, name='Bus 3', vn_kv=220, type='b', zone='CIGRE_HV') bus4 = pp.create_bus(net_cigre_hv, name='Bus 4', vn_kv=220, type='b', zone='CIGRE_HV') bus5 = pp.create_bus(net_cigre_hv, name='Bus 5', vn_kv=220, type='b', zone='CIGRE_HV') bus6a = pp.create_bus(net_cigre_hv, name='Bus 6a', vn_kv=220, type='b', zone='CIGRE_HV') bus6b = pp.create_bus(net_cigre_hv, name='Bus 6b', vn_kv=220, type='b', zone='CIGRE_HV') bus7 = pp.create_bus(net_cigre_hv, name='Bus 7', vn_kv=380, type='b', zone='CIGRE_HV') bus8 = pp.create_bus(net_cigre_hv, name='Bus 8', vn_kv=380, type='b', zone='CIGRE_HV') bus9 = pp.create_bus(net_cigre_hv, name='Bus 9', vn_kv=22, type='b', zone='CIGRE_HV') bus10 = pp.create_bus(net_cigre_hv, name='Bus 10', vn_kv=22, type='b', zone='CIGRE_HV') bus11 = pp.create_bus(net_cigre_hv, name='Bus 11', vn_kv=22, type='b', zone='CIGRE_HV') bus12 = pp.create_bus(net_cigre_hv, name='Bus 12', vn_kv=22, type='b', zone='CIGRE_HV') # Lines pp.create_line(net_cigre_hv, bus1, bus2, length_km=100, std_type='Line220kV', name='Line 1-2') pp.create_line(net_cigre_hv, bus1, bus6a, length_km=300, std_type='Line220kV', name='Line 1-6a') pp.create_line(net_cigre_hv, bus2, bus5, length_km=300, std_type='Line220kV', name='Line 2-5') pp.create_line(net_cigre_hv, bus3, bus4, length_km=100, std_type='Line220kV', name='Line 3-4') pp.create_line(net_cigre_hv, bus3, bus4, length_km=100, std_type='Line220kV', name='Line 3-4_2') pp.create_line(net_cigre_hv, bus4, bus5, length_km=300, std_type='Line220kV', name='Line 4-5') pp.create_line(net_cigre_hv, bus4, bus6a, length_km=300, std_type='Line220kV', name='Line 4-6a') pp.create_line(net_cigre_hv, bus7, bus8, length_km=600, std_type='Line380kV', name='Line 7-8') pp.create_line(net_cigre_hv, bus6a, bus6b, length_km=length_km_6a_6b, std_type='Line220kV', name='Line 6a-6b') # Trafos pp.create_transformer_from_parameters(net_cigre_hv, bus7, bus1, sn_kva=1000000, vn_hv_kv=380, vn_lv_kv=220, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=0.0, name='Trafo 1-7') pp.create_transformer_from_parameters(net_cigre_hv, bus8, bus3, sn_kva=1000000, vn_hv_kv=380, vn_lv_kv=220, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=0.0, name='Trafo 3-8') pp.create_transformer_from_parameters(net_cigre_hv, bus1, bus9, sn_kva=1000000, vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=330.0, name='Trafo 9-1') pp.create_transformer_from_parameters(net_cigre_hv, bus2, bus10, sn_kva=1000000, vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=330.0, name='Trafo 10-2') pp.create_transformer_from_parameters(net_cigre_hv, bus3, bus11, sn_kva=1000000, vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=330.0, name='Trafo 11-3') pp.create_transformer_from_parameters(net_cigre_hv, bus6b, bus12, sn_kva=500000, vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=330.0, name='Trafo 12-6b') # Loads pp.create_load(net_cigre_hv, bus2, p_kw=285000, q_kvar=200000, name='Load 2') pp.create_load(net_cigre_hv, bus3, p_kw=325000, q_kvar=244000, name='Load 3') pp.create_load(net_cigre_hv, bus4, p_kw=326000, q_kvar=244000, name='Load 4') pp.create_load(net_cigre_hv, bus5, p_kw=103000, q_kvar=62000, name='Load 5') pp.create_load(net_cigre_hv, bus6a, p_kw=435000, q_kvar=296000, name='Load 6a') # External grid pp.create_ext_grid(net_cigre_hv, bus9, vm_pu=1.03, va_degree=0, name='Generator 9') # Generators pp.create_gen(net_cigre_hv, bus10, vm_pu=1.03, p_kw=-5e5, name='Generator 10') pp.create_gen(net_cigre_hv, bus11, vm_pu=1.03, p_kw=-2e5, name='Generator 11') pp.create_gen(net_cigre_hv, bus12, vm_pu=1.03, p_kw=-3e5, name='Generator 12') # Shunts pp.create_shunt(net_cigre_hv, bus4, p_kw=0.0, q_kvar=-160000, name='Shunt 4') pp.create_shunt(net_cigre_hv, bus5, p_kw=0.0, q_kvar=-80000, name='Shunt 5') pp.create_shunt(net_cigre_hv, bus6a, p_kw=0.0, q_kvar=-180000, name='Shunt 6a') return net_cigre_hv
# create load pp_load_list = [] for i in stack_list: for j in i: if j.CE_type == 'Load': pp_load_list.append(pp.create_load(net, i[0].bus, p_mw=2, q_mvar=1, scaling=0.65, name = j.name)) net.load # print(pp_load_list) # create shunt pp_shunt_list = [] for i in stack_list: for j in i: if j.CE_type == 'Compensator': pp_shunt_list.append(pp.create_shunt(net, i[0].bus, q_mvar=-0.95, p_mw=0, name = j.name)) net.shunt # print(pp_shunt_list) print(net) print(net.bus) print(net.trafo) print(net.line) print(net.switch) print(net.sgen) print(net.load) print(net.shunt) pp.plotting.simple_plot(net) for terminal in terminal_list:
sn_mva=sn_mva, vn_hv_kv=vn_hv_kv, vn_lv_kv=vn_lv_kv, vkr_percent=10, vk_percent=0.3, pfe_kw=0, i0_percent=0) # Shunt for shunt in linear_shunt_compensator_list: bus, way_terminals = find_attached_busbar(shunt) bus_name = bus[0].name bus_pp = pp.get_element_index(net, "bus", bus_name) pp.create_shunt(net, name=shunt.name, bus=bus_pp, p_mw=shunt.p, q_mvar=shunt.q) # Load for load in energy_consumer_list: bus, way_terminals = find_attached_busbar(load) bus_name = bus[0].name bus_pp = pp.get_element_index(net, "bus", bus_name) pp.create_load(net, name=load.name, bus=bus_pp, p_mw=load.P) # Line for line in AC_lines_list: bus_list, way_terminals = find_attached_busbar(line) from_bus = pp.get_element_index(net, "bus", bus_list[0].name) to_bus = pp.get_element_index(net, "bus", bus_list[1].name)
pp.create_sgen(net, bus7, p_mw=2, q_mvar=-0.5, name="static generator") print(net.sgen) #Create a voltage controlled generator. Same costumer point of view criteria. pp.create_gen(net, bus6, p_mw=6, max_q_mvar=3, min_q_mvar=-3, vm_pu=1.03, name="generator") net.gen #Shunt (capacitor bank model) pp.create_shunt(net, bus3, q_mvar=-0.96, p_mw=0, name='Shunt') net.shunt #========================================================= #Example/Continuation 3: #Running the powerflow import pandapower as pp import pandapower.networks pp.runpp(net) print(net) print(net.res_bus) #Loadflow analyis commands: #Minimum voltage at a bus with load or generation print(net.res_bus[net.bus.vn_kv == 20.].vm_pu.min())
def execute_my_script(EQ_file, SSH_file): #Next step is to create a tree by parsing the XML file referenced # We are here using ENTSO-E model files used in Interoperability testing EQ_tree = ET.parse(EQ_file) SSH_tree = ET.parse(SSH_file) # We can access the root (raiz) of the tree and print it EQ_microgrid = EQ_tree.getroot() SSH_microgrid = SSH_tree.getroot() # To make working with the file easier, it may be useful to store the # namespace identifiers in strings and reuse when you search for tags ns = {'cim':'http://iec.ch/TC57/2013/CIM-schema-cim16#', 'entsoe':'http://entsoe.eu/CIM/SchemaExtension/3/1#', 'rdf':'{http://www.w3.org/1999/02/22-rdf-syntax-ns#}'} #create an empty network net = pp.create_empty_network() #to see al the elements in our system: EQ_tag=[] for eq in EQ_microgrid: if (ns['cim'] in eq.tag): equipment = eq.tag.replace("{"+ns['cim']+"}","") if equipment not in EQ_tag : EQ_tag.append(equipment) print(EQ_tag) print("---------------------------------------------------------") # My goal here it's to create a dictionary that links voltage level with their respective ID # I want to to avoid repetition in the loop when finding the match voltage level of the equipment voltage_levels_dic = {} for voltage_level in EQ_microgrid.findall('cim:VoltageLevel', ns): voltage_name = float(voltage_level.find('cim:IdentifiedObject.name', ns).text) voltage_levels_dic[voltage_level.attrib.get(ns['rdf']+'ID')] = voltage_name print(voltage_levels_dic) # Create buses in the pandapower system from the XML file data adquired for bus in EQ_microgrid.findall('cim:BusbarSection', ns): # Extracting the name from the BusbarSection element bus_name = bus.find('cim:IdentifiedObject.name', ns).text # I the next line of code we want to obtain the Equipment.EquipmentContainer ID of each busbar section and take with it the corresponding bus # voltage level relation that we have previously determined in the dictionary bus_voltage_level = voltage_levels_dic[bus.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '')] pp.create_bus(net, bus_voltage_level, name=bus_name) print(net.bus) print("---------------------------------------------------------") # Create lines in the pandapower system from the XML file data adquired for line in EQ_microgrid.findall('cim:ACLineSegment', ns): #I want to get the ID of each line line_id = line.attrib.get(ns['rdf'] + 'ID') print (line_id) # next step will be retrieving the name of the line line_name = line.find('cim:IdentifiedObject.name', ns).text print (line_name) # Now I want to get the length of the line line_length = float(line.find('cim:Conductor.length', ns).text) print (line_length) # get the resistance of the line line_resistance_per_km = float(line.find('cim:ACLineSegment.r', ns).text)/line_length # get the reactance of the line line_rectance_per_km = float(line.find('cim:ACLineSegment.x', ns).text)/line_length # I want to find the ID of the terminals where the line is connected to # Basically we want to know to wich 2 terminals each line is connected to in order to later define # from/to which buses the lines are connected to for terminal in EQ_microgrid.findall('cim:Terminal', ns): line_Te_CE = terminal.find('cim:Terminal.ConductingEquipment', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') line_sequence_number = terminal.find('cim:ACDCTerminal.sequenceNumber', ns).text if line_id == line_Te_CE: # We do this in order to select the terminals related to the lines if line_sequence_number == '1': #This is because for each line we have 2 terminals, the one with sequence number 1 and the other with seq number 2 # Gets the connectivity node ID from the terminals line_Te_CN = terminal.find('cim:Terminal.ConnectivityNode', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # With this new for loop the objective is to find the ConnectivityNode associaton, in other words # I want to obtain for each connectivitynode their corresponding id and container association for CN in EQ_microgrid.findall('cim:ConnectivityNode', ns): if CN.attrib.get(ns['rdf'] + 'ID') == line_Te_CN: CN_id = CN.attrib.get(ns['rdf'] + 'ID') CN_container = CN.find('cim:ConnectivityNode.ConnectivityNodeContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # I want now to stablish a connection between the ConnectivityNode.ConnectivityNodeContainer # and the corresponding busbarsection for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): if BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') == CN_container: Line_Te1 = BusBar.find('cim:IdentifiedObject.name', ns).text elif line_sequence_number == '2': # Gets the connectivity node ID from the terminals line_Te_CN = terminal.find('cim:Terminal.ConnectivityNode', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # With this new for loop the objective is to find the ConnectivityNode associaton, in other words # I want to obtain for each connectivitynode their corresponding id and container association for CN in EQ_microgrid.findall('cim:ConnectivityNode', ns): if CN.attrib.get(ns['rdf'] + 'ID') == line_Te_CN: CN_id = CN.attrib.get(ns['rdf'] + 'ID') CN_container = CN.find('cim:ConnectivityNode.ConnectivityNodeContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # I want now to stablish a connection between the ConnectivityNode.ConnectivityNodeContainer # and the corresponding busbarsection for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): if BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') == CN_container: Line_Te2 = BusBar.find('cim:IdentifiedObject.name', ns).text Line_from_Bus = pp.get_element_index(net, "bus", Line_Te1) Line_to_Bus = pp.get_element_index(net, "bus", Line_Te2) pp.create_line(net, Line_from_Bus, Line_to_Bus, length_km=line_length,std_type='NAYY 4x50 SE', name=line_name)# parallel=hv_line.parallel) # show line table print(net.line) print("---------------------------------------------------------") # Create transformers in the pandapower system from the XML file data adquired for transformers in EQ_microgrid.findall('cim:PowerTransformer', ns): #I want to get the ID of each transformer transformer_id = transformers.attrib.get(ns['rdf'] + 'ID') # next step will be retrieving the name of the transformer transformers_name = transformers.find('cim:IdentifiedObject.name', ns).text print(transformers_name) # I want to find the ID of the terminals where the transformer is connected to for transformer_end in EQ_microgrid.findall('cim:PowerTransformerEnd', ns): transformer_end_id = transformer_end.find('cim:PowerTransformerEnd.PowerTransformer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # Find the side of the power transformer if transformer_id == transformer_end_id: transformer_end_number = transformer_end.find('cim:TransformerEnd.endNumber', ns).text # I want to find the value of the TransformerEnd.endNumber because it will give you the information about if # it is the HV(=1) or LV(=2) print(transformer_end_number) if transformer_end_number == '1': # As we did previously for the lines we use did if in order to create 2 paths, one will define the # parameters of HV side and the other the parameters of the LV side # I am taking the information of the transformer, Power rating of the transformer # The parameters are taking on the HV(=1) side because is where the data about r,x is stored at the XML file transformer_S = float(transformer_end.find('cim:PowerTransformerEnd.ratedS', ns).text) transformer_hv_kv = float(transformer_end.find('cim:PowerTransformerEnd.ratedU', ns).text) transformer_r = float(transformer_end.find('cim:PowerTransformerEnd.r', ns).text) transformer_x = float(transformer_end.find('cim:PowerTransformerEnd.x', ns).text) transformer_z = (transformer_r ** 2 + transformer_x ** 2) ** (1/2) # I am going to neglect the iron losses, the open loop losses, shift degree # Find the terminal the transformer end is connected to transformer_end_terminal = transformer_end.find('cim:TransformerEnd.Terminal', ns).attrib.get(ns['rdf'] + 'resource').replace('#','') for terminal in EQ_microgrid.findall('cim:Terminal', ns): terminal_id = terminal.attrib.get(ns['rdf'] + 'ID') if terminal_id == transformer_end_terminal: # Take the connectivity node's ID from the terminal transformer_Te_CN = terminal.find('cim:Terminal.ConnectivityNode', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # With this new for loop the objective is to find the ConnectivityNode associaton, in other words # I want to obtain for each connectivitynode their corresponding id and container association for CN in EQ_microgrid.findall('cim:ConnectivityNode', ns): if CN.attrib.get(ns['rdf'] + 'ID') == line_Te_CN: transformer_CN_id = CN.attrib.get(ns['rdf'] + 'ID') transformer_CN_container = CN.find('cim:ConnectivityNode.ConnectivityNodeContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # I want now to stablish a connection between the ConnectivityNode.ConnectivityNodeContainer # and the corresponding busbarsection for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): if BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') == CN_container: transformer_Te1 = BusBar.find('cim:IdentifiedObject.name', ns).text # Now we want to do the same for the LV side elif transformer_end_number == '2': transformer_lv_kv = float(transformer_end.find('cim:PowerTransformerEnd.ratedU', ns).text) # Find the terminal the transformer end is connected to transformer_end_terminal = transformer_end.find('cim:TransformerEnd.Terminal', ns).attrib.get(ns['rdf'] + 'resource').replace('#','') for terminal in EQ_microgrid.findall('cim:Terminal', ns): terminal_id = terminal.attrib.get(ns['rdf'] + 'ID') if terminal_id == transformer_end_terminal: # Take the connectivity node's ID from the terminal transformer_Te_CN = terminal.find('cim:Terminal.ConnectivityNode', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # With this new for loop the objective is to find the ConnectivityNode associaton, in other words # I want to obtain for each connectivitynode their corresponding id and container association for CN in EQ_microgrid.findall('cim:ConnectivityNode', ns): if CN.attrib.get(ns['rdf'] + 'ID') == line_Te_CN: transformer_CN_id = CN.attrib.get(ns['rdf'] + 'ID') transformer_CN_container = CN.find('cim:ConnectivityNode.ConnectivityNodeContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # I want now to stablish a connection between the ConnectivityNode.ConnectivityNodeContainer # and the corresponding busbarsection for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): if BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') == CN_container: transformer_Te2 = BusBar.find('cim:IdentifiedObject.name', ns).text hv_bus = pp.get_element_index(net, "bus", transformer_Te1) lv_bus = pp.get_element_index(net, "bus", transformer_Te2) pp.create_transformer_from_parameters(net, hv_bus, lv_bus, sn_mva=transformer_S, vn_hv_kv=transformer_hv_kv, vn_lv_kv=transformer_lv_kv, vkr_percent=0.06, vk_percent=8, pfe_kw=0, i0_percent=0, tp_pos=0, shift_degree=0, name=transformers_name) print(net.trafo) # show trafo table print("---------------------------------------------------------") # Create Loads in the pandapower system from the XML file (SSH) data adquired # In order to do this, firs we will take the name and ID of the loads from the EQ file, afterwards we will use this # Id that we have obtained before to look for its corresponding P & Q data stored in the SSH file for load in EQ_microgrid.findall('cim:EnergyConsumer', ns): #I want to get the ID of each load eq_load_id = load.attrib.get(ns['rdf'] + 'ID') # next step will be retrieving the name of the load load_name = load.find('cim:IdentifiedObject.name', ns).text print(load_name) for ssh_load in SSH_microgrid.findall('cim:EnergyConsumer', ns): ssh_load_id = ssh_load.attrib.get(ns['rdf'] + 'about').replace('#', '') print(ssh_load_id) if ssh_load_id == eq_load_id: P_load = float(ssh_load.find('cim:EnergyConsumer.p', ns).text) Q_load = float(ssh_load.find('cim:EnergyConsumer.q', ns).text) # After we got the P & Q for each load, now I want to find the terminal associated to each load (from the EQ file again) for terminal in EQ_microgrid.findall('cim:Terminal', ns): load_Te_CE = terminal.find('cim:Terminal.ConductingEquipment', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') if eq_load_id == load_Te_CE: # We do this in order to select the terminals related to the loads load_Te_CN = terminal.find('cim:Terminal.ConnectivityNode', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # With this new for loop the objective is to find the ConnectivityNode associaton, in other words # I want to obtain for each connectivitynode their corresponding id and container association for CN in EQ_microgrid.findall('cim:ConnectivityNode', ns): if CN.attrib.get(ns['rdf'] + 'ID') == load_Te_CN: CN_id = CN.attrib.get(ns['rdf'] + 'ID') CN_container = CN.find('cim:ConnectivityNode.ConnectivityNodeContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # I want now to stablish a connection between the ConnectivityNode.ConnectivityNodeContainer # and the corresponding busbarsection for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): if BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') == CN_container: Load_Te = BusBar.find('cim:IdentifiedObject.name', ns).text bus_idx = pp.get_element_index(net, "bus", Load_Te) pp.create_load(net, bus_idx, p_mw=P_load, q_mvar=Q_load, name=load_name) # show load table print(net.load) print("---------------------------------------------------------") # Create generators in pandapower, for generator in EQ_microgrid.findall('cim:GeneratingUnit', ns): generator_id = generator.attrib.get(ns['rdf'] + 'ID') generator_name = generator.find('cim:IdentifiedObject.name', ns).text generator_initial_P = float(generator.find('cim:GeneratingUnit.initialP', ns).text) # Looking for the SynchronousMachine related to the generator unit for synch_machine in EQ_microgrid.findall('cim:SynchronousMachine', ns): synch_machine_id = synch_machine.attrib.get(ns['rdf'] + 'ID') if synch_machine.find('cim:RotatingMachine.GeneratingUnit', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') == generator_id: synch_machine_ratedU = float(synch_machine.find('cim:RotatingMachine.ratedU', ns).text) # print(synch_machine_ratedU) synch_machine_id = synch_machine.attrib.get(ns['rdf'] + 'ID') synch_machine_equip_cont = synch_machine.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): BusBar_equip_cont = BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') if BusBar_equip_cont == synch_machine_equip_cont: generator_busbar = BusBar.find('cim:IdentifiedObject.name', ns).text bus_voltage = voltage_levels_dic[BusBar_equip_cont] # print(bus_voltage) vm_pu = synch_machine_ratedU / bus_voltage print(vm_pu) pp.create_gen(net, pp.get_element_index(net, "bus", generator_busbar), generator_initial_P, vm_pu, name=generator_name) # vm_pu=1.0 this is because there is no extra info about vm_pu in the xml file. Thus, as the rated voltage # of the synch.machine is exactly the same as the bus which it is connected # Find the terminal the generator is connected to print(net.gen) print("---------------------------------------------------------") # Create shunt capacitors in pandapower. # To define shunt in pandapower we need: the bus that is connected to, p_mw=0, q_mvar, name. for shunt in EQ_microgrid.findall('cim:LinearShuntCompensator', ns): shunt_id = shunt.attrib.get(ns['rdf'] + 'ID') shunt_name = shunt.find('cim:IdentifiedObject.name', ns).text shunt_b = float(shunt.find('cim:LinearShuntCompensator.bPerSection', ns).text) shunt_nom_U = float(shunt.find('cim:ShuntCompensator.nomU', ns).text) # In a shunt capacitor, Q = b*(Unom^2) because g = 0 shunt_Q = shunt_b*(shunt_nom_U**2) shunt_equip_cont = shunt.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): BusBar_equip_cont = BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') if BusBar_equip_cont == shunt_equip_cont: shunt_busbar = BusBar.find('cim:IdentifiedObject.name', ns).text pp.create_shunt(net, pp.get_element_index(net, "bus", shunt_busbar), p_mw=0, q_mvar=shunt_Q, name=shunt_name) print(net.shunt) print("---------------------------------------------------------") # Create breakers in pandapower. for breaker in EQ_microgrid.findall('cim:Breaker', ns): breaker_id = breaker.attrib.get(ns['rdf'] + 'ID') breaker_name = breaker.find('cim:IdentifiedObject.name', ns).text breaker_position = breaker.find('cim:Switch.normalOpen', ns).text # Breaker position in the EQ.xml file determines if the sitch is open(=TRUE), but for pandapower # the parameteres examines if the switch is closed(=FALSE), thi is why we need to create # an if condition to readjust this as we want if breaker_position == 'false': breaker_position = True elif breaker_position == 'true': breaker_position = False # I want to find the ID of the terminals where the breaker is connected to # Basically we want to know to wich 2 terminals each breaker is connected to in order to later define # from/to which buses the breaker are connected to for terminal in EQ_microgrid.findall('cim:Terminal', ns): breaker_Te_CE = terminal.find('cim:Terminal.ConductingEquipment', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') breaker_sequence_number = terminal.find('cim:ACDCTerminal.sequenceNumber', ns).text if breaker_id == breaker_Te_CE: if breaker_sequence_number == '1': # Take the connectivity node's ID from the terminal breaker_Te_CN = terminal.find('cim:Terminal.ConnectivityNode', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # With this new for loop the objective is to find the ConnectivityNode associaton, in other words # I want to obtain for each connectivitynode their corresponding id and container association for CN in EQ_microgrid.findall('cim:ConnectivityNode', ns): if CN.attrib.get(ns['rdf'] + 'ID') == breaker_Te_CN: CN_id = CN.attrib.get(ns['rdf'] + 'ID') CN_container = CN.find('cim:ConnectivityNode.ConnectivityNodeContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # I want now to stablish a connection between the ConnectivityNode.ConnectivityNodeContainer # and the corresponding busbarsection for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): if BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') == CN_container: breaker_Te1 = BusBar.find('cim:IdentifiedObject.name', ns).text print(breaker_Te1) elif breaker_sequence_number == '2': # Gets the connectivity node ID from the terminals breaker_Te_CN = terminal.find('cim:Terminal.ConnectivityNode', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # With this new for loop the objective is to find the ConnectivityNode associaton, in other words # I want to obtain for each connectivitynode their corresponding id and container association for CN in EQ_microgrid.findall('cim:ConnectivityNode', ns): if CN.attrib.get(ns['rdf'] + 'ID') == line_Te_CN: CN_id = CN.attrib.get(ns['rdf'] + 'ID') CN_container = CN.find('cim:ConnectivityNode.ConnectivityNodeContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') # I want now to stablish a connection between the ConnectivityNode.ConnectivityNodeContainer # and the corresponding busbarsection for BusBar in EQ_microgrid.findall('cim:BusbarSection', ns): if BusBar.find('cim:Equipment.EquipmentContainer', ns).attrib.get(ns['rdf'] + 'resource').replace('#', '') == CN_container: breaker_Te2 = BusBar.find('cim:IdentifiedObject.name', ns).text print(breaker_Te2) print("---------------------------------------------------------") from_bus = pp.get_element_index(net, "bus", breaker_Te1) to_bus = pp.get_element_index(net, "bus", breaker_Te2) pp.create_switch(net, from_bus, to_bus, et='b', closed=breaker_position, type='CB', name=breaker_name) print(net.switch) plot.to_html(net, 'plot_system.html') #plot.simple_plot(net, respect_switches=False, line_width=1.0, bus_size=1.0, ext_grid_size=1.0, trafo_size=1.0, plot_loads=False, plot_sgens=False, load_size=1.0, sgen_size=1.0, switch_size=2.0, # switch_distance=1.0, plot_line_switches=False, scale_size=True, bus_color='b', line_color='grey', trafo_color='k', ext_grid_color='y', switch_color='k', library='igraph', show_plot=True, ax=None) #execute_my_script('MicroGridTestConfiguration_T1_BE_EQ_V2.xml', 'MicroGridTestConfiguration_T1_BE_SSH_V2.xml')
def create_cigre_network_hv(length_km_6a_6b=0.1): """ Create the CIGRE HV Grid from final Report of Task Force C6.04.02: "Benchmark Systems for Network Integration of Renewable and Distributed Energy Resources”, 2014. OPTIONAL: **length_km_6a_6b** (float, 0.1) - Length of the line segment 9 between buses 6a and 6b which is intended to be optional with user-definable geometrical configuration, length and installation type. OUTPUT: **net** - The pandapower format network. """ net_cigre_hv = pp.create_empty_network() # Linedata # Line220kV line_data = {'c_nf_per_km': 9.08, 'r_ohm_per_km': 0.0653, 'x_ohm_per_km': 0.398, 'max_i_ka': 1.14, 'type': 'ol'} pp.create_std_type(net_cigre_hv, line_data, 'Line220kV', element='line') # Line380kV line_data = {'c_nf_per_km': 11.5, 'r_ohm_per_km': 0.0328, 'x_ohm_per_km': 0.312, 'max_i_ka': 1.32, 'type': 'ol'} pp.create_std_type(net_cigre_hv, line_data, 'Line380kV', element='line') # Busses bus1 = pp.create_bus(net_cigre_hv, name='Bus 1', vn_kv=220, type='b', zone='CIGRE_HV') bus2 = pp.create_bus(net_cigre_hv, name='Bus 2', vn_kv=220, type='b', zone='CIGRE_HV') bus3 = pp.create_bus(net_cigre_hv, name='Bus 3', vn_kv=220, type='b', zone='CIGRE_HV') bus4 = pp.create_bus(net_cigre_hv, name='Bus 4', vn_kv=220, type='b', zone='CIGRE_HV') bus5 = pp.create_bus(net_cigre_hv, name='Bus 5', vn_kv=220, type='b', zone='CIGRE_HV') bus6a = pp.create_bus(net_cigre_hv, name='Bus 6a', vn_kv=220, type='b', zone='CIGRE_HV') bus6b = pp.create_bus(net_cigre_hv, name='Bus 6b', vn_kv=220, type='b', zone='CIGRE_HV') bus7 = pp.create_bus(net_cigre_hv, name='Bus 7', vn_kv=380, type='b', zone='CIGRE_HV') bus8 = pp.create_bus(net_cigre_hv, name='Bus 8', vn_kv=380, type='b', zone='CIGRE_HV') bus9 = pp.create_bus(net_cigre_hv, name='Bus 9', vn_kv=22, type='b', zone='CIGRE_HV') bus10 = pp.create_bus(net_cigre_hv, name='Bus 10', vn_kv=22, type='b', zone='CIGRE_HV') bus11 = pp.create_bus(net_cigre_hv, name='Bus 11', vn_kv=22, type='b', zone='CIGRE_HV') bus12 = pp.create_bus(net_cigre_hv, name='Bus 12', vn_kv=22, type='b', zone='CIGRE_HV') # Lines pp.create_line(net_cigre_hv, bus1, bus2, length_km=100, std_type='Line220kV', name='Line 1-2') pp.create_line(net_cigre_hv, bus1, bus6a, length_km=300, std_type='Line220kV', name='Line 1-6a') pp.create_line(net_cigre_hv, bus2, bus5, length_km=300, std_type='Line220kV', name='Line 2-5') pp.create_line(net_cigre_hv, bus3, bus4, length_km=100, std_type='Line220kV', name='Line 3-4') pp.create_line(net_cigre_hv, bus3, bus4, length_km=100, std_type='Line220kV', name='Line 3-4_2') pp.create_line(net_cigre_hv, bus4, bus5, length_km=300, std_type='Line220kV', name='Line 4-5') pp.create_line(net_cigre_hv, bus4, bus6a, length_km=300, std_type='Line220kV', name='Line 4-6a') pp.create_line(net_cigre_hv, bus7, bus8, length_km=600, std_type='Line380kV', name='Line 7-8') pp.create_line(net_cigre_hv, bus6a, bus6b, length_km=length_km_6a_6b, std_type='Line220kV', name='Line 6a-6b') # Trafos pp.create_transformer_from_parameters(net_cigre_hv, bus7, bus1, sn_kva=1000000, vn_hv_kv=380, vn_lv_kv=220, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=0.0, name='Trafo 1-7') pp.create_transformer_from_parameters(net_cigre_hv, bus8, bus3, sn_kva=1000000, vn_hv_kv=380, vn_lv_kv=220, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=0.0, name='Trafo 3-8') pp.create_transformer_from_parameters(net_cigre_hv, bus1, bus9, sn_kva=1000000, vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=330.0, name='Trafo 9-1') pp.create_transformer_from_parameters(net_cigre_hv, bus2, bus10, sn_kva=1000000, vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=330.0, name='Trafo 10-2') pp.create_transformer_from_parameters(net_cigre_hv, bus3, bus11, sn_kva=1000000, vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=330.0, name='Trafo 11-3') pp.create_transformer_from_parameters(net_cigre_hv, bus6b, bus12, sn_kva=500000, vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0, vsc_percent=13.0, pfe_kw=0, i0_percent=0, shift_degree=330.0, name='Trafo 12-6b') # Loads pp.create_load(net_cigre_hv, bus2, p_kw=285000, q_kvar=200000, name='Load 2') pp.create_load(net_cigre_hv, bus3, p_kw=325000, q_kvar=244000, name='Load 3') pp.create_load(net_cigre_hv, bus4, p_kw=326000, q_kvar=244000, name='Load 4') pp.create_load(net_cigre_hv, bus5, p_kw=103000, q_kvar=62000, name='Load 5') pp.create_load(net_cigre_hv, bus6a, p_kw=435000, q_kvar=296000, name='Load 6a') # External grid pp.create_ext_grid(net_cigre_hv, bus9, vm_pu=1.03, va_degree=0, name='Generator 9') # Generators pp.create_gen(net_cigre_hv, bus10, vm_pu=1.03, p_kw=-5e5, name='Generator 10') pp.create_gen(net_cigre_hv, bus11, vm_pu=1.03, p_kw=-2e5, name='Generator 11') pp.create_gen(net_cigre_hv, bus12, vm_pu=1.03, p_kw=-3e5, name='Generator 12') # Shunts pp.create_shunt(net_cigre_hv, bus4, p_kw=0.0, q_kvar=-160000, name='Shunt 4') pp.create_shunt(net_cigre_hv, bus5, p_kw=0.0, q_kvar=-80000, name='Shunt 5') pp.create_shunt(net_cigre_hv, bus6a, p_kw=0.0, q_kvar=-180000, name='Shunt 6a') # Bus geo data net_cigre_hv.bus_geodata = read_json( """{"x":{"0":4,"1":8,"2":20,"3":16,"4":12,"5":8,"6":12,"7":4,"8":20,"9":0,"10":8,"11":24, "12":16},"y":{"0":8.0,"1":8.0,"2":8.0,"3":8.0,"4":8.0,"5":6.0,"6":4.5,"7":1.0,"8":1.0, "9":8.0,"10":12.0,"11":8.0,"12":4.5}}""") # Match bus.index net_cigre_hv.bus_geodata = net_cigre_hv.bus_geodata.loc[net_cigre_hv.bus.index] return net_cigre_hv
def case34(): """ Create the IEEE 34 bus from IEEE PES Test Feeders: "https://site.ieee.org/pes-testfeeders/resources/”. OUTPUT: **net** - The pandapower format network. """ net = pp.create_empty_network() # Linedata # CF-300 line_data = { 'c_nf_per_km': 3.8250977, 'r_ohm_per_km': 0.69599766, 'x_ohm_per_km': 0.5177677, 'c0_nf_per_km': 1.86976748, 'r0_ohm_per_km': 1.08727498, 'x0_ohm_per_km': 1.47374703, 'max_i_ka': 0.23, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-300', element='line') # CF-301 line_data = { 'c_nf_per_km': 3.66884364, 'r_ohm_per_km': 1.05015841, 'x_ohm_per_km': 0.52265586, 'c0_nf_per_km': 1.82231544, 'r0_ohm_per_km': 1.48350255, 'x0_ohm_per_km': 1.60203942, 'max_i_ka': 0.18, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-301', element='line') # CF-302 line_data = { 'c_nf_per_km': 0.8751182, 'r_ohm_per_km': 0.5798427, 'x_ohm_per_km': 0.30768221, 'c0_nf_per_km': 0.8751182, 'r0_ohm_per_km': 0.5798427, 'x0_ohm_per_km': 0.30768221, 'max_i_ka': 0.14, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-302', element='line') # CF-303 line_data = { 'c_nf_per_km': 0.8751182, 'r_ohm_per_km': 0.5798427, 'x_ohm_per_km': 0.30768221, 'c0_nf_per_km': 0.8751182, 'r0_ohm_per_km': 0.5798427, 'x0_ohm_per_km': 0.30768221, 'max_i_ka': 0.14, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-303', element='line') # CF-304 line_data = { 'c_nf_per_km': 0.90382554, 'r_ohm_per_km': 0.39802955, 'x_ohm_per_km': 0.29436416, 'c0_nf_per_km': 0.90382554, 'r0_ohm_per_km': 0.39802955, 'x0_ohm_per_km': 0.29436416, 'max_i_ka': 0.18, 'type': 'ol' } pp.create_std_type(net, line_data, name='CF-304', element='line') # Busses # bus0 = pp.create_bus(net, name='Bus 0', vn_kv=69.0, type='n', zone='34_BUS') bus_800 = pp.create_bus(net, name='Bus 800', vn_kv=24.9, type='n', zone='34_BUS') bus_802 = pp.create_bus(net, name='Bus 802', vn_kv=24.9, type='n', zone='34_BUS') bus_806 = pp.create_bus(net, name='Bus 806', vn_kv=24.9, type='n', zone='34_BUS') bus_808 = pp.create_bus(net, name='Bus 808', vn_kv=24.9, type='n', zone='34_BUS') bus_810 = pp.create_bus(net, name='Bus 810', vn_kv=24.9, type='n', zone='34_BUS') bus_812 = pp.create_bus(net, name='Bus 812', vn_kv=24.9, type='n', zone='34_BUS') bus_814 = pp.create_bus(net, name='Bus 814', vn_kv=24.9, type='n', zone='34_BUS') bus_850 = pp.create_bus(net, name='Bus 850', vn_kv=24.9, type='n', zone='34_BUS') bus_816 = pp.create_bus(net, name='Bus 816', vn_kv=24.9, type='n', zone='34_BUS') bus_818 = pp.create_bus(net, name='Bus 818', vn_kv=24.9, type='n', zone='34_BUS') bus_820 = pp.create_bus(net, name='Bus 820', vn_kv=24.9, type='n', zone='34_BUS') bus_822 = pp.create_bus(net, name='Bus 822', vn_kv=24.9, type='n', zone='34_BUS') bus_824 = pp.create_bus(net, name='Bus 824', vn_kv=24.9, type='n', zone='34_BUS') bus_826 = pp.create_bus(net, name='Bus 826', vn_kv=24.9, type='n', zone='34_BUS') bus_828 = pp.create_bus(net, name='Bus 828', vn_kv=24.9, type='n', zone='34_BUS') bus_830 = pp.create_bus(net, name='Bus 830', vn_kv=24.9, type='n', zone='34_BUS') bus_854 = pp.create_bus(net, name='Bus 854', vn_kv=24.9, type='n', zone='34_BUS') bus_852 = pp.create_bus(net, name='Bus 852', vn_kv=24.9, type='n', zone='34_BUS') bus_832 = pp.create_bus(net, name='Bus 832', vn_kv=24.9, type='n', zone='34_BUS') bus_858 = pp.create_bus(net, name='Bus 858', vn_kv=24.9, type='n', zone='34_BUS') bus_834 = pp.create_bus(net, name='Bus 834', vn_kv=24.9, type='n', zone='34_BUS') bus_842 = pp.create_bus(net, name='Bus 842', vn_kv=24.9, type='n', zone='34_BUS') bus_844 = pp.create_bus(net, name='Bus 844', vn_kv=24.9, type='n', zone='34_BUS') bus_846 = pp.create_bus(net, name='Bus 846', vn_kv=24.9, type='n', zone='34_BUS') bus_848 = pp.create_bus(net, name='Bus 848', vn_kv=24.9, type='n', zone='34_BUS') bus_860 = pp.create_bus(net, name='Bus 860', vn_kv=24.9, type='n', zone='34_BUS') bus_836 = pp.create_bus(net, name='Bus 836', vn_kv=24.9, type='n', zone='34_BUS') bus_840 = pp.create_bus(net, name='Bus 840', vn_kv=24.9, type='n', zone='34_BUS') bus_862 = pp.create_bus(net, name='Bus 862', vn_kv=24.9, type='n', zone='34_BUS') bus_838 = pp.create_bus(net, name='Bus 838', vn_kv=24.9, type='n', zone='34_BUS') bus_864 = pp.create_bus(net, name='Bus 864', vn_kv=24.9, type='n', zone='34_BUS') bus_888 = pp.create_bus(net, name='Bus 888', vn_kv=4.16, type='n', zone='34_BUS') bus_890 = pp.create_bus(net, name='Bus 890', vn_kv=4.16, type='n', zone='34_BUS') bus_856 = pp.create_bus(net, name='Bus 856', vn_kv=24.9, type='n', zone='34_BUS') # Lines pp.create_line(net, bus_800, bus_802, length_km=0.786384, std_type='CF-300', name='Line 0') pp.create_line(net, bus_802, bus_806, length_km=0.527304, std_type='CF-300', name='Line 1') pp.create_line(net, bus_806, bus_808, length_km=9.823704, std_type='CF-300', name='Line 2') pp.create_line(net, bus_808, bus_810, length_km=1.769059, std_type='CF-303', name='Line 3') pp.create_line(net, bus_808, bus_812, length_km=11.43000, std_type='CF-300', name='Line 4') pp.create_line(net, bus_812, bus_814, length_km=9.061704, std_type='CF-300', name='Line 5') # pp.create_line(net, bus_814, bus_850, length_km=0.003048, std_type='CF-301', name='Line 6') pp.create_line(net, bus_816, bus_818, length_km=0.521208, std_type='CF-302', name='Line 7') pp.create_line(net, bus_816, bus_824, length_km=3.112008, std_type='CF-301', name='Line 8') pp.create_line(net, bus_818, bus_820, length_km=14.67612, std_type='CF-302', name='Line 9') pp.create_line(net, bus_820, bus_822, length_km=4.187952, std_type='CF-302', name='Line 10') pp.create_line(net, bus_824, bus_826, length_km=0.923544, std_type='CF-303', name='Line 11') pp.create_line(net, bus_824, bus_828, length_km=0.256032, std_type='CF-301', name='Line 12') pp.create_line(net, bus_828, bus_830, length_km=6.230112, std_type='CF-301', name='Line 13') pp.create_line(net, bus_830, bus_854, length_km=0.158496, std_type='CF-301', name='Line 14') pp.create_line(net, bus_832, bus_858, length_km=1.493520, std_type='CF-301', name='Line 15') pp.create_line(net, bus_834, bus_860, length_km=0.615696, std_type='CF-301', name='Line 16') pp.create_line(net, bus_834, bus_842, length_km=0.085344, std_type='CF-301', name='Line 17') pp.create_line(net, bus_836, bus_840, length_km=0.262128, std_type='CF-301', name='Line 18') pp.create_line(net, bus_836, bus_862, length_km=0.085344, std_type='CF-301', name='Line 19') pp.create_line(net, bus_842, bus_844, length_km=0.411480, std_type='CF-301', name='Line 20') pp.create_line(net, bus_844, bus_846, length_km=1.109472, std_type='CF-301', name='Line 21') pp.create_line(net, bus_846, bus_848, length_km=0.161544, std_type='CF-301', name='Line 22') pp.create_line(net, bus_850, bus_816, length_km=0.094488, std_type='CF-301', name='Line 23') # pp.create_line(net, bus_852, bus_832, length_km=0.003048, std_type='CF-301', name='Line 24') pp.create_line(net, bus_854, bus_856, length_km=7.110984, std_type='CF-303', name='Line 25') pp.create_line(net, bus_854, bus_852, length_km=11.22578, std_type='CF-301', name='Line 26') pp.create_line(net, bus_858, bus_864, length_km=0.493776, std_type='CF-302', name='Line 27') pp.create_line(net, bus_858, bus_834, length_km=1.776984, std_type='CF-301', name='Line 28') pp.create_line(net, bus_860, bus_836, length_km=0.816864, std_type='CF-301', name='Line 29') pp.create_line(net, bus_860, bus_838, length_km=1.481328, std_type='CF-304', name='Line 30') pp.create_line(net, bus_888, bus_890, length_km=3.218688, std_type='CF-300', name='Line 31') # Regulator 1 pp.create_transformer_from_parameters(net, bus_814, bus_850, sn_mva=2.5, vn_hv_kv=24.9, vn_lv_kv=24.9, vkr_percent=0.320088 * 2.5, vk_percent=0.357539 * 2.5, pfe_kw=0.0, i0_percent=0.0, shift_degree=0.0, tap_side='lv', tap_neutral=0, tap_max=16, tap_min=-16, tap_step_percent=0.625, tap_pos=0, tap_phase_shifter=False, name='Regulator 1') # Regulator 2 pp.create_transformer_from_parameters(net, bus_852, bus_832, sn_mva=2.5, vn_hv_kv=24.9, vn_lv_kv=24.9, vkr_percent=0.320088 * 2.5, vk_percent=0.357539 * 2.5, pfe_kw=0.0, i0_percent=0.0, shift_degree=0.0, tap_side='lv', tap_neutral=0, tap_max=16, tap_min=-16, tap_step_percent=0.625, tap_pos=0, tap_phase_shifter=False, name='Regulator 2') # # Substation # pp.create_transformer_from_parameters(net, bus0, bus_800, sn_mva=2.5, vn_hv_kv=69.0, # vn_lv_kv=24.9, vkr_percent=1.0, vk_percent=8.062257, # pfe_kw=0.0, i0_percent=0.0, shift_degree=0.0, # tap_side='lv', tap_neutral=0, tap_max=2, tap_min=-2, # tap_step_percent=2.5, tap_pos=0, tap_phase_shifter=False, # name='Substation') # Traformer pp.create_transformer_from_parameters(net, bus_832, bus_888, sn_mva=0.5, vn_hv_kv=24.9, vn_lv_kv=4.16, vkr_percent=1.9, vk_percent=4.5, pfe_kw=0.0, i0_percent=0.0, shift_degree=0.0, name='Transformer 1') # Loads pp.create_load(net, bus_806, p_mw=0.055, q_mvar=0.029, name='Load 806') pp.create_load(net, bus_810, p_mw=0.016, q_mvar=0.008, name='Load 810') pp.create_load(net, bus_820, p_mw=0.034, q_mvar=0.017, name='Load 820') pp.create_load(net, bus_822, p_mw=0.135, q_mvar=0.070, name='Load 822') pp.create_load(net, bus_824, p_mw=0.005, q_mvar=0.002, name='Load 824') pp.create_load(net, bus_826, p_mw=0.004, q_mvar=0.020, name='Load 826') pp.create_load(net, bus_828, p_mw=0.004, q_mvar=0.002, name='Load 828') pp.create_load(net, bus_830, p_mw=0.007, q_mvar=0.003, name='Load 830') pp.create_load(net, bus_856, p_mw=0.004, q_mvar=0.002, name='Load 856') pp.create_load(net, bus_858, p_mw=0.015, q_mvar=0.007, name='Load 858') pp.create_load(net, bus_864, p_mw=0.002, q_mvar=0.001, name='Load 864') pp.create_load(net, bus_834, p_mw=0.032, q_mvar=0.017, name='Load 834') pp.create_load(net, bus_860, p_mw=0.029, q_mvar=0.073, name='Load 860') pp.create_load(net, bus_836, p_mw=0.082, q_mvar=0.043, name='Load 836') pp.create_load(net, bus_840, p_mw=0.040, q_mvar=0.020, name='Load 840') pp.create_load(net, bus_838, p_mw=0.028, q_mvar=0.014, name='Load 838') pp.create_load(net, bus_844, p_mw=0.009, q_mvar=0.005, name='Load 844') pp.create_load(net, bus_846, p_mw=0.037, q_mvar=0.031, name='Load 846') pp.create_load(net, bus_848, p_mw=0.023, q_mvar=0.011, name='Load 848') pp.create_load(net, bus_860, p_mw=0.060, q_mvar=0.048, name='Load 860 spot') pp.create_load(net, bus_840, p_mw=0.027, q_mvar=0.021, name='Load 840 spot') pp.create_load(net, bus_844, p_mw=0.405, q_mvar=0.315, name='Load 844 spot') pp.create_load(net, bus_848, p_mw=0.060, q_mvar=0.048, name='Load 848 spot') pp.create_load(net, bus_890, p_mw=0.450, q_mvar=0.225, name='Load 890 spot') pp.create_load(net, bus_830, p_mw=0.045, q_mvar=0.020, name='Load 830 spot') # External grid pp.create_ext_grid(net, bus_800, vm_pu=1.0, va_degree=0.0, s_sc_max_mva=10.0, s_sc_min_mva=10.0, rx_max=1, rx_min=1, r0x0_max=1, x0x_max=1) # Distributed generators pp.create_sgen(net, bus_848, p_mw=0.66, q_mvar=0.500, name='DG 1', max_p_mw=0.66, min_p_mw=0, max_q_mvar=0.5, min_q_mvar=0) pp.create_sgen(net, bus_890, p_mw=0.50, q_mvar=0.375, name='DG 2', max_p_mw=0.50, min_p_mw=0, max_q_mvar=0.375, min_q_mvar=0) pp.create_sgen(net, bus_822, p_mw=0.1, type='PV', name='PV 1', max_p_mw=0.1, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_856, p_mw=0.1, type='PV', name='PV 2', max_p_mw=0.1, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_838, p_mw=0.1, type='PV', name='PV 3', max_p_mw=0.1, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_822, p_mw=0.1, type='WP', name='WP 1', max_p_mw=0.1, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_826, p_mw=0.1, type='WP', name='WP 2', max_p_mw=0.1, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) pp.create_sgen(net, bus_838, p_mw=0.1, type='WP', name='WP 3', max_p_mw=0.1, min_p_mw=0, max_q_mvar=0, min_q_mvar=0) # Shunt capacity bank pp.create_shunt(net, bus_840, q_mvar=-0.12, name='SCB 1', step=4, max_step=4) pp.create_shunt(net, bus_864, q_mvar=-0.12, name='SCB 2', step=4, max_step=4) # storage pp.create_storage(net, bus_810, p_mw=0.5, max_e_mwh=2, sn_mva=1.0, soc_percent=50, min_e_mwh=0.2, name='Storage') return net # net = case34() # pp.runpp(net) # print(net.res_bus) # print(net.res_ext_grid) # print(net.trafo) # print(net.res_load['p_mw'].values.sum()) # import numpy as np # import pandas as pd # import pandapower.control as control # import pandapower.networks as nw # import pandapower.timeseries as timeseries # from pandapower.timeseries.data_sources.frame_data import DFData # # number of time steps # n_ts = 95 # # df = pd.read_csv("load_timeseries.csv") # # create a DataFrame with some random time series as an example # df = pd.DataFrame(np.random.normal(1., 0.1, size=(n_ts, len(net.load.index))), # index=list(range(n_ts)), columns=net.load.index) * net.load.p_mw.values # ds = DFData(df) # const_load = control.ConstControl(net, element='load', element_index=net.load.index, # variable='p_mw', data_source=ds, profile_name=net.load.index) # # initialising the outputwriter to save data to excel files in the current folder. You can change this to .json, .csv, or .pickle as well # ow = timeseries.OutputWriter(net, output_path="./", output_file_type=".xlsx") # # adding vm_pu of all buses and line_loading in percent of all lines as outputs to be stored # ow.log_variable('res_bus', 'vm_pu') # ow.log_variable('res_line', 'loading_percent') # # starting the timeseries simulation for one day -> 96 15 min values. # timeseries.run_timeseries(net) # # now checkout the folders res_bus and res_line in your current working dir # # number of time steps # n_ts = 1 # # df = pd.read_csv("load_timeseries.csv") # # create a DataFrame with some random time series as an example # df = pd.DataFrame(np.array([[0,0]]), # index=list(range(n_ts)), columns=net.trafo.index[1:]) # ds = DFData(df) # const_load = control.ConstControl(net, element='trafo', element_index=net.trafo.index[1:], # variable='tap_pos', data_source=ds, profile_name=net.trafo.index[1:]) # # initialising the outputwriter to save data to excel files in the current folder. You can change this to .json, .csv, or .pickle as well # ow = timeseries.OutputWriter(net, output_path="./", output_file_type=".xlsx") # # adding vm_pu of all buses and line_loading in percent of all lines as outputs to be stored # ow.log_variable('res_bus', 'vm_pu') # ow.log_variable('res_line', 'loading_percent') # ow.log_variable('res_trafo', 'tap_pos') # # starting the timeseries simulation for one day -> 96 15 min values. # timeseries.run_timeseries(net) # # now checkout the folders res_bus and res_line in your current working dir
# create load pp.create_load(net, bus7, p_kw=2000, q_kvar=4000, scaling=0.6, name="load") # show load table load = net.load # create static generator pp.create_sgen(net, bus7, p_kw=-2000, q_kvar=500, name="static generator") # show static generator table gen_s = net.sgen # create voltage controlled generator pp.create_gen(net, bus6, p_kw=-6000, max_q_kvar=3000, min_q_kvar=-3000, vm_pu=1.03, name="generator") # show voltage controlled generator table gen_vc = net.gen # create shunt pp.create_shunt(net, bus3, q_kvar=-960, p_kw=0, name='Shunt') # show shunt table shunt = net.shunt
net.gen pp.create_sgen(net, pp.get_element_index(net, "bus", 'Bus SB 5'), p_kw=-20e3, q_kvar=-4e3, sn_kva=45e3, type='WP', name='Wind Park') # show static generator table net.sgen pp.create_shunt(net, pp.get_element_index(net, "bus", 'Bus HV1'), p_kw=0, q_kvar=-960, name='Shunt') # show shunt table net.shunt # Impedance pp.create_impedance(net, pp.get_element_index(net, "bus", 'Bus HV3'), pp.get_element_index(net, "bus", 'Bus HV1'), rft_pu=0.074873, xft_pu=0.198872, sn_kva=100000, name='Impedance')
line_num = getattr(line, "Index") pp.create_line_from_parameters(net,from_bus-1,to_bus-1, length_km=length,r_ohm_per_km=r_ohm_per_km,x_ohm_per_km=x_ohm_per_km, c_nf_per_km=c_nf_per_km,max_i_ka=max_i_ka,name='Line %s' % line_num) '''pp.create_line(net,from_bus-1,to_bus-1,length_km=length,std_type="NAYY 4x50 SE", name='Line %s' % line_num)''' print(net.line) # show line table ### Shunt ### shunts = pd.read_csv('data/Shunt.csv',names=['bus_num','power_rating','voltage_rating','freq_rating', 'conductance','susceptance'],index_col=False) for shunt in shunts.itertuples(index=True, name='Pandas'): bus_num = getattr(shunt, "bus_num") q_mvar = getattr(shunt, "susceptance") shunt_num = getattr(shunt, "Index") pp.create_shunt(net, bus_num-1, p_mw=0, q_mvar=q_mvar, name='Shunt %s' % shunt_num) print(net.shunt) # show shunt table ### Swing ### swings = pd.read_csv('data/SW.csv',names=['bus_num','power_rating','voltage_rating','voltage_mag','ref_angle', 'q_max','q_min','v_max','v_min','p_init','loss_coeff','area','region'],index_col=False) for swing in swings.itertuples(index=True, name='Pandas'): bus_num = getattr(swing, "bus_num") vm_pu = getattr(swing, "voltage_mag") va_degree = getattr(swing, "ref_angle") pp.create_ext_grid(net, bus_num-1, vm_pu=vm_pu, va_degree=va_degree, name='Slack Bus') print(net.ext_grid) # show swing table ### PV ### pvs = pd.read_csv('data/PV.csv',names=['bus_num','power_rating','voltage_rating','active_power','voltage_mag', 'q_max','q_min','v_max','v_min','p_init','loss_coeff'],index_col=False)
def from_ppc(ppc, f_hz=50, validate_conversion=False, **kwargs): """ This function converts pypower case files to pandapower net structure. INPUT: **ppc** : The pypower case file. OPTIONAL: **f_hz** (float, 50) - The frequency of the network. **validate_conversion** (bool, False) - If True, validate_from_ppc is run after conversion. For running the validation, the ppc must already contain the pypower powerflow results or pypower must be importable. ****kwargs** keyword arguments for validate_from_ppc if validate_conversion is True OUTPUT: **net** : pandapower net. EXAMPLE: import pandapower.converter as pc from pypower import case4gs ppc_net = case4gs.case4gs() net = pc.from_ppc(ppc_net, f_hz=60) """ # --- catch common failures if Series(ppc['bus'][:, BASE_KV] <= 0).any(): logger.info('There are false baseKV given in the pypower case file.') # --- general_parameters baseMVA = ppc['baseMVA'] # MVA omega = pi * f_hz # 1/s MAX_VAL = 99999. net = pp.create_empty_network(f_hz=f_hz, sn_mva=baseMVA) # --- bus data -> create buses, sgen, load, shunt for i in range(len(ppc['bus'])): # create buses pp.create_bus(net, name=int(ppc['bus'][i, 0]), vn_kv=ppc['bus'][i, 9], type="b", zone=ppc['bus'][i, 6], in_service=bool(ppc['bus'][i, 1] != 4), max_vm_pu=ppc['bus'][i, 11], min_vm_pu=ppc['bus'][i, 12]) # create sgen, load if ppc['bus'][i, 2] > 0: pp.create_load(net, i, p_mw=ppc['bus'][i, 2], q_mvar=ppc['bus'][i, 3], controllable=False) elif ppc['bus'][i, 2] < 0: pp.create_sgen(net, i, p_mw=-ppc['bus'][i, 2], q_mvar=-ppc['bus'][i, 3], type="", controllable=False) elif ppc['bus'][i, 3] != 0: pp.create_load(net, i, p_mw=ppc['bus'][i, 2], q_mvar=ppc['bus'][i, 3], controllable=False) # create shunt if ppc['bus'][i, 4] != 0 or ppc['bus'][i, 5] != 0: pp.create_shunt(net, i, p_mw=ppc['bus'][i, 4], q_mvar=-ppc['bus'][i, 5]) # unused data of ppc: Vm, Va (partwise: in ext_grid), zone # --- gen data -> create ext_grid, gen, sgen gen_lookup = DataFrame(nan, columns=['element', 'element_type'], index=range(len(ppc['gen'][:, 0]))) # if in ppc is only one gen -> numpy initially uses one dim array -> change to two dim array if len(ppc["gen"].shape) == 1: ppc["gen"] = array(ppc["gen"], ndmin=2) for i in range(len(ppc['gen'][:, 0])): current_bus_type, current_bus_idx, same_bus_gen_idx, first_same_bus_in_service_gen_idx, \ last_same_bus_in_service_gen_idx = _gen_bus_info(ppc, i) # create ext_grid if current_bus_type == 3: if i == first_same_bus_in_service_gen_idx: gen_lookup.element.loc[i] = pp.create_ext_grid( net, bus=current_bus_idx, vm_pu=ppc['gen'][last_same_bus_in_service_gen_idx, 5], va_degree=ppc['bus'][current_bus_idx, 8], in_service=bool(ppc['gen'][i, 7] > 0), max_p_mw=ppc['gen'][i, PMAX], min_p_mw=ppc['gen'][i, PMIN], max_q_mvar=ppc['gen'][i, QMAX], min_q_mvar=ppc['gen'][i, QMIN]) gen_lookup.element_type.loc[i] = 'ext_grid' if ppc['gen'][i, 4] > ppc['gen'][i, 3]: logger.info( 'min_q_mvar of gen %d must be less than max_q_mvar but is not.' % i) if -ppc['gen'][i, 9] < -ppc['gen'][i, 8]: logger.info( 'max_p_mw of gen %d must be less than min_p_mw but is not.' % i) else: current_bus_type = 1 # create gen elif current_bus_type == 2: if i == first_same_bus_in_service_gen_idx: gen_lookup.element.loc[i] = pp.create_gen( net, bus=current_bus_idx, vm_pu=ppc['gen'][last_same_bus_in_service_gen_idx, 5], p_mw=ppc['gen'][i, 1], in_service=bool(ppc['gen'][i, 7] > 0), controllable=True, max_p_mw=ppc['gen'][i, PMAX], min_p_mw=ppc['gen'][i, PMIN], max_q_mvar=ppc['gen'][i, QMAX], min_q_mvar=ppc['gen'][i, QMIN]) gen_lookup.element_type.loc[i] = 'gen' if ppc['gen'][i, 1] < 0: logger.info( 'p_mw of gen %d must be less than zero but is not.' % i) if ppc['gen'][i, 4] > ppc['gen'][i, 3]: logger.info( 'min_q_mvar of gen %d must be less than max_q_mvar but is not.' % i) if -ppc['gen'][i, 9] < -ppc['gen'][i, 8]: logger.info( 'max_p_mw of gen %d must be less than min_p_mw but is not.' % i) else: current_bus_type = 1 # create sgen if current_bus_type == 1: gen_lookup.element.loc[i] = pp.create_sgen( net, bus=current_bus_idx, p_mw=ppc['gen'][i, 1], q_mvar=ppc['gen'][i, 2], type="", in_service=bool(ppc['gen'][i, 7] > 0), max_p_mw=ppc['gen'][i, PMAX], min_p_mw=ppc['gen'][i, PMIN], max_q_mvar=ppc['gen'][i, QMAX], min_q_mvar=ppc['gen'][i, QMIN], controllable=True) gen_lookup.element_type.loc[i] = 'sgen' if ppc['gen'][i, 1] < 0: logger.info( 'p_mw of sgen %d must be less than zero but is not.' % i) if ppc['gen'][i, 4] > ppc['gen'][i, 3]: logger.info( 'min_q_mvar of gen %d must be less than max_q_mvar but is not.' % i) if -ppc['gen'][i, 9] < -ppc['gen'][i, 8]: logger.info( 'max_p_mw of gen %d must be less than min_p_mw but is not.' % i) # unused data of ppc: Vg (partwise: in ext_grid and gen), mBase, Pc1, Pc2, Qc1min, Qc1max, # Qc2min, Qc2max, ramp_agc, ramp_10, ramp_30,ramp_q, apf # --- branch data -> create line, trafo for i in range(len(ppc['branch'])): from_bus = pp.get_element_index(net, 'bus', name=int(ppc['branch'][i, 0])) to_bus = pp.get_element_index(net, 'bus', name=int(ppc['branch'][i, 1])) from_vn_kv = ppc['bus'][from_bus, 9] to_vn_kv = ppc['bus'][to_bus, 9] if (from_vn_kv == to_vn_kv) & ((ppc['branch'][i, 8] == 0) | (ppc['branch'][i, 8] == 1)) & \ (ppc['branch'][i, 9] == 0): # create line Zni = ppc['bus'][to_bus, 9]**2 / baseMVA # ohm max_i_ka = ppc['branch'][i, 5] / ppc['bus'][to_bus, 9] / sqrt(3) if max_i_ka == 0.0: max_i_ka = MAX_VAL logger.debug( "ppc branch rateA is zero -> Using MAX_VAL instead to calculate " + "maximum branch flow") pp.create_line_from_parameters( net, from_bus=from_bus, to_bus=to_bus, length_km=1, r_ohm_per_km=ppc['branch'][i, 2] * Zni, x_ohm_per_km=ppc['branch'][i, 3] * Zni, c_nf_per_km=ppc['branch'][i, 4] / Zni / omega * 1e9 / 2, max_i_ka=max_i_ka, type='ol', max_loading_percent=100, in_service=bool(ppc['branch'][i, 10])) else: # create transformer if from_vn_kv >= to_vn_kv: hv_bus = from_bus vn_hv_kv = from_vn_kv lv_bus = to_bus vn_lv_kv = to_vn_kv tap_side = 'hv' else: hv_bus = to_bus vn_hv_kv = to_vn_kv lv_bus = from_bus vn_lv_kv = from_vn_kv tap_side = 'lv' if from_vn_kv == to_vn_kv: logger.warning( 'The pypower branch %d (from_bus, to_bus)=(%d, %d) is considered' ' as a transformer because of a ratio != 0 | 1 but it connects ' 'the same voltage level', i, ppc['branch'][i, 0], ppc['branch'][i, 1]) rk = ppc['branch'][i, 2] xk = ppc['branch'][i, 3] zk = (rk**2 + xk**2)**0.5 sn = ppc['branch'][i, 5] if sn == 0.0: sn = MAX_VAL logger.debug( "ppc branch rateA is zero -> Using MAX_VAL instead to calculate " + "apparent power") ratio_1 = 0 if ppc['branch'][i, 8] == 0 else (ppc['branch'][i, 8] - 1) * 100 i0_percent = -ppc['branch'][i, 4] * 100 * baseMVA / sn if i0_percent < 0: logger.info( 'A transformer always behaves inductive consumpting but the ' 'susceptance of pypower branch %d (from_bus, to_bus)=(%d, %d) is ' 'positive.', i, ppc['branch'][i, 0], ppc['branch'][i, 1]) pp.create_transformer_from_parameters( net, hv_bus=hv_bus, lv_bus=lv_bus, sn_mva=sn, vn_hv_kv=vn_hv_kv, vn_lv_kv=vn_lv_kv, vk_percent=sign(xk) * zk * sn * 100 / baseMVA, vkr_percent=rk * sn * 100 / baseMVA, max_loading_percent=100, pfe_kw=0, i0_percent=i0_percent, shift_degree=ppc['branch'][i, 9], tap_step_percent=abs(ratio_1) if ratio_1 else nan, tap_pos=sign(ratio_1) if ratio_1 else nan, tap_side=tap_side if ratio_1 else None, tap_neutral=0 if ratio_1 else nan) # unused data of ppc: rateB, rateC # --- gencost -> create polynomial_cost, piecewise_cost if 'gencost' in ppc: if len(ppc['gencost'].shape) == 1: # reshape gencost if only one gencost is given -> no indexError ppc['gencost'] = ppc['gencost'].reshape((1, -1)) if ppc['gencost'].shape[0] <= gen_lookup.shape[0]: idx_p = range(ppc['gencost'].shape[0]) idx_q = [] elif ppc['gencost'].shape[0] > gen_lookup.shape[0]: idx_p = range(gen_lookup.shape[0]) idx_q = range(gen_lookup.shape[0], ppc['gencost'].shape[0]) if ppc['gencost'].shape[0] >= 2 * gen_lookup.shape[0]: idx_p = range(gen_lookup.shape[0]) idx_q = range(gen_lookup.shape[0], 2 * gen_lookup.shape[0]) for idx in idx_p: _create_costs(net, ppc, gen_lookup, 'p', idx) for idx in idx_q: _create_costs(net, ppc, gen_lookup, 'q', idx) # areas are unconverted if validate_conversion: logger.setLevel(logging.DEBUG) if not validate_from_ppc(ppc, net, **kwargs): logger.error("Validation failed.") return net