Professional Documents
Culture Documents
DPL Excel Digsilent PDF
DPL Excel Digsilent PDF
Keywords DIgSILENT programming language DPL Local voltage control
Reactive power drop control Q(U) Simulation automation Simulation scripting
14.1 Introduction
Typical simulation scenarios may include the modelling of different generation and
load situation in the network (e.g. winter and summer).
Built-in mechanisms in PowerFactory enable the assignment of specific char-
acteristics (‘profiles’) to various variables, such as the active and reactive power of
loads. When managing a decent size of a network model, this assignment of
characteristics can be time-consuming, tedious and error prone. Within DPL, this
can be easily achieved and used generically for all sorts of controlling individual
behaviour of variables by characteristic. Figure 14.1 shows the typical tasks for
conducting power-flow-based system analysis and the listing in Fig. 14.2 the
execution of the corresponding subscripts. All scripts can be found in the accom-
panying project under: Library → Scripts → RunExtDataTimeSweep.
14 Advanced Applications of DPL … 325
Create Characteristics
Assign Characteristics
Export Results
Fig. 14.1 Typical tasks for power flow based analysis with characteristics
Fig. 14.2 DPL script for running simulations with external characteristics
The external characteristic objects have to be created and assigned to the specific
load object variables. The listing in Fig. 14.3 shows the steps of first deleting all
existing and creating new characteristics for the active and reactive power of all
loads.
After creating the external file characteristics for every load, the next step is to
automatically assign the external file, respectively the columns of the comma
separated value (.csv) file to the right characteristic.
Since the format of the characteristic file is without any header or information for
the various columns, an accompanying file loadList—a list of the loads to assign—is
provided as a parameter of the script. This has the advantage that the references
between loads and characteristics are fully controllable from extern: the alphabet-
ically ordered name of loads in every line in the loadList corresponds to the col-
umns in the characteristic. In case of balanced models, for every entry in the
loadList, two columns for active and reactive power will be assigned. The listing in
Fig. 14.4 shows this DPL script.
326 M. Stifter et al.
Fig. 14.3 DPL script for creating characteristics for active power of loads
Since every characteristic needs a trigger, which corresponds to the actual position in
the associated scale of the characteristic, a trigger has also to be created and assigned
automatically. The subscript CreateAndAssignTrigger in the project deletes any
existing triggers, creates a new one and assigns it to all characteristics in the project.
For running a series of power flow calculation, we need also to define the variables
of the objects we want to store for later analysis. This is usually done by adding
Variable Selection Objects (IntMon) to a result set (default result set ‘All calcula-
tions’). In Fig. 14.5, the DPL command is depicted, showing the reference to the
external result set ‘Results’ (ElmRes). Automatically adding the variables of interest
(voltage and active power) with DPL is shown in listing Fig. 14.6.
After assigning the external characteristics, triggers and results, the simulation can
be executed. The probably well-known and by the standard, global library provided
14 Advanced Applications of DPL … 327
Fig. 14.4 DPL script for automatic assignment of external characteristics to loads
Fig. 14.6 DPL script for adding result variables to the result set
start Script:
step TimeSweep triggerPos
Input Result
parameters stop Contents: parameters
Results.ElmRes
Until PowerFactory Version 14.x, the file folder ENGINE provided the so-called
RCOM interface for sending control commands via remote procedure call. Since
version 15.1 RCOM is no longer offically supported and it is recommended to use
the Python/API functionality for this purpose. Although no longer supported, one
can still copy and paste the ENGINE folder from previous version and use the
provided digrcom executable.
The following listing in Fig. 14.10 shows the use of the RCOM interface for
batch processing of various simulation scenarios by setting parameters of the
external sources of the characteristic files and starting the DPL script
RunExtDataTimeSweep.
14 Advanced Applications of DPL … 329
Fig. 14.8 DPL script for running power flow with characteristics
8,00
6,00
4,00
2,00
0,00
-2,00
0,000 287,8 575,6 863,4 1151, [-] 1439,
Load1: Active Power in kW
Load2: Active Power in kW
Load3: Active Power in kW
Load4: Active Power in kW
Load5: Active Power in kW
Load6: Active Power in kW
Load7: Active Power in kW
Load8: Active Power in kW
Load_EV1: Active Power in kW
Load_EV2: Active Power in kW
Load_EV3: Active Power in kW
Load_EV4: Active Power in kW
Load_EV5: Active Power in kW
The content of this RCOM command file is the parameter for the command:
330 M. Stifter et al.
14.4.1 Description
The input parameters for various scenarios are taken from a spreadsheet. After
the operation point of the generators have converged the maximum, minimum and
total active and reactive power are evaluated and written as a result to the
spreadsheet.
14.4.2 Preparation
In order to have the right references to the external measurement data files, the
batch file configure.bat has to be executed. It will map the network drive A: to the
data folder contained in that folder automatically. The batch file can be started from
any location (CD or hard drive) to reference the actual folder to the one referenced
in the PowerFactory project. All external profiles in the example project are mapped
to A: drive, e.g. A:\data\LoadList.txt.
A typical voltage control characteristic is depicted in Fig. 14.11, where a dead band
is defined at the nominal voltage. The slopes for overvoltage (II.) and undervoltage
Q
(IV.) are characterised by the voltages UDB;pos ; UDB;neg
Q
—where the control starts to
operate—and the maximum reactive power Qmax.ind and Qmax.cap. These reactive
Q(U), S(U)
S(U) undervoltage overvoltage
Qmax,cap
Q(U)
VII. VI. SECTION I. II. III. IV. V.
Qmax,ind
power limits have to be determined by the maximum apparent power Snom, and the
minimum allowed power factor PFmin defined as the cosine of the angle between
active power and the apparent power:
Pmax
PFmin ¼ cos u ¼ ð14:1Þ
Snom
Overvoltage
II. If the voltage increases over a certain limit, the reactive power is provided
according to the given droop with the equation:
Q
QðUÞ ¼ kovervoltage Q
U UDB;pos ð14:2Þ
Qmax:ind
Q
kovervoltage ¼ ð14:3Þ
Q
Umax UDB;pos
Q
where kovervoltage
Q
is the slope of the U(Q) characteristic in section II in
Fig. 14.11.
III. Maximum negative reactive power: The maximum reactive power is lim-
ited when the maximum power factor of the generator is reached to
IV. Maximum voltage limit: If the voltage increases over a certain limit the
active power will constantly be reduced (P(U)-control) to counteract a
further increase to the point where the total power output is zero. Note that
due to the minimal power factor supported by the inverter the reactive
power has to be reduced simultaneously.
P ¼ kP U d P ð14:6Þ
14 Advanced Applications of DPL … 333
Snom PFmin
kP ¼ ð14:7Þ
ðUmax
P UP
DB;pos Þ
d P ¼ kP Umax
P
ð14:8Þ
P
V. The power output will be set to zero, when the voltage is higher than Umax .
Undervoltage
VI. To support the voltage reactive power is produced according to the given
gradient of the droop, which can be determined similar to the equations of
the overvoltage droop region in II.
VII. Maximum positive reactive power: The reactive power is limited due to the
nominal power factor of the generator:
To converge to the steady-state operation point, the DPL script executes a power
flow to determine the reactive power for every inverter and a controller evaluation
iteratively until the change of the reactive power set point is below a certain epsilon
threshold (fix-point iteration). The algorithm is a simple way of finding the steady-
state solution of a network with inverters with Q(U) and P(U) control and is very
easy to use. It does not claim to be efficient in terms of convergence. Since the
iteration starts with determining the individual reactive power support with respect
to the local voltage level, the contributions are fairly distributed among the ones
which are causing the violation, which is proportional to the local voltage situation.
Figure 14.12 shows the flow diagram for the voltage control algorithm according
to the voltage-dependent reactive power characteristic (Fig. 14.11):
1. Power flow is performed to calculate the voltages at the nodes
2. For each generator, the position within the voltage characteristic is determined
3. According to the section on the voltage characteristic, the respective action is
performed.
For example, if the voltage is within the section II in Fig. 14.11, ‘Q(U) droop
inductive’: the reactive power set point is determined to the appropriate point on
the slope, according to the gradient of the characteristic.
4. Check apparent power constraints: After the set points of the reactive (and
active) power are calculated, they are checked if within the given maximum
apparent power of the power diagram.
5. Check power factor constraints: The operational limits are checked.
334 M. Stifter et al.
Initialisation
i=i+1
Power Flow
Finished
Fig. 14.12 Algorithm for the voltage depended reactive power control Q(U) with droop
characteristics and dead band
Microsoft Excel tables can be accessed from within DPL scripts for providing input
parameters for an automated simulation. In the example project, various settings for
14 Advanced Applications of DPL … 335
Table 14.1 Example input parameters for voltage control scenarios (Excel)
Gen. Q(U) characteristics P(U) characteristic Generator ratings
Pact UQmin
Q
UDB;neg Q
UDB;pos UQmax
Q
UDB;pos UQP
max PFmin Snom
(MW) (V) (V) (V) (V) (V) (V) (rad) (MVA)
0.0005 0.95 0.98 1.02 1.05 1.06 1.07 0.85 0.001
0.0007 0.95 0.98 1.02 1.05 1.06 1.07 0.85 0.001
0.0008 0.95 0.98 1.02 1.05 1.06 1.07 0.85 0.001
0.001 0.95 0.98 1.02 1.05 1.06 1.07 0.85 0.001
ExcelFile Script:
RunVoltageControl
Input row
parameters Contents:
GetResults
VoltageControl_Q_U
the Q(U) characteristic as well as parameters for the nominal rating powers of the
generators are used. The DPL script RunVoltageControl reads the rows of the excel
worksheet and executes the voltage control script. Simulation results are written
back into the table. Table 14.1 shows the input parameter and the settings for the Q
(U) characteristics. Figure 14.13 shows the DPL script with its input parameters and
the listing in Fig. 14.14 the main parts of the DPL code.
In the DPL script VoltageControl_Q_U (Fig. 14.15) the set points of the generator’s
reactive and, respectively, active power are determined according to the given
characteristics. In the initialisation part, the generator parameters are assigned from
the input parameters. The generator output P is stored in a map and retrieved at the
start of the iteration. After the initial power flow the generator node voltages are
also stored in a map, because assigning new set points to the network model will
reset those results (change of calculation relevant objects). Both constraints—
maximal nominal apparent power limits and minimal power factor—are checked,
after the potential Q(U) operation point has been determined. The change of the set
points Q and P between successive iterations is the termination criteria DeltaS. In
case the algorithm does not converge and alternates between two values (which can
happen in weak networks with a high amount of PV generation), it is forced into the
convergence with a damping factor alpha. The Listing is shown in Fig. 14.16.
336 M. Stifter et al.
Fig. 14.14 DPL script for running voltage control with external parameters
Figure 14.17 shows the input parameter for the script CheckApparentPower-
Constraints. The input parameter P is modified inside the script and changes are
automatically reflected in the calling higher-level script VoltageControl_Q_U.
In the script CheckPowerFactor the reactive power set point has to be within the
operational limits given by the minimal power factor of the generator. The script
CheckPowerFactor takes care of this by constraining Q, if it exceeds the limits, to:
Q
Q¼ P tan ðacosðPFminÞÞ ð14:11Þ
absðQÞ
14 Advanced Applications of DPL … 337
Fig. 14.15 DPL script (part) for reactive power control Q(U)
P Script:
Q VoltageControl_Q_U
Input U min
parameters UQDB,neg Contents:
Q
AssignGeneratorParameters
U DB,pos CheckApparentPowerConstraints
UPDB,pos CheckPowerFactor
ForceConvergence
PFmin Map_P
Snom Map_U
DeltaS
alpha
Snom Script:
CheckApparentPowerConstraints
Input P
parameters Q Contents:
Fig. 14.17 DPL script for running voltage control with external parameters
Pset Snom
ϕ min
ExcelFile Script:
RunVoltageControl
Input row
parameters Contents:
GetResults
VoltageControl_Q_U
Fig. 14.19 DPL command for checking the power factor limit of the generator
14 Advanced Applications of DPL … 339
Snom
Pset
ϕmin
Script: Psum
GetResults
Input Qsum Result
parameters Contents: Umax parameters
Umin
As an example, the sum of the active and reactive power of all generators and the
maximum and minimum voltages are evaluated. Figure 14.21 shows the result
parameters of the script and Fig. 14.22 shows the DPL code. The script GetResults
Table 14.2 Example results for the voltage control scenarios (Excel)
Input Parameter Results
Gen. All generators Network
Pact [MW] Ptot [MW] Qtot [Mvar] Umax [p.u.] Umin [p.u.]
0.0005 0.0045 −0.00279 1.04717963 0.99999664
0.0007 0.0054 −0.003304 1.04715858 0.99999667
0.0008 0.0054 −0.003348 1.0471555 0.99999667
0.001 0.0063 −0.003589 1.04715356 0.99999672
is called every time after the Voltage_Control_Q_U script. For every row of input
parameters from the external Excel file, the maximum and minimum voltage are
obtained, and the results of the total achieved active and reactive power are summed
up and then exported to the result columns (see Fig. 14.22) (Table 14.2).
14.5 Conclusions
Automation of simulation tasks by means of scripting with DPL (and RCOM) has
been presented. The example demonstrated the implementation of a control algo-
rithm used in multiple models and the use of iterative convergence to a steady state
of the system in DPL. Depending on the requirements of the simulation and
analysis task, the right way of implementation in terms of efficiency and other
criteria, such as time saving, needs to be chosen. Sometimes a combination of the
introduced concepts may be the most suitable.
14.5.1 Outlook
With the introduction of Python in PowerFactory 15.1.1, the API functionalities can
be used in a scripting environment, as opposed to compile C++ code and run
PowerFactory within an application. Moreover, the possibility to connect a
debugger to it will boost the workflow for users and programmers.
References
1. E-Control (2013) TOR Part D4, Technical and organizational rules for network operators and
users—part D4; Parallel operation of generators connected to the distribution network
2. Technical Guideline Generating Plants Connected to the Medium-Voltage Network (2008),
BDEW Bundesverband der Energie- und Wasserwirtschaft e.V., Jun. 2008
3. Fawzy T, Premm D, Bletterie B, Goršek A (2011) Active contribution of PV inverters to
voltage control—from a smart grid vision to full-scale implementation. e & i Elektrotechnik und
Informationstechnik 128(4):110–115
14 Advanced Applications of DPL … 341