DIgSILENT Programming Tutorial #1: Counting Grid Elements
A program that displays the amount of each element on the 39 Bus New England System Grid using DIgSILENT Programming Language (DPL).
Introduction
In this tutorial, I want to share a tutorial about DIgSILENT Programming Language (DPL): Counting Grid Elements. The things that need to be prepared to follow this tutorial are:
- Installed DIgSILENT PowerFactory Software.
- PFD file of 39-Bus New England System Grid.
A. Preparation Phase
Program Specification
The program must meet the specifications with the following details.
- This program can detect Terminal, Busbar, Generator, Line, and 2-Winding Transformer elements on the Grid 39 Bus New England System.
- This program can count the number of each type of element (Terminal, Busbar, Generator, Line, and 2-Winding Transformer).
- This program can display the calculation results in the Output Window of DIgSILENT PowerFactory software.
Program Output Design
The following is the final design of the expected program output display. This design has been adjusted to the program specifications to make it easier for users to understand the DPL script calculation results.
[Program Output Design]Num. of Terminal = x
Num. of Busbar = x
Num. of Generator = x
Num. of Line = x
Num. of 2-Winding Trafo = x
B. Programming Phase
The following is the source code of the program, which is divided into three parts, namely:
- Documentation, is the section that contains essential information in the form of comments (non-executable code). Usually, this information can be in the form of the program name, author name, and program description.
- Dictionary, is the part that defines the type of the variables used in the script (object, set, int, string, double).
- Algorithm, is the part that executes the code/command procedurally to implement the design design and program specifications that have been determined previously.
!Title: GRID INFO PROGRAM
!Author: Jonathan Fedrico Simorangkir
!Date: July 2022
!Code Version: 1.0
!Availability:!Descriptions:
!1) This program can detect Terminal, Busbar, Generator, Line, and 2-Winding Transformer elements on the Grid 39 Bus New England System.
!2) This program can count the number of each type of element (Terminal, Busbar, Generator, Line, and 2-Winding Transformer).
!3) This program can display the calculation results in the Output Window of DiGSILENT PowerFactory software.!---------------------------!DICTIONARY
object term,gen,line,trf;
set TERMs,GENs,LINEs,TRFs;
int ctr;!---------------------------
!ALGORITHM
ClearOutput();TERMs=AllRelevant('*.ElmTerm');
GENs=AllRelevant('*.ElmSym');
LINEs=AllRelevant('*.ElmLne');
TRFs=AllRelevant('*.ElmTr2');!calculating amount of each element
!--TERMINAL
ctr=0;
for(term=TERMs.First();term;term=TERMs.Next()){
ctr+=1;
}
printf('Num. of Terminal = %d',ctr);!--BUSBAR
ctr=0;
for(term=TERMs.First();term;term=TERMs.Next()){
if(term:iUsage=0){
ctr+=1;
}
}
printf('Num. of Busbar = %d',ctr);!--GENERATOR
ctr=0;
for(gen=GENs.First();gen;gen=GENs.Next()){
ctr+=1;
}
printf('Num. of Generator = %d',ctr);!--LINE
ctr=0;
for(line=LINEs.First();line;line=LINEs.Next()){
ctr+=1;
}
printf('Num. of Line = %d',ctr);!--2 WINDING TRAFO
ctr=0;
for(trf=TRFs.First();trf;trf=TRFs.Next()){
ctr+=1;
}
printf('Num. of 2-Winding Trafo = %d',ctr);
C. Program Execution Phase
The following is the result of program execution in DIgSILENT PowerFactory Output Window.
Based on the results above, it can be seen that the program has succeeded in meeting the specifications and output designs that have been previously determined.
Reference
DIgSILENT PowerFactory Documentation