aloytag / electrical-grid-simulator

Graphical user interface application for simulating electrical networks based on the pandapower library
MIT License
22 stars 1 forks source link
electrical-grid-simulator electrical-networks nodegraphqt pandapower power-systems

Electrical Grid Simulator (EGS)

The Electrical Grid Simulator (abbreviated as EGS) is a graphical user interface application for simulating electrical networks based on the pandapower library. The main objective is to allow the creation of mathematical models for steady-state electrical grids from a user-friendly interface. It adds an extensions system for including new calculation or simulation algorithms. Extensions are implemented as standard Python packages, so they can be distributed through the PyPI repository.

EGS logo

EGS is developed at the National Technological University, Santa Fe Regional Faculty (UTN-FRSF), at the Center for Research and Development in Electrical Engineering and Energy Systems (CIESE), Argentina.

[!WARNING]
This application is in an early stage of development. So you can expect incomplete sections and some (or many) bugs. New changes may cause incompatibilities with older versions (old files that no longer work with newer versions of the program).

Goals

How it is built

EGS is built in Python and entirely from open source and free software. The main core components are:

EGS is implemented as a Python package uploaded to the PyPI repository. pandapower and other packages listed above are set as dependencies.

[!NOTE]
Starting with version 0.0.8.0, the EGS package includes a fork of NodeGraphQt ported to Qt6 (using the PySide6 library). This implementation is renamed to NodeGraphQt6 in order to avoid conflicts. These changes allow the application to run on recent versions of Python.

How it works

Every time the user inserts and connects an element to the grid, the application replicates the addition in a pandapower network. Thus, the parameters of a component are updated in the pandapower network when they are modified from the graphical interface.

The network configured from the interface is designated as Graph, while the corresponding pandapower model is denoted as Data model. This synchronization works in the Graph -> Data model direction, i.e. changes in the Graph are automatically registered into the Data model, and not the other way around. However, the contents of the Data model can be consulted at any time.

According to the structure proposed by the pandapower library, the Data model consists of a set of tables (pandas DataFrame type objects). Each table (DataFrame) contains the parameters of a certain type of component. The types of components supported by pandapower are those indicated in this documentation link. At this moment, most of these components are also supported by EGS.

Main window: Graph view

Main window: Graph view

Main window: Data model view

Extension manager: Select and execute extensions

Main window: Data model view

Main window: Data model view - Tables arranged in tabs



The EGS main window is organized as follows:

Main features

Nodes and ports

A node element is a component added to the Graph. A node should not be mistaken for a network bus. Any component of the grid is represented by a node in the Graph. For this reason, there is a node type for each type of component supported by EGS.

Symmetric load node

Node element (example: symmetric load with an output port)



Some nodes provide widgets that work as shortcuts for some of their main features. For example, a symmetric load node has three widgets (as shown above) to set the real and reactive power demands, and a scale factor. However, all the node parameters are accessed from a dialog after double clicking on the node, as shown below. Additionally, the node name can be modified after double clicking on it.

Node dialog

Node dialog (example for a symmetric load node)



Node types (component types) are distinguished by color. For example, a line is represented by a different color than the one used for a transformer. Two- and three-winding transformers have nodes with the same color, but differs in the number of connections. Additionally, most of the nodes present a symbol (icon) identifying the type of component.

Nodes can have input and output ports. Connections are made by linking an output port on one node with an input port on another node. For example, to connect a generator to a bus, you can link the output port of the generator to the input port of the bus.

When a node is displayed in horizontal layout, input ports are placed on the left and output ports on the right. In the vertical layout, input ports are placed at the top and output ports at the bottom. For convenience, nodes with a single port can be flipped, so that an input port becomes an output port, or vice versa. Additionally, buses are represented since version 0.0.8.4 with four-port nodes, which means that one output port is placed on the right and one at the bottom, and similar locations are available for two input ports (left and top).

The distinction between input and output ports has another use in certain components. For example, in a two-winding transformer, the input port represents the high voltage side (hv), while the output port corresponds to the low voltage side (lv). In this case, to make it easier to distinguish, these ports have different shapes. In an AC line, input and output ports refer to the "from bus" and "to bus" sides, respectively. On the contrary, there is no distinction between input and output ports in a bus, which correspond to the same point.

AC line and two-winding transformer nodes

Two-winding transformer and AC line nodes



When a bus node is added to the Graph, it is immediately inserted also into the Data model. But this is not the case with other components, which are included in the Data model only when they are connected. This behavior is due to the fact that pandapower requires the connection points to insert a new element into the grid (with the only exception of the bus component). But this has an advantage: you can disconnect an element and connect it again in a different place, without losing the parameters configured in the node, which remain stored in the Graph. EGS will take care of maintaining the synchronization with the Data model.

Simulations and calculations

With EGS you can build and set up the model of an electrical grid in a graphical way. The application also allows you to perform AC balanced power flow calculations (other calculations supported by pandapower may be added in the future). For other types of simulations and calculations, you can proceed according to two alternatives:

  1. Export the Data model and the last power flow results to a JSON format file ready to be imported from a Python script through pandapower. Then, any calculation or processing can be done from the script. The export is done from the graphical interface, while the subsequent import is done as indicated in the pandapower documentation, using the pandapower.from_json() function.

  2. Incorporate the required calculation functionality from an extension developed in Python. This way, the calculation is executed from within EGS. Extensions are implemented as regular Python packages. An Optimal Power Flow (OPF) extension is available in the PyPI repository (package name: electricalsim-opf-quadratic). Instructions and a template for creating extensions will be available soon.

Models generated by EGS can be saved in a file containing both the Graph and the Data model (.egs file extension). You can then reopen the file whenever you need it and retrieve even the results of the last power flow run.

Running an AC balanced power flow

In order to run a power flow, click on the play button at the upper toolbar. A new dialog gets opened. The first tab allows you to configure the parameters of the numerical method (solver) and other model settings. Then, execute the calculation using the Run power flow button.

Power flow dialog - First tab (settings)

Power flow dialog - First tab (settings)


The sencond tab shows the results in the pandapower way (tables), while the third tab includes some plots:

In bar voltage charts, the magnitud level is distinguished with different colors to emphasize acceptable values, under-voltages and over-voltages. Line and transformer overloads are also highlighted in red. In addition, the head of the plot usually includes some statistical results.

Power flow dialog - Second tab (pandapower results)

Power flow dialog - Second tab (pandapower results)


Power flow dialog - Third tab (plot results) - Voltages

Power flow dialog - Third tab (plot results) - Voltages


Power flow dialog - Third tab (plot results) - AC line loading

Power flow dialog - Third tab (plot results) - AC line loading


After closing the power flow dialog and returning to the graph view, you can place the cursor on a particular node and get a tooltip with the main results (see the screenshot below). For example, an AC line shows the loading percentage, and the real and reactive power transmitted (at the "from bus" and "to bus"). Most of the nodes show this kind of information.

Tooltip - Power flow results

Tooltip - Power flow results


Application settings

The application settings are saved in a config.ini file outside the installation directory. This way, your settings are maintained after updating the program. However, you can change them from a dialog window.

Settings are classified into four categories:

Settings dialog

Settings dialog


EGS with dark theme

EGS with dark theme


Connections in angle style Connections in curved style Connections in straight style

Connection style: angle, curved and straight



Shortcuts

Shortcut Description
Ctrl+N Create a new session
Ctrl+O Open session from a .egs file
Ctrl+S Save session to a .egs file
Ctrl+Shift+S Save session as...
Ctrl+E Export Data model to a JSON file
Ctrl+Z Undo
Ctrl+Shift+Z Redo
Del Delete selected components in the Graph
Ctrl+A Select all the nodes in the Graph
Ctrl+Shift+A Unselect what is selected
D Disable the selected nodes
R Flip the selected nodes (works only with nodes that have only one port)
Ctrl+D Duplicate the selected nodes (switches cannot be duplicated)
Ctrl++ Zoom in
Ctrl+- Zoom out
= Reset zoom
F Adjust the zoom level according to the selection
V Change selected nodes to the vertical layout
H Change selected nodes to the horizontal layout
Shift+V Apply a vertical alignment to selected nodes
Shift+H Apply a horizontal alignment to selected nodes
Ctrl+F Find a node by fuzzy search

Note

  • Undo and Redo only work for simple actions.
  • Pressing F without selected nodes will adjust the zoom level to show all the grid.
  • Pressing D will change the bool value for the in_service parameter in the Data model. This works for every component, except for switches.
  • For selecting nodes in the Graph you can use the left mouse button (LMB). Just click with the LMB, hold and drag to mark the selection area.
  • Clicking with the LMB on the background will unselect all.
  • You can use Shift+LMB on a node in order to add it to the selection.
  • Ctrl+LMB or Shift+LMB on a selected node will unselect it.
  • The mouse scroll wheel can be used to zoom in and out.
  • Use the medium mouse button (MMB) to scroll over the Graph. Just click with the MMB, hold and move.
  • Hold Shift+Alt+LMB to slice several connections (see the picture below).

If you prefer to use the mouse instead of keyboard shortcuts, just right click on the Graph and access a context menu that complements the upper toolbar and the menu bar.

Disabling nodes

Disabling nodes


Slicing connections

Slicing connections


Fuzzy search

Fuzzy search


![Context menu](img/14_Context_menu.png)

Context menu


# Installation EGS is installed using ```pip```, the official Python package manager. On GNU/Linux and MacOS execute the following order in a terminal: ```bash pip install electricalsim ``` On MS Windows you may prefer: ```bash python -m pip install electricalsim ``` If you want to install the latest development version: ```bash python -m pip install git+https://github.com/aloytag/electrical-grid-simulator.git -U ``` ## Upgrading EGS In order to upgrade EGS via ```pip```, execute the following in a terminal: ```bash pip install electricalsim -U ``` On MS Windows you may prefer: ```bash python -m pip install electricalsim -U ``` ## Running EGS Once installed, you can run it with the command: ```bash egs ``` If you prefer to run the program in a more practical way, just execute this command only once: ```bash egs-create-shortcut ``` This will add a shortcut launcher to your desktop and to your application menu. Note that this launcher will not work if you are installing the application into a Python virtual environment. ## Uninstalling If you want to remove the application, execute: ```bash pip uninstall electricalsim ``` On MS Windows: ```bash python -m pip uninstall electricalsim ``` Note that shortcuts added with the ```egs-create-shortcut``` command are not removed. So you must delete them manually. ## Installing extensions Extensions available in the PyPI repository can be installed using ```pip```. For example, the [Optimal Power Flow extension](https://github.com/aloytag/electricalsim-opf-quadratic) is installed with: ```bash pip install electricalsim-opf-quadratic ``` On MS Windows: ```bash python -m pip install electricalsim-opf-quadratic ``` # License This project uses the [MIT license](https://github.com/aloytag/electrical-grid-simulator/blob/main/LICENSE). The background image on the splash screen is based on the work of [David Gunter](https://www.flickr.com/photos/23812004@N03/6637323071), marked with a [CC BY 2.0](https://creativecommons.org/licenses/by/2.0/) license.