Split lines or cables into a pre-defined number of sections in DIgSILENT PowerFactory

In this post, I present an approach to automatically split lines or cables in DIgSILENT PowerFactory into a pre-defined number of sections.

The main idea is to loop over every line and split it into a pre-defined number of sections. The sections assume the same line type as the original line. Whereas the length of each section is defined by the original length of the line divided by the number of sections, i.e. section length = line length / # sections.

An example of a line split into 10 sections

In the screenshot below you can see an example of a line before and after the split into sections. In red, you can see that the line type is transferred to the sections. In green, you can see that the total line length remains the same, whereas each section is equal to the line length / # sections (here: section length = 1 km / 10 sections = 0.1 km/section). In blue, you can see the 10 generated sections numbered from 0 – 9. Of course, the number of sections can be chosen freely and the length will be adapted accordingly.

Screenshot of the line before and after running the script
split lines into sections 
DIgSILENT PowerFactory
Screenshot of the line before and after splitting into sections

Step-by-step instructions on how to use the Python script to split lines

  1. create a backup of your PowerFactory project (just in case)
  2. download the script 🙂
  3. change the path to your PowerFactory installation in the script (in line 32)
  4. change project name and study case name (see screenshot below)
  5. define the desired number of sections (see screenshot below)
  6. make sure no line sections are defined before running the script for the first time
  7. every line needs to have a line type (because it is used for the sections)
  8. run the script
Screenshot of the Python script

Additional comments

  • When you run the script for the first time, a csv-file with the “projName + _LineLengths_Backup.csv” will be saved in the current folder. The file includes all lines and their original line lengths. When running the script again, the line lengths from this file will be used. This is done in order to keep the correct line lengths when deleting the previously created sections. Otherwise they will be lost. You can delete this file if necessary. In this case the script will save a new backup file on the next run.
  • When sections are defined for a line it is not possible to change the line type to distributed. It must be lumped.

I hope you find this article insightful. If so, you might also like the following: How to create a measurement file for DIgSILENT PowerFactory from a CSV, TXT, or XLSX file?

More insights to follow in the next article.

Michael

Share this post:

Similar Posts

Leave a Reply