Tutorial DSL TestTroubleshooting
Tutorial DSL TestTroubleshooting
PowerFactory includes different options and methods to test a model for errors. If you are following the
complete tutorial and have completed the previous part Building a User Defined Model, then you can continue
working with the same project; otherwise you can import the project with the already prepared model. If you
select the first option then go to Section 1, otherwise:
• Click on the icon from the exercise “Testing and Troubleshooting” of the PowerFactory Tutorial window,
to import and activate the project for this exercise.
After creating a complete model definition including the initialisation, the next step should be checking for
syntax and typing errors. To this end, PowerFactory provides the “Check” function in the DSL model type (see
Figure 1.1).
The “Check” function looks for syntax and typographical errors; for instance, built-in function names that are
misspelled (e.g. “sqrut(4)” instead of “sqrt(4)”), mathematical syntax errors (e.g. “2 ++ 3” instead of “2 + 3”),
variable or signal names that don’t exist or are misspelled, etc. Actual numerical checks are not performed,
however it checks whether all state variables in the model have an initial condition statement (whether the
definitions of the initial values lead to a steady-state operating point is not verified at this point).
The “Check” function, as said before, only looks for syntax errors, but does not check whether a model is
correctly connected to other elements or if the initialisation is adequately defined. Checks of this kind can only
be performed at the DSL model level (i.e, when the model has been included in the grid calculations).
A most important tool for this is the “Verify initial conditions” option of the “Calculate Initial Conditions” command
( ): when enabled, this option will print to the output window a summary of errors and warnings concerning
the model initial status, as, for example:
• Model cannot be initialised
• Derivative of state variable not zero
When testing models and troubleshooting initialisation issues, it is useful to be able to examine the input /output
signals connecting the DSL models, as well as any internal and state variables from inside the DSL models.
In the following sections three possible ways to inspect model signals and variables in PowerFactory will be
demonstrated.
• Define a variable selection for the DSL common model object (“Voltage Controller”). From the variable
selection dialog, select the following signals and variables: s:Vref; s:Vs; s:Vt; s:Efd; c:Vc; c:yi; c:Va; c:Vr.
Rev.2 2
TESTING AND TROUBLESHOOTING
Note: Signals and state variables are located in the “Signals” menu, and internal variables are located
in the “Calculation Parameter” menu.
• Press the “Print Values” button to show the calculated initial values of the selected signals and variables
(see Figures 2.1 and 2.2).
Figure 2.1: Printing initial values from the variable set dialog
Rev.2 3
TESTING AND TROUBLESHOOTING
The flexible data window of the network model manager ( ) can also be used to view model signals and
variables.
• Run the “Calculate Initial Conditions” command ( )
• Open the network model manager and look for the DSL model (“Voltage Controller”), select “Detail Mode”
using the icon and then select the “Flexible Data” tab at the bottom of the window.
• Clicking on the “Variable Selection” icon ( ) brings up a variable set dialog, where the signals and
variables of interests can be selected. Select the same variables defined in previous section 2.1; these
signals and variables will then be displayed in the network model manager as shown in Figure 2.3.
Figure 2.3: Using the flexible data window to view model signals and variables
The graphical representation of the DSL model object can be also used to view signals and variables values at
initialisation.
• Open the data manager and locate the “Voltage Controller” DSL model, do right-click Diagrams → Show
Diagram. A new page with the controller block diagram will be displayed, however it is in freeze mode
and doesn’t allow you to modify the model. You will see the external frame as a thin grey line, this is the
only visible difference with the block diagram.
• Execute the “Calculate Initial Conditions” command ( ) and check the results on the diagram as shown
in Figure 2.4.
Rev.2 4
TESTING AND TROUBLESHOOTING
Figure 2.4: Using the block diagram to see signals and variables
The following guidelines are provided to help find and resolve any issues encountered when creating dynamic
models in PowerFactory :
• Add the initialisation equations to the composite block definitions, rather than to the primitive blocks.
• Make sure that DSL model types are set up so that each model can be completely initialised individually.
• The previous point also applies to a single composite model with many block definitions (DSL models).
If there is a problem with one DSL model, try to put the DSL models that are not directly connected or
related to the problematic model out of service. Some dummy initialisation values (i.e. with the inc0
statement) may need to be added.
Rev.2 5
TESTING AND TROUBLESHOOTING
• Use the “Verify Initial Conditions” option in the “Calculation of Initial Conditions” command object (Com-
Inc).
• Use the “Display internal DSL-events in output window” option in the “Run Simulation” command object
(ComSim).
• Avoid potentially inconsistent operations such as division by zero. The concrete case of a division by zero
can be handled by adding some extra code to avoid the inconsistency. One option is to skip the division,
e.g. instead of writing “(yi-x)/T” where “T” can take potentially the value of zero, use “select(T>0,(yi-x)/T,
yi)”.
• Expressions resulting (directly or indirectly) in the definition of a variable as a function of itself (e.g, yo=
x+yi+K*yo) are not allowed and are reported as “algebraic loop” errors by PowerFactory. Some algebraic
loops may be solved by reformulating the model equations, but this is not always possible. Typically
algebraic loops occur in feedback branches and in some if/else (“select”) implementations. To solve
algebraic loops resulting from feedback branches it is necessary to decouple the input/output equations,
for example by introducing a single order lag filter “1/(1+sT)” with a time constant close to the simulation
step size. Algebraic loops are detected by PowerFactory evaluating all possible paths, e.g., all “select”
alternatives, this can be solved avoiding the path in the “select” function causing the loop.
4 Summary
This concludes the exercise. Now it should be clear how to carry out the following tasks: