Skip to main content
This quickstart guide will help you perform your first power flow calculation using PyPowSyBl. You’ll learn how to create a network, run a load flow, and inspect the results.

Prerequisites

Make sure you have PyPowSyBl installed. If not, follow the installation guide.
pip install pypowsybl

Your First Load Flow

1

Import PyPowSyBl

Start by importing PyPowSyBl in your Python script or notebook:
import pypowsybl as pp
2

Create a network

PyPowSyBl provides built-in test networks. Let’s create the IEEE 14-bus test network:
network = pp.network.create_ieee14()
This creates a standard IEEE 14-bus network that’s commonly used for testing power system algorithms.
3

Run a load flow calculation

Now, run an AC load flow calculation on the network:
results = pp.loadflow.run_ac(network)
print(results)
You should see output similar to:
[ComponentResult(connected_component_num=0, synchronous_component_num=0, 
status=CONVERGED, status_text=CONVERGED, iteration_count=3, 
reference_bus_id='VL1_0', 
slack_bus_results=[SlackBusResult(id='VL1_0', active_power_mismatch=-0.006730108618313579)], 
distributed_active_power=0.0)]
The status=CONVERGED indicates that the load flow calculation successfully converged to a solution.
4

Inspect the results

After the load flow, you can extract network data as Pandas DataFrames. For example, to get bus voltages:
buses = network.get_buses()
print(buses)
This returns a DataFrame with voltage magnitudes and angles:
        v_mag  v_angle
VL1_0   1.060     0.00
VL2_0   1.045    -4.98
VL3_0   1.010   -12.72
VL4_0   1.019   -10.33
VL5_0   1.020    -8.78
VL6_0   1.070   -14.22
VL7_0   1.062   -13.37
VL8_0   1.090   -13.36
VL9_0   1.056   -14.94
VL10_0  1.051   -15.10
VL11_0  1.057   -14.79
VL12_0  1.055   -15.07
VL13_0  1.050   -15.16
VL14_0  1.036   -16.04

Complete Example

Here’s the complete working example:
import pypowsybl as pp

# Create a network
network = pp.network.create_ieee14()

# Run AC load flow
results = pp.loadflow.run_ac(network)
print(results)

# Get bus voltages
buses = network.get_buses()
print(buses)

# Get generators data
generators = network.get_generators()
print(generators)

# Get lines data
lines = network.get_lines()
print(lines)

Working with Different Network Types

Creating Networks

PyPowSyBl supports multiple ways to create or load networks:
# IEEE test networks
network = pp.network.create_ieee14()
network = pp.network.create_ieee30()

# Eurostag tutorial examples
network = pp.network.create_eurostag_tutorial_example1_network()

# Empty network
network = pp.network.create_empty("my_network")

Running Load Flow with Parameters

You can customize the load flow calculation with parameters:
import pypowsybl.loadflow as lf

# Create custom parameters
parameters = lf.Parameters(
    distributed_slack=False,
    dc_use_transformer_ratio=True
)

# Run load flow with parameters
results = lf.run_ac(network, parameters)

DC Load Flow

For faster calculations, you can run a DC load flow:
# Run DC load flow
parameters = lf.Parameters(distributed_slack=False)
results = pp.loadflow.run_dc(network, parameters)

Extracting Network Elements

PyPowSyBl provides methods to extract various network elements as Pandas DataFrames:
# Get all buses with voltage data
buses = network.get_buses()
All methods return Pandas DataFrames, making it easy to analyze and visualize your power system data.

What’s Next?

PyPowSyBl offers much more than basic load flow calculations:

Security Analysis

Perform N-1 security analysis and contingency simulations

Sensitivity Analysis

Calculate sensitivity factors for network analysis

Network Formats

Work with CGMES, MATPOWER, UCTE, and other formats

Visualization

Generate substation and network diagrams
For more examples and advanced features, check out the PyPowSyBl notebooks repository.

Getting Help

Documentation

Full API reference and detailed guides

Slack Community

Join the PowSyBl community on Slack

Build docs developers (and LLMs) love