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_capacitor(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 update_pandapower( self, net: pandapowerNet, name: str, bus: str, ): """Update a pandapower model by adding the capacitor itself. Args: net: a pandapower network model. name: name of the external grid. bus: the bus to which the external grid is attached. """ bus_idx = pp.get_element_index(net, "bus", bus) pp.create_shunt_as_capacitor( net, name=name, bus=bus_idx, q_mvar=self.q_mvar, loss_factor=self.loss_factor, )
def test_convenience_create_functions(): net = pp.create_empty_network() b1 = pp.create_bus(net, 110.) b2 = pp.create_bus(net, 110.) b3 = pp.create_bus(net, 20) pp.create_ext_grid(net, b1) pp.create_line_from_parameters(net, b1, b2, length_km=20., r_ohm_per_km=0.0487, x_ohm_per_km=0.1382301, c_nf_per_km=160., max_i_ka=0.664) l0 = pp.create_load_from_cosphi(net, b2, 10, 0.95, "underexcited", name="load") pp.runpp(net, init="flat") assert net.load.p_mw.at[l0] == 9.5 assert net.load.q_mvar.at[l0] > 0 assert np.sqrt(net.load.p_mw.at[l0] ** 2 + net.load.q_mvar.at[l0] ** 2) == 10 assert np.isclose(net.res_bus.vm_pu.at[b2], 0.99990833838) assert net.load.name.at[l0] == "load" sh0 = pp.create_shunt_as_capacitor(net, b2, 10, loss_factor=0.01, name="shunt") pp.runpp(net, init="flat") assert np.isclose(net.res_shunt.q_mvar.at[sh0], -10.043934174) assert np.isclose(net.res_shunt.p_mw.at[sh0], 0.10043933665) assert np.isclose(net.res_bus.vm_pu.at[b2], 1.0021942964) assert net.shunt.name.at[sh0] == "shunt" sg0 = pp.create_sgen_from_cosphi(net, b2, 5, 0.95, "overexcited", name="sgen") pp.runpp(net, init="flat") assert np.sqrt(net.sgen.p_mw.at[sg0] ** 2 + net.sgen.q_mvar.at[sg0] ** 2) == 5 assert net.sgen.p_mw.at[sg0] == 4.75 assert net.sgen.q_mvar.at[sg0] > 0 assert np.isclose(net.res_bus.vm_pu.at[b2], 1.0029376578) assert net.sgen.name.at[sg0] == "sgen" tol = 1e-6 base_z = 110 ** 2 / 100 sind = pp.create_series_reactor_as_impedance(net, b1, b2, r_ohm=100, x_ohm=200, sn_mva=100) assert net.impedance.at[sind, 'rft_pu'] - 100 / base_z < tol assert net.impedance.at[sind, 'xft_pu'] - 200 / base_z < tol tid = pp.create_transformer_from_parameters(net, hv_bus=b2, lv_bus=b3, sn_mva=0.1, vn_hv_kv=110, vn_lv_kv=20, vkr_percent=5, vk_percent=20, pfe_kw=1, i0_percent=1) pp.create_load(net, b3, 0.1) assert net.trafo.at[tid, 'df'] == 1 pp.runpp(net) tr_l = net.res_trafo.at[tid, 'loading_percent'] net.trafo.at[tid, 'df'] = 2 pp.runpp(net) tr_l_2 = net.res_trafo.at[tid, 'loading_percent'] assert tr_l == tr_l_2 * 2 net.trafo.at[tid, 'df'] = 0 with pytest.raises(UserWarning): pp.runpp(net)
def create_network(): network = pp.create_empty_network() sn_vn_transformer_data = { "sn_mva": 1, "vn_hv_kv": 20, "vn_lv_kv": 0.4, "vk_percent": 5, "vkr_percent": 1.1, "pfe_kw": 1.95, "i0_percent": 0.27, "shift_degree": 0 } pp.create_std_type(network, sn_vn_transformer_data, "SN/NN 1MVA", element='trafo') slack_bus = pp.create_bus(network, vn_kv=110, name="Slack Bus") busNodes = [] lowVoltageBusNodes = [] pp.create_ext_grid(network, bus=slack_bus, vm_pu=1.01, name="Grid Connection") mediumVoltageBusNode = pp.create_bus(network, vn_kv=20, name="MV slack side") pp.create_transformer(network, hv_bus=slack_bus, lv_bus=mediumVoltageBusNode, std_type="40 MVA 110/20 kV", name="VN/SN Transformer") for i in range(0, 100): busNodes.append( pp.create_bus(network, vn_kv=20, name="Bus_" + str(i + 1))) lowVoltageBusNodes.append( pp.create_bus(network, vn_kv=0.4, name="LowVoltageBus_" + str(i + 1))) pp.create_load(network, bus=lowVoltageBusNodes[i], p_mw=0.14, q_mvar=0.05, name="Load_" + str(i + 1)) pp.create_transformer(network, hv_bus=busNodes[i], lv_bus=lowVoltageBusNodes[i], std_type="SN/NN 1MVA", name="Transformer_" + str(i + 1)) pp.create_line(network, from_bus=mediumVoltageBusNode, to_bus=busNodes[0], length_km=0.2, name="Line_0", std_type="NA2XS2Y 1x150 RM/25 12/20 kV") for i in range(0, 99): pp.create_line(network, from_bus=busNodes[i], to_bus=busNodes[i + 1], length_km=0.6, name="Line_" + str(i + 1), std_type="NA2XS2Y 1x150 RM/25 12/20 kV") # Add capacitors with regulating switches pp.create_bus(network, vn_kv=20, name="Bus_Cap1") pp.create_switch(network, pp.get_element_index(network, "bus", 'Bus_13'), pp.get_element_index(network, "bus", 'Bus_Cap1'), et="b", closed=False, type="LBS", name="CapSwitch1") pp.create_shunt_as_capacitor(network, pp.get_element_index(network, "bus", 'Bus_Cap1'), 0.125, 0, name="Cap1") pp.create_bus(network, vn_kv=20, name="Bus_Cap2") pp.create_switch(network, pp.get_element_index(network, "bus", 'Bus_39'), pp.get_element_index(network, "bus", 'Bus_Cap2'), et="b", closed=False, type="LBS", name="CapSwitch2") pp.create_shunt_as_capacitor(network, pp.get_element_index(network, "bus", 'Bus_Cap2'), 0.8, 0, name="Cap2") pp.create_bus(network, vn_kv=20, name="Bus_Cap3") pp.create_switch(network, pp.get_element_index(network, "bus", 'Bus_85'), pp.get_element_index(network, "bus", 'Bus_Cap3'), et="b", closed=False, type="LBS", name="CapSwitch3") pp.create_shunt_as_capacitor(network, pp.get_element_index(network, "bus", 'Bus_Cap3'), 0.125, 0, name="Cap3") pp.create_bus(network, vn_kv=20, name="Bus_Cap4") pp.create_switch(network, pp.get_element_index(network, "bus", 'Bus_28'), pp.get_element_index(network, "bus", 'Bus_Cap4'), et="b", closed=False, type="LBS", name="CapSwitch4") pp.create_shunt_as_capacitor(network, pp.get_element_index(network, "bus", 'Bus_Cap4'), 3, 0, name="Cap4") pp.create_bus(network, vn_kv=20, name="Bus_Cap5") pp.create_switch(network, pp.get_element_index(network, "bus", 'Bus_59'), pp.get_element_index(network, "bus", 'Bus_Cap5'), et="b", closed=False, type="LBS", name="CapSwitch5") pp.create_shunt_as_capacitor(network, pp.get_element_index(network, "bus", 'Bus_Cap5'), 0.25, 0, name="Cap5") pp.create_bus(network, vn_kv=20, name="Bus_Cap6") pp.create_switch(network, pp.get_element_index(network, "bus", 'Bus_70'), pp.get_element_index(network, "bus", 'Bus_Cap6'), et="b", closed=False, type="LBS", name="CapSwitch6") pp.create_shunt_as_capacitor(network, pp.get_element_index(network, "bus", 'Bus_Cap6'), 0.8, 0, name="Cap6") pp.create_bus(network, vn_kv=20, name="Bus_Cap7") pp.create_switch(network, pp.get_element_index(network, "bus", 'Bus_48'), pp.get_element_index(network, "bus", 'Bus_Cap7'), et="b", closed=False, type="LBS", name="CapSwitch7") pp.create_shunt_as_capacitor(network, pp.get_element_index(network, "bus", 'Bus_Cap7'), 0.25, 0, name="Cap7") pp.create_bus(network, vn_kv=20, name="Bus_Cap8") pp.create_switch(network, pp.get_element_index(network, "bus", 'Bus_95'), pp.get_element_index(network, "bus", 'Bus_Cap8'), et="b", closed=False, type="LBS", name="CapSwitch8") pp.create_shunt_as_capacitor(network, pp.get_element_index(network, "bus", 'Bus_Cap8'), 0.25, 0, name="Cap8") return network
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_capacitor(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)