Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
pp.create_line(pd_net, busnr3, busnr7, name="line5", length_km=0.05,
# old ext_grid -> gen
j = 0
for i in ext_grid_idx:
ext_grid_data = net.ext_grid.loc[i]
net.ext_grid.drop(i, inplace=True)
pp.create_gen(net, ext_grid_data.bus, ext_grid_p[j],
vm_pu=ext_grid_data.vm_pu, controllable=True,
min_q_kvar=ext_grid_data.min_q_kvar, max_q_kvar=ext_grid_data.max_q_kvar,
min_p_kw=ext_grid_data.min_p_kw, max_p_kw=ext_grid_data.max_p_kw)
j += 1
# old gen at ref_bus -> ext_grid (and sgen)
for i in gen_idx:
gen_data = net.gen.loc[i]
net.gen.drop(i, inplace=True)
if gen_data.bus not in net.ext_grid.bus.values:
pp.create_ext_grid(net, gen_data.bus, vm_pu=gen_data.vm_pu, va_degree=0.,
min_q_kvar=gen_data.min_q_kvar, max_q_kvar=gen_data.max_q_kvar,
min_p_kw=gen_data.min_p_kw, max_p_kw=gen_data.max_p_kw)
else:
pp.create_sgen(net, gen_data.bus, p_kw=gen_data.p_kw,
min_q_kvar=gen_data.min_q_kvar, max_q_kvar=gen_data.max_q_kvar,
min_p_kw=gen_data.min_p_kw, max_p_kw=gen_data.max_p_kw)
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],
pp.create_std_type(net=pd_net, data=NFA2X4x70, name="NFA2X 4x70", element="line")
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
import pandapower.networks as pn
net = pn.create_dickert_lv_network()
"""
# --- create network
net = pp.create_empty_network(name='dickert_lv_network with' + feeders_range +
'-range feeders, ' + linetype + 'and ' + customer +
'customers in ' + case + 'case')
# assumptions
mv_vn_kv = 20
lv_vn_kv = 0.4
# create mv connection
mv_bus = pp.create_bus(net, mv_vn_kv, name='mv bus')
busbar_index = pp.create_bus(net, lv_vn_kv, name='busbar')
pp.create_ext_grid(net, mv_bus)
if trafo_type_name not in net.std_types['trafo'].keys():
pp.create_std_type(net, trafo_type_data, name=trafo_type_name, element="trafo")
pp.create_transformer(net, mv_bus, busbar_index, std_type=trafo_type_name)
# create feeders
create_dickert_lv_feeders(net=net, busbar_index=busbar_index, feeders_range=feeders_range,
linetype=linetype, customer=customer, case=case)
return net
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
, "c_nf_per_km" : 170}, "example_type3")
vsc_percent=13.0, pfe_mw=0, i0_percent=0,
shift_degree=330.0, name='Trafo 11-3')
pp.create_transformer_from_parameters(net_cigre_hv, bus6b, bus12, sn_mva=500,
vn_hv_kv=220, vn_lv_kv=22, vscr_percent=0.0,
vsc_percent=13.0, pfe_mw=0, i0_percent=0,
shift_degree=330.0, name='Trafo 12-6b')
# Loads
pp.create_load(net_cigre_hv, bus2, p_mw=285, q_mvar=200, name='Load 2')
pp.create_load(net_cigre_hv, bus3, p_mw=325, q_mvar=244, name='Load 3')
pp.create_load(net_cigre_hv, bus4, p_mw=326, q_mvar=244, name='Load 4')
pp.create_load(net_cigre_hv, bus5, p_mw=103, q_mvar=62, name='Load 5')
pp.create_load(net_cigre_hv, bus6a, p_mw=435, q_mvar=296, 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_mw=500, name='Generator 10')
pp.create_gen(net_cigre_hv, bus11, vm_pu=1.03, p_mw=200, name='Generator 11')
pp.create_gen(net_cigre_hv, bus12, vm_pu=1.03, p_mw=300, name='Generator 12')
# Shunts
pp.create_shunt(net_cigre_hv, bus4, p_mw=0.0, q_mvar=-0.16, name='Shunt 4')
pp.create_shunt(net_cigre_hv, bus5, p_mw=0.0, q_mvar=-0.08, name='Shunt 5')
pp.create_shunt(net_cigre_hv, bus6a, p_mw=0.0, q_mvar=-0.18, 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}}""")
'2.2', '2.3', '2.4', '2.2.1', '2.2.2']]
lv_loads['p'] = [0.1] + [0.01]*11
lv_loads['q'] = [0.01] + [0.03]*11
for _, load in lv_loads.iterrows():
bus_idx = pp.get_element_index(net, "bus", load.bus)
pp.create_load(net, bus_idx, p_mw=load.p, q_mvar=load.q, name=load.load_name)
# --- Other
# Shunt
pp.create_shunt(net, pp.get_element_index(net, "bus", 'Bus HV1'), p_mw=0, q_mvar=-0.96,
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_mw=100,
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_mva=100, name='Impedance')
# xwards
pp.create_xward(net, pp.get_element_index(net, "bus", 'Bus HV3'), ps_mw=23.942,
qs_mvar=-12.24187, pz_mw=2.814571, qz_mvar=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_mw=3.776,
**With defined standard types and probabilities:**
net = pn.random_line_networ(p_pv=0.7, p_wp=0.4, linetypes=["NAYY 4x120 SE", \
"NAYY 4x150 SE", "NA2XS2Y 1x95 RM/25 12/20 kV"])
"""
net = pp.create_empty_network()
avail_std_types = None
if not linetypes:
avail_std_types = pp.available_std_types(net, element='line').index
else:
avail_std_types = linetypes
cb = pp.create_bus(net, name="slack", vn_kv=voltage_level)
pp.create_ext_grid(net, cb)
for cb, nr_buses in [(0, nr_buses_main)] + branches:
start_bus = cb
for i in range(nr_buses):
ind_str = "%s" % (i + 1) if start_bus == 0 else "%s.%s" % (start_bus, i + 1)
bidx = pp.create_bus(net, name="Bus " + ind_str, vn_kv=voltage_level)
pp.create_load(net, bidx, p_kw=_chose_from_range(p_load_range),
q_kvar=_chose_from_range(q_load_range), name="Load " + ind_str)
if p_pv > random.random():
pp.create_sgen(net, bidx, p_kw=-_chose_from_range(p_pv_range),
q_kvar=_chose_from_range(q_pv_range), name="PV " + ind_str, type='PV')
if p_wp > random.random():
pp.create_sgen(net, bidx, p_kw=-_chose_from_range(p_wp_range),
q_kvar=_chose_from_range(q_wp_range), name="WP " + ind_str, type='WP')
pp.create_line(net, cb, bidx, _chose_from_range(line_length_range),
name="Line " + ind_str, std_type=random.choice(avail_std_types))
cb = bidx