Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 Station 1", vn_kv=20, type="b")
bus6 = pp.create_bus(net, name="MV Station 2", vn_kv=20, type="b")
bus7 = pp.create_bus(net, name="MV Station 3", vn_kv=20, type="b")
bus8 = pp.create_bus(net, name="MV Station 4", vn_kv=20, type="b")
# create external grid
pp.create_ext_grid(net, bus1, va_degree=20)
# create transformer
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, 0.225, std_type="N2XS(FL)2Y 1x300 RM/35 64/110 kV",
name="Line 1")
line2 = pp.create_line(net, bus5, bus6, 0.075, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
name="Line 2")
line3 = pp.create_line(net, bus5, bus7, 0.125, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
name="Line 3")
line4 = pp.create_line(net, bus5, bus8, 0.175, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
name="Line 4")
# create switches
# (Circuit breaker)
pp.create_switch(net, bus2, bus3, et="b", type="CB")
pp.create_switch(net, bus4, bus5, et="b", type="CB")
# (Load break switches)
pp.create_switch(net, bus5, line2, et="l", type="LBS")
pp.create_switch(net, bus6, line2, et="l", type="LBS")
pp.create_switch(net, bus5, line3, et="l", type="LBS")
Loads will only be added if p_load_mw or q_load_mvar \
is assigned
The branch number could be assigned with branchnr. It will be added to \
the name ti keep track on the node position
"""
startpoint_bus = 1
startpoint_line = 1
bus_before = startbusnr
for i in list(range(n_lines)):
buscounter = startpoint_bus + i
linecounter = startpoint_line + i
created_bus_nr = pp.create_bus(pd_net, name="bus_%d_%d" % (branchnr, buscounter), vn_kv=.4)
pp.create_line(pd_net, bus_before, created_bus_nr, length_km=length_per_line,
name="line_%d_%d" % (branchnr, linecounter), std_type=std_type)
if p_load_mw or q_load_mvar:
pp.create_load(pd_net, created_bus_nr, p_mw=p_load_mw, q_mvar=q_load_mvar)
bus_before = created_bus_nr # rueckgefuehrter Wert in der Schleife
return pd_net
#create_load
pp.create_load(net, bus=b3, p_kw=100, q_kvar=50, name="Load")
tid = pp.create_transformer(net, hv_bus=b1, lv_bus=b2, std_type="0.4 MVA 20/0.4 kV")
#tid = pp.create_transformer_from_parameters(net,
# hv_bus=b1,
# lv_bus=b2,
# sn_kva=400.,
# vn_hv_kv=20.,
# vn_lv_kv=0.4,
# vsc_percent=6.,
# vscr_percent=1.425,
# i0_percent=0.3375,
# pfe_kw=1.35)
#create line by standard type
lid = pp.create_line(net, from_bus=b2, to_bus=b3, length_km=0.1,
std_type="NAYY 4x50 SE", name="Line")
#run loadflow
pp.runpp(net)
#print element tables
print("-------------------")
print(" ELEMENT TABLES ")
print("-------------------")
print("net.bus")
print(net.bus)
print("\n net.trafo")
print(net.trafo)
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_mva=1000,
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
pp.create_transformer(net, bus3, bus4, name="110kV/20kV transformer",
std_type="25 MVA 110/20 kV")
# create lines
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
pp.create_switch(net, bus2, bus3, et="b", type="CB")
pp.create_switch(net, bus4, bus5, et="b", type="CB")
# create bus-line switches
pp.create_switch(net, bus5, line2, et="l", type="LBS", closed=True)
pp.create_switch(net, bus6, line2, et="l", type="LBS", closed=True)
pp.create_switch(net, bus6, line3, et="l", type="LBS", closed=True)
pp.create_switch(net, bus7, line3, et="l", type="LBS", closed=False)
pp.create_switch(net, bus7, line4, et="l", type="LBS", closed=True)
name='Line R13-R14')
pp.create_line(net_cigre_lv, busR14, busR15, length_km=0.030, std_type='UG3',
name='Line R14-R15')
pp.create_line(net_cigre_lv, busR6, busR16, length_km=0.030, std_type='UG3',
name='Line R6-R16')
pp.create_line(net_cigre_lv, busR9, busR17, length_km=0.030, std_type='UG3',
name='Line R9-R17')
pp.create_line(net_cigre_lv, busR10, busR18, length_km=0.030, std_type='UG3',
name='Line R10-R18')
pp.create_line(net_cigre_lv, busI1, busI2, length_km=0.2, std_type='UG2',
name='Line I1-I2')
pp.create_line(net_cigre_lv, busC1, busC2, length_km=0.030, std_type='OH1',
name='Line C1-C2')
pp.create_line(net_cigre_lv, busC2, busC3, length_km=0.030, std_type='OH1',
name='Line C2-C3')
pp.create_line(net_cigre_lv, busC3, busC4, length_km=0.030, std_type='OH1',
name='Line C3-C4')
pp.create_line(net_cigre_lv, busC4, busC5, length_km=0.030, std_type='OH1',
name='Line C4-C5')
pp.create_line(net_cigre_lv, busC5, busC6, length_km=0.030, std_type='OH1',
name='Line C5-C6')
pp.create_line(net_cigre_lv, busC6, busC7, length_km=0.030, std_type='OH1',
name='Line C6-C7')
pp.create_line(net_cigre_lv, busC7, busC8, length_km=0.030, std_type='OH1',
name='Line C7-C8')
pp.create_line(net_cigre_lv, busC8, busC9, length_km=0.030, std_type='OH1',
name='Line C8-C9')
pp.create_line(net_cigre_lv, busC3, busC10, length_km=0.030, std_type='OH2',
name='Line C3-C10')
pp.create_line(net_cigre_lv, busC10, busC11, length_km=0.030, std_type='OH2',
name='Line R9-R10')
pp.create_line(net_cigre_lv, busR3, busR11, length_km=0.030, std_type='UG3',
name='Line R3-R11')
pp.create_line(net_cigre_lv, busR4, busR12, length_km=0.035, std_type='UG3',
name='Line R4-R12')
pp.create_line(net_cigre_lv, busR12, busR13, length_km=0.035, std_type='UG3',
name='Line R12-R13')
pp.create_line(net_cigre_lv, busR13, busR14, length_km=0.035, std_type='UG3',
name='Line R13-R14')
pp.create_line(net_cigre_lv, busR14, busR15, length_km=0.030, std_type='UG3',
name='Line R14-R15')
pp.create_line(net_cigre_lv, busR6, busR16, length_km=0.030, std_type='UG3',
name='Line R6-R16')
pp.create_line(net_cigre_lv, busR9, busR17, length_km=0.030, std_type='UG3',
name='Line R9-R17')
pp.create_line(net_cigre_lv, busR10, busR18, length_km=0.030, std_type='UG3',
name='Line R10-R18')
pp.create_line(net_cigre_lv, busI1, busI2, length_km=0.2, std_type='UG2',
name='Line I1-I2')
pp.create_line(net_cigre_lv, busC1, busC2, length_km=0.030, std_type='OH1',
name='Line C1-C2')
pp.create_line(net_cigre_lv, busC2, busC3, length_km=0.030, std_type='OH1',
name='Line C2-C3')
pp.create_line(net_cigre_lv, busC3, busC4, length_km=0.030, std_type='OH1',
name='Line C3-C4')
pp.create_line(net_cigre_lv, busC4, busC5, length_km=0.030, std_type='OH1',
name='Line C4-C5')
pp.create_line(net_cigre_lv, busC5, busC6, length_km=0.030, std_type='OH1',
name='Line C5-C6')
pp.create_line(net_cigre_lv, busC6, busC7, length_km=0.030, std_type='OH1',
def createSampleNetwork():
net = pp.create_empty_network()
b1 = pp.create_bus(net, vn_kv=20., name="HV", geodata=(5, 30))
b2 = pp.create_bus(net, vn_kv=0.4, name="MV", geodata=(5, 28))
b3 = pp.create_bus(net, vn_kv=0.4, name="Load Bus", geodata=(5, 22))
#create bus elements
pp.create_ext_grid(net, bus=b1, vm_pu=1.02, name="Grid Connection")
pp.create_load(net, bus=b3, p_kw=100, q_kvar=50, 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")
return net
std_type='CABLE_CIGRE_MV', name='Line 4-5')
pp.create_line(net_cigre_mv, buses[4], buses[5], length_km=1.54,
std_type='CABLE_CIGRE_MV', name='Line 5-6')
pp.create_line(net_cigre_mv, buses[6], buses[7], length_km=1.67,
std_type='CABLE_CIGRE_MV', name='Line 7-8')
pp.create_line(net_cigre_mv, buses[7], buses[8], length_km=0.32,
std_type='CABLE_CIGRE_MV', name='Line 8-9')
pp.create_line(net_cigre_mv, buses[8], buses[9], length_km=0.77,
std_type='CABLE_CIGRE_MV', name='Line 9-10')
pp.create_line(net_cigre_mv, buses[9], buses[10], length_km=0.33,
std_type='CABLE_CIGRE_MV', name='Line 10-11')
pp.create_line(net_cigre_mv, buses[2], buses[7], length_km=1.3,
std_type='CABLE_CIGRE_MV', name='Line 3-8')
pp.create_line(net_cigre_mv, buses[11], buses[12], length_km=4.89,
std_type='OHL_CIGRE_MV', name='Line 12-13')
pp.create_line(net_cigre_mv, buses[12], buses[13], length_km=2.99,
std_type='OHL_CIGRE_MV', name='Line 13-14')
line6_7 = pp.create_line(net_cigre_mv, buses[5], buses[6], length_km=0.24,
std_type='CABLE_CIGRE_MV', name='Line 6-7')
line4_11 = pp.create_line(net_cigre_mv, buses[10], buses[3], length_km=0.49,
std_type='CABLE_CIGRE_MV', name='Line 11-4')
line8_14 = pp.create_line(net_cigre_mv, buses[13], buses[7], length_km=2.,
std_type='OHL_CIGRE_MV', name='Line 14-8')
# Ext-Grid
pp.create_ext_grid(net_cigre_mv, bus0, vm_pu=1.03, va_degree=0.,
s_sc_max_mva=5000, s_sc_min_mva=5000, rx_max=0.1, rx_min=0.1)
# Trafos
trafo0 = pp.create_transformer_from_parameters(net_cigre_mv, bus0, buses[0], sn_mva=25,
vn_hv_kv=110, vn_lv_kv=20, vscr_percent=0.16,
name='Line R10-R18')
pp.create_line(net_cigre_lv, busI1, busI2, length_km=0.2, std_type='UG2',
name='Line I1-I2')
pp.create_line(net_cigre_lv, busC1, busC2, length_km=0.030, std_type='OH1',
name='Line C1-C2')
pp.create_line(net_cigre_lv, busC2, busC3, length_km=0.030, std_type='OH1',
name='Line C2-C3')
pp.create_line(net_cigre_lv, busC3, busC4, length_km=0.030, std_type='OH1',
name='Line C3-C4')
pp.create_line(net_cigre_lv, busC4, busC5, length_km=0.030, std_type='OH1',
name='Line C4-C5')
pp.create_line(net_cigre_lv, busC5, busC6, length_km=0.030, std_type='OH1',
name='Line C5-C6')
pp.create_line(net_cigre_lv, busC6, busC7, length_km=0.030, std_type='OH1',
name='Line C6-C7')
pp.create_line(net_cigre_lv, busC7, busC8, length_km=0.030, std_type='OH1',
name='Line C7-C8')
pp.create_line(net_cigre_lv, busC8, busC9, length_km=0.030, std_type='OH1',
name='Line C8-C9')
pp.create_line(net_cigre_lv, busC3, busC10, length_km=0.030, std_type='OH2',
name='Line C3-C10')
pp.create_line(net_cigre_lv, busC10, busC11, length_km=0.030, std_type='OH2',
name='Line C10-C11')
pp.create_line(net_cigre_lv, busC11, busC12, length_km=0.030, std_type='OH3',
name='Line C11-C12')
pp.create_line(net_cigre_lv, busC11, busC13, length_km=0.030, std_type='OH3',
name='Line C11-C13')
pp.create_line(net_cigre_lv, busC10, busC14, length_km=0.030, std_type='OH3',
name='Line C10-C14')
pp.create_line(net_cigre_lv, busC5, busC15, length_km=0.030, std_type='OH2',