Grid from text Examples
This document gives instructions for combining the graph drawing tool on https://csacademy.com/app/graph_editor/ with pgm-ds. Please note that the graph drawing tool is not linked to the power-grid-model project. This example solely illustrates how to use their editor to create a simple graph which can be loaded into power-grid-model-ds using a .txt file.
Creating input data for pgm-ds
Drawing a grid
The graph editor on https://csacademy.com/app/graph_editor/ is a very intuitive and easy to use tool for quickly drawing a grid.
A graph can be created by defining branches between nodes.
If you follow a specific syntax, you can use the input from the graph editor to transfer your drawing to pgm-ds:
A substation node should be prefixed with
Se.g:
S1,S2
A line is defined as
<from_node> <to_node>From nodes can be both regular nodes and source nodes
e.g.:
S1 2,3 4
A transformer is defined as
<from_node> <to_node> transformere.g.:
8 9 transformer
A grid opening is defined by adding
opene.g.:
4 5 openfor lines or6 7 transformer,openfor transformers
Loading a drawn grid into pgm-ds
There are two ways of loading a text grid into a pgm-ds:
load grid from a .txt file
load grid from a list of strings
Load a grid from a .txt file
Copy the Graph Data of your grid to a text file (e.g. my_grid.txt).
For the example above, the file should contain the following data:
S1 2
S1 3 open
2 7
3 5
3 6 transformer
5 7
7 8
8 9
Then, using python’s pathlib module, navigate to your file and load your grid
from pathlib import Path
from power_grid_model_ds import Grid
txt_file_path = Path("../../_static/my_grid.txt")
grid = Grid.from_txt_file(txt_file_path)
Load grid from a list of strings
You can also load a grid directly from a list of strings
from power_grid_model_ds import Grid
grid = Grid.from_txt(
"S1 2",
"S1 3 open",
"2 7",
"3 5",
"3 6 transformer",
"5 7",
"7 8",
"8 9",
)
print(grid)
3 6 14,transformer
S1 2 10
S1 3 11,open
2 7 12
3 5 13
5 7 15
7 8 16
8 9 17