Learn how to create, load, and manipulate power network models in PyPowSyBl
The Network object is the main data structure of PyPowSyBl. It contains all the data of a power network: substations, generators, lines, transformers, and more.
# List available post processorspp.network.get_import_post_processors()# ['geoJsonImporter', 'loadflowResultsCompletion', 'replaceTieLinesByLines']# Apply post processorsnetwork = pp.network.load('mycgmes.zip', post_processors=['replaceTieLinesByLines'])
# Tap changer steps indexed by transformer ID and positionsteps = network.get_ratio_tap_changer_steps()print(steps.loc['NHV2_NLOAD']) # Get steps for specific transformer
Variants allow you to maintain multiple network states:
network = pp.network.create_eurostag_tutorial_example1_network()# Create a new variantnetwork.clone_variant('InitialState', 'Variant')network.get_variant_ids()# ['InitialState', 'Variant']# Switch to the variant and make changesnetwork.set_working_variant('Variant')network.update_generators(id='GEN', target_p=700)# Use context manager for automatic switchingwith network.working_variant('Variant'): network.update_generators(id='GEN', target_p=701) # Automatically switches back when context exits# Remove variant when donenetwork.remove_variant('Variant')
be = pp.network.create_micro_grid_be_network()nl = pp.network.create_micro_grid_nl_network()# Merge NL into BEbe.merge(nl)# Access sub-networksbe.get_sub_networks()# Get specific sub-networknl_sub = be.get_sub_network('urn:uuid:77b55f87-fc1e-4046-9599-6c6b4f991a86')# Detach sub-networknl_sub.detach()
Manage operational limits for branches and transformers:
# Get operational limitsnet = pp.network.create_eurostag_tutorial_example1_network()limits = net.get_operational_limits()print(limits)# Get all limit groups (not just selected)limits_all = net.get_operational_limits(all_attributes=True, show_inactive_sets=True)# Change selected limit groupnet.update_lines(id='LINE1', selected_limits_group_2='OTHER_GROUP')
Do not commit files containing secrets (.env, credentials.json, etc.) to version control.