def test_convert_format_for_pp_objects(net_in): pp.create_transformer(net_in, net_in.bus.index.values[0], net_in.bus.index.values[1], '0.25 MVA 20/0.4 kV', tap_pos=0) c1 = control.ContinuousTapControl(net_in, 0, 1.02) c2 = control.DiscreteTapControl(net_in, 0, 1, 1) c1.u_set = 0.98 c2.u_lower = 0.99 c2.u_upper = 1.1 # needed to trigger conversion net_in.version = "2.1.0" net_in.controller.rename(columns={'object': 'controller'}, inplace=True) assert 'controller' in net_in.controller.columns s = json.dumps(net_in, cls=PPJSONEncoder) net1 = pp.from_json_string(s, convert=True) assert 'controller' not in net1.controller.columns assert 'object' in net1.controller.columns obj1 = net1.controller.object.at[0] obj2 = net1.controller.object.at[1] assert not hasattr(obj1, 'u_set') assert not hasattr(obj2, 'u_lower') assert not hasattr(obj2, 'u_upper') assert obj1.vm_set_pu == 0.98 assert obj2.vm_lower_pu == 0.99 assert obj2.vm_upper_pu == 1.1
def create_pp_grid(nodes, lines, tech, loads, n0, hv=True, ntrafos_hv=2, vn_kv=20, tanphi=0.3, hv_trafo_controller=True, verbose=True): """ """ if verbose: print('Starting!') # 0- empty grid net = pp.create_empty_network() # 1- std_types if verbose: print('\tTech types') add_tech_types(net, tech) # 2 - Create buses if verbose: print('\tBuses') idxs = pp.create_buses(net, len(nodes), vn_kv=vn_kv, name=nodes.index, geodata=list(nodes.xyGPS), type='b', zone=nodes.Geo.values) if 'Feeder' in nodes: add_extra(net.bus, idxs, nodes.Feeder.values, 'Feeder') # 3- Create lines if verbose: print('\tLines') for linetype in lines.Conductor.unique(): ls = lines[lines.Conductor == linetype] nis = pp.get_element_indices(net, "bus", ls.node_i) nes = pp.get_element_indices(net, "bus", ls.node_e) idxs = pp.create_lines(net, nis, nes, ls.Length.values / 1000, std_type=linetype, name=ls.index, geodata=list(ls.ShapeGPS), df=1., parallel=1, in_service=True) if 'Feeder' in lines: add_extra(net.line, idxs, ls.Feeder.values, 'Feeder') # 4- Create loads if verbose: print('\tLoads') nls = pp.get_element_indices(net, 'bus', loads.node) idxs = pp.create_loads(net, nls, name=loads.index, p_mw=loads.Pmax_MW.values, q_mvar=loads.Pmax_MW.values * tanphi) if 'type_load' in loads: add_extra(net.load, idxs, loads.type_load.values, 'type_load') else: add_extra(net.load, idxs, 'Base', 'type_load') if 'Geo' in loads: add_extra(net.load, idxs, loads.Geo, 'zone') # Adding external grid if verbose: print('\tExt Grid') if hv: # If HV, then add extra bus for HV and add trafo b0 = pp.create_bus(net, vn_kv=110, geodata=nodes.xyGPS[n0], name='HV_SS') # Adding HV-MV trafo (n x 40MW trafos) t = pp.create_transformer(net, hv_bus=b0, lv_bus=n0, std_type='40 MVA 110/20 kV', name='TrafoSS', parallel=ntrafos_hv) if hv_trafo_controller: # Add tap changer controller at MV side of SS trafo ppc.DiscreteTapControl(net, t, 0.99, 1.01, side='lv') else: b0 = n0 pp.create_ext_grid(net, bus=b0) if verbose: print('Finished!') return net
# -*- coding: utf-8 -*- # Copyright (c) 2016-2021 by University of Kassel and Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. import pandapower.networks as nw import pandapower as pp import pandapower.control as control import os net = nw.example_multivoltage() control.DiscreteTapControl(net, 1, 1.02, 1.03) pp.runpp(net, run_control=True) pp.to_json(net, os.path.join("old_versions", "example_%s.json" % pp.__version__))