Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_pandapower_case():
#more complicated examples like
#net = pandapower.networks.example_simple()
#can be used once the import of e.g. switches is perfected
#create empty net
net = pp.create_empty_network()
#create buses
b1 = pp.create_bus(net, vn_kv=20., name="Bus 1")
b2 = pp.create_bus(net, vn_kv=0.4, name="Bus 2")
b3 = pp.create_bus(net, vn_kv=0.4, name="Bus 3")
#create bus elements
pp.create_ext_grid(net, bus=b1, vm_pu=1.02, name="Grid Connection")
pp.create_load(net, bus=b3, p_mw=0.1, q_mvar=0.05, name="Load")
#create branch elements
tid = pp.create_transformer(net, hv_bus=b1, lv_bus=b2, std_type="0.4 MVA 20/0.4 kV",
name="Trafo")
pp.create_line(net, from_bus=b2, to_bus=b3, length_km=0.1, name="Line",
std_type="NAYY 4x50 SE")
#because of phase angles, need to init with DC
pp.runpp(net,calculate_voltage_angles=True, init="dc")
"""
This function creates a simple ten bus system with four radial low voltage nodes connected to \
a medium voltage slack bus. At every of the four radial low voltage nodes another low voltage \
node with a load is connected via cable.
OUTPUT:
**net** - Returns the required four load system with branches
EXAMPLE:
import pandapower.networks as pn
net_four_load_with_branches = pn.four_loads_with_branches_out()
"""
pd_net = pp.create_empty_network()
busnr1 = pp.create_bus(pd_net, name="bus1ref", vn_kv=10.)
pp.create_ext_grid(pd_net, busnr1)
busnr2 = pp.create_bus(pd_net, name="bus2", vn_kv=.4)
pp.create_transformer(pd_net, busnr1, busnr2, std_type="0.25 MVA 10/0.4 kV")
busnr3 = pp.create_bus(pd_net, name="bus3", vn_kv=.4)
pp.create_line(pd_net, busnr2, busnr3, name="line1", length_km=0.05,
std_type="NAYY 4x120 SE")
busnr4 = pp.create_bus(pd_net, name="bus4", vn_kv=.4)
pp.create_line(pd_net, busnr3, busnr4, name="line2", length_km=0.05,
std_type="NAYY 4x120 SE")
busnr5 = pp.create_bus(pd_net, name="bus5", vn_kv=.4)
pp.create_line(pd_net, busnr4, busnr5, name="line3", length_km=0.05,
std_type="NAYY 4x120 SE")
busnr6 = pp.create_bus(pd_net, name="bus6", vn_kv=.4)
pp.create_line(pd_net, busnr5, busnr6, name="line4", length_km=0.05,
std_type="NAYY 4x120 SE")
busnr7 = pp.create_bus(pd_net, name="bus7", vn_kv=.4)
self.last_bus = None
self.update_line_collection()
self.draw_collections()
if self.Trafo.isChecked():
if self.last_bus is None:
self.last_bus = idx
elif self.last_bus != idx:
pp.create_transformer(self.net, self.last_bus, idx, std_type="0.25 MVA 10/0.4 kV")
self.last_bus = None
self.update_trafo_collections()
self.draw_collections()
if __name__ == '__main__':
net = pp.create_empty_network()
b1 = pp.create_bus(net, 10, geodata=(5,10))
b2 = pp.create_bus(net, 0.4, geodata=(5,15))
b3 = pp.create_bus(net, 0.4, geodata=(0,22))
b4 = pp.create_bus(net, 0.4, geodata=(8, 20))
pp.create_line(net, b2, b3, 2.0, std_type="NAYY 4x50 SE")
pp.create_line(net, b2, b4, 2.0, std_type="NAYY 4x50 SE")
pp.create_transformer(net, b1, b2, std_type="0.63 MVA 10/0.4 kV")
app = QApplication(sys.argv)
ex = NetworkBuilder(net)
#self = ex
# self.redraw_collections()
ex.show()
sys.exit(app.exec_())
# main(net)
busR18 = pp.create_bus(net_cigre_lv, name='Bus R18', vn_kv=0.4, type='m', zone='CIGRE_LV')
busI0 = pp.create_bus(net_cigre_lv, name='Bus I0', vn_kv=20.0, type='b', zone='CIGRE_LV')
busI1 = pp.create_bus(net_cigre_lv, name='Bus I1', vn_kv=0.4, type='b', zone='CIGRE_LV')
busI2 = pp.create_bus(net_cigre_lv, name='Bus I2', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC0 = pp.create_bus(net_cigre_lv, name='Bus C0', vn_kv=20.0, type='b', zone='CIGRE_LV')
busC1 = pp.create_bus(net_cigre_lv, name='Bus C1', vn_kv=0.4, type='b', zone='CIGRE_LV')
busC2 = pp.create_bus(net_cigre_lv, name='Bus C2', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC3 = pp.create_bus(net_cigre_lv, name='Bus C3', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC4 = pp.create_bus(net_cigre_lv, name='Bus C4', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC5 = pp.create_bus(net_cigre_lv, name='Bus C5', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC6 = pp.create_bus(net_cigre_lv, name='Bus C6', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC7 = pp.create_bus(net_cigre_lv, name='Bus C7', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC8 = pp.create_bus(net_cigre_lv, name='Bus C8', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC9 = pp.create_bus(net_cigre_lv, name='Bus C9', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC10 = pp.create_bus(net_cigre_lv, name='Bus C10', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC11 = pp.create_bus(net_cigre_lv, name='Bus C11', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC12 = pp.create_bus(net_cigre_lv, name='Bus C12', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC13 = pp.create_bus(net_cigre_lv, name='Bus C13', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC14 = pp.create_bus(net_cigre_lv, name='Bus C14', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC15 = pp.create_bus(net_cigre_lv, name='Bus C15', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC16 = pp.create_bus(net_cigre_lv, name='Bus C16', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC17 = pp.create_bus(net_cigre_lv, name='Bus C17', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC18 = pp.create_bus(net_cigre_lv, name='Bus C18', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC19 = pp.create_bus(net_cigre_lv, name='Bus C19', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC20 = pp.create_bus(net_cigre_lv, name='Bus C20', vn_kv=0.4, type='m', zone='CIGRE_LV')
# Lines
pp.create_line(net_cigre_lv, busR1, busR2, length_km=0.035, std_type='UG1',
name='Line R1-R2')
pp.create_line(net_cigre_lv, busR2, busR3, length_km=0.035, std_type='UG1',
pp.create_std_type(net=pd_net, data=NAYY4x50, name="NAYY 4x50", element="line")
pp.create_std_type(net=pd_net, data=NAYY4x150, name="NAYY 4x150", element="line")
pp.create_std_type(net=pd_net, data=NAYY4x185, name="NAYY 4x185", element="line")
pp.create_std_type(net=pd_net, data=NYY4x35, name="NYY 4x35", element="line")
T100kVA = {"sn_mva": 0.100, "vn_hv_kv": 10, "vn_lv_kv": 0.4, "vk_percent": 4,
"vkr_percent": 1.2, "pfe_kw": 0.45, "i0_percent": 0.25, "shift_degree": 150,
"vector_group": "Dyn5"}
T160kVA = {"sn_mva": 0.160, "vn_hv_kv": 10, "vn_lv_kv": 0.4, "vk_percent": 4,
"vkr_percent": 1.2, "pfe_kw": 0.38, "i0_percent": 0.26, "shift_degree": 150,
"vector_group": "Dyn5"}
pp.create_std_type(net=pd_net, data=T100kVA, name="0.1 MVA 10/0.4 kV", element="trafo")
pp.create_std_type(net=pd_net, data=T160kVA, name="0.16 MVA 10/0.4 kV", element="trafo")
busnr1 = pp.create_bus(pd_net, name="Trafostation_OS", vn_kv=V_OS)
pp.create_ext_grid(pd_net, bus=busnr1)
main_busbar_nr = pp.create_bus(pd_net, name="main_busbar", vn_kv=V_US, type="b")
pp.create_transformer(pd_net, hv_bus=busnr1, lv_bus=main_busbar_nr, std_type=trafotype,
name="trafo 1")
return pd_net, main_busbar_nr
"""
# --- 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])
busC1 = pp.create_bus(net_cigre_lv, name='Bus C1', vn_kv=0.4, type='b', zone='CIGRE_LV')
busC2 = pp.create_bus(net_cigre_lv, name='Bus C2', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC3 = pp.create_bus(net_cigre_lv, name='Bus C3', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC4 = pp.create_bus(net_cigre_lv, name='Bus C4', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC5 = pp.create_bus(net_cigre_lv, name='Bus C5', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC6 = pp.create_bus(net_cigre_lv, name='Bus C6', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC7 = pp.create_bus(net_cigre_lv, name='Bus C7', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC8 = pp.create_bus(net_cigre_lv, name='Bus C8', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC9 = pp.create_bus(net_cigre_lv, name='Bus C9', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC10 = pp.create_bus(net_cigre_lv, name='Bus C10', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC11 = pp.create_bus(net_cigre_lv, name='Bus C11', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC12 = pp.create_bus(net_cigre_lv, name='Bus C12', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC13 = pp.create_bus(net_cigre_lv, name='Bus C13', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC14 = pp.create_bus(net_cigre_lv, name='Bus C14', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC15 = pp.create_bus(net_cigre_lv, name='Bus C15', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC16 = pp.create_bus(net_cigre_lv, name='Bus C16', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC17 = pp.create_bus(net_cigre_lv, name='Bus C17', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC18 = pp.create_bus(net_cigre_lv, name='Bus C18', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC19 = pp.create_bus(net_cigre_lv, name='Bus C19', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC20 = pp.create_bus(net_cigre_lv, name='Bus C20', vn_kv=0.4, type='m', zone='CIGRE_LV')
# Lines
pp.create_line(net_cigre_lv, busR1, busR2, length_km=0.035, std_type='UG1',
name='Line R1-R2')
pp.create_line(net_cigre_lv, busR2, busR3, length_km=0.035, std_type='UG1',
name='Line R2-R3')
pp.create_line(net_cigre_lv, busR3, busR4, length_km=0.035, std_type='UG1',
name='Line R3-R4')
pp.create_line(net_cigre_lv, busR4, busR5, length_km=0.035, std_type='UG1',
name='Line R4-R5')
pp.create_line(net_cigre_lv, busR5, busR6, length_km=0.035, std_type='UG1',
name='Line R5-R6')
#In per Unit
Vabc_pq_pf_pu = np.divide(Vabc_pq_pf,V_base)
V012_pq_pf_pu = phase_to_sequence(Vabc_pq_pf_pu)
# =============================================================================
# Calculated Power from V_PowerFactory x conj( I_PowerFactory)
# =============================================================================
Sabc_pq_pf_pu = np.multiply(Vabc_pq_pf_pu,Iabc_pq_pf_pu.conjugate())
Sabc_sl_pf_pu = np.multiply(Vabc_sl_pf_pu,Iabc_sl_pf_pu.conjugate())
# =============================================================================
# Y Bus formation for Network
# =============================================================================
net = pp.create_empty_network(sn_kva = kVA_base )
busn = pp.create_bus(net, vn_kv = V_base, name = "busn")
busk = pp.create_bus(net, vn_kv = V_base, name = "busk")
busm = pp.create_bus(net, vn_kv = V_base, name = "busm")
busp = pp.create_bus(net, vn_kv = V_base, name = "busp")
pp.create_ext_grid(net, bus=busn, vm_pu=1.0, name="Grid Connection", s_sc_max_mva=5000/3, rx_max=0.1)
net.ext_grid["r0x0_max"] = 0.1
net.ext_grid["x0x_max"] = 1.0
pp.create_std_type(net, {"r0_ohm_per_km": 0.0848, "x0_ohm_per_km": 0.4649556, "c0_nf_per_km": 230.6,
"max_i_ka": 0.963, "r_ohm_per_km": 0.0212, "x_ohm_per_km": 0.1162389,
"c_nf_per_km": 230}, "example_type1")
pp.create_std_type(net, {"r0_ohm_per_km" : .3048, "x0_ohm_per_km" : 0.6031856,
"c0_nf_per_km" : 140.3, "max_i_ka": 0.531,
"r_ohm_per_km" : .0762, "x_ohm_per_km" : 0.1507964
, "c_nf_per_km" : 140}, "example_type2")
pp.create_std_type(net, {"r0_ohm_per_km" : .154, "x0_ohm_per_km" : 0.5277876
, "c0_nf_per_km" : 170.4, "max_i_ka": 0.741,
"r_ohm_per_km" : .0385, "x_ohm_per_km" : 0.1319469
busR14 = pp.create_bus(net_cigre_lv, name='Bus R14', vn_kv=0.4, type='m', zone='CIGRE_LV')
busR15 = pp.create_bus(net_cigre_lv, name='Bus R15', vn_kv=0.4, type='m', zone='CIGRE_LV')
busR16 = pp.create_bus(net_cigre_lv, name='Bus R16', vn_kv=0.4, type='m', zone='CIGRE_LV')
busR17 = pp.create_bus(net_cigre_lv, name='Bus R17', vn_kv=0.4, type='m', zone='CIGRE_LV')
busR18 = pp.create_bus(net_cigre_lv, name='Bus R18', vn_kv=0.4, type='m', zone='CIGRE_LV')
busI0 = pp.create_bus(net_cigre_lv, name='Bus I0', vn_kv=20.0, type='b', zone='CIGRE_LV')
busI1 = pp.create_bus(net_cigre_lv, name='Bus I1', vn_kv=0.4, type='b', zone='CIGRE_LV')
busI2 = pp.create_bus(net_cigre_lv, name='Bus I2', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC0 = pp.create_bus(net_cigre_lv, name='Bus C0', vn_kv=20.0, type='b', zone='CIGRE_LV')
busC1 = pp.create_bus(net_cigre_lv, name='Bus C1', vn_kv=0.4, type='b', zone='CIGRE_LV')
busC2 = pp.create_bus(net_cigre_lv, name='Bus C2', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC3 = pp.create_bus(net_cigre_lv, name='Bus C3', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC4 = pp.create_bus(net_cigre_lv, name='Bus C4', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC5 = pp.create_bus(net_cigre_lv, name='Bus C5', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC6 = pp.create_bus(net_cigre_lv, name='Bus C6', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC7 = pp.create_bus(net_cigre_lv, name='Bus C7', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC8 = pp.create_bus(net_cigre_lv, name='Bus C8', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC9 = pp.create_bus(net_cigre_lv, name='Bus C9', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC10 = pp.create_bus(net_cigre_lv, name='Bus C10', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC11 = pp.create_bus(net_cigre_lv, name='Bus C11', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC12 = pp.create_bus(net_cigre_lv, name='Bus C12', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC13 = pp.create_bus(net_cigre_lv, name='Bus C13', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC14 = pp.create_bus(net_cigre_lv, name='Bus C14', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC15 = pp.create_bus(net_cigre_lv, name='Bus C15', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC16 = pp.create_bus(net_cigre_lv, name='Bus C16', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC17 = pp.create_bus(net_cigre_lv, name='Bus C17', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC18 = pp.create_bus(net_cigre_lv, name='Bus C18', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC19 = pp.create_bus(net_cigre_lv, name='Bus C19', vn_kv=0.4, type='m', zone='CIGRE_LV')
busC20 = pp.create_bus(net_cigre_lv, name='Bus C20', vn_kv=0.4, type='m', zone='CIGRE_LV')