DPL Manual Version 12 1

Embed Size (px)

Citation preview

  • DPL ManualDIgSILENT PowerFactoryVersion 12.1

    DIgSILENT GmbHGomaringen, Germany

    2003

  • Publisher:DIgSILENT GmbHBuchenstrasse 10D-72810 GomaringenTel : (07072)9168-0Fax : (07072)9168-88

    Visit our homepage at:www.digsilent.de

    Copyright DIgSILENT GmbH.All rights reserved. No part of thispublication may be reproduced ordistributed in any form withoutpermission of the publisher.doc 103 05 06 920

  • Contents

    1 DPL 21.1 The DPL Command Object . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 The DPL Script Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Access to Other Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.4 Access to Locally Stored Objects . . . . . . . . . . . . . . . . . . . . . . . . 91.5 Accessing the General Selection . . . . . . . . . . . . . . . . . . . . . . . . 101.6 Accessing External Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.7 Remote Scripts and DPL command Libraries . . . . . . . . . . . . . . . . . 111.8 DPL Functions and Subroutines . . . . . . . . . . . . . . . . . . . . . . . . 13

    DPL Manual 1

  • DIgSILENT PowerFactory DPL

    Chapter1

    DPL

    The DIgSILENT Programming Language DPL serves the purpose of offering an interface forautomating tasks in the PowerFactory program. The DPL method distinguishes itself from thecommand batch method in several aspects:

    DPL offers program decision and flow commands DPL offers the definition and use of user-defined variables DPL has a flexible interface for input-data and external objects DPL offers mathematical expressions

    The DPL adds a new dimension to the DIgSILENT PowerFactory program by allowing thecreation of new calculation functions. Such user-defined calculation commands can be used inall areas of power system analysis, such as

    Network optimizing Cable-sizing Protection coordination Stability analysis Parametric sweep analysis Contingency analysis etc. etc.

    Such new calculation functions are written as program scripts which comprise

    flow commands like if-then-else and do-while DIgSILENT commands (i.e. load flow or short-circuit commands) Input and output routines Mathematical expressions DIgSILENT object procedure calls subroutine calls

    Such program scripts are executed by DPL command objects.

    To understand the DPL philosophy and the resulting hierarchical structure of DPL scripts, thefollowing is important to understand:

    DPL Manual 2

  • DIgSILENT PowerFactory DPL

    A DPL command either executes its own script or the script of another, remote, DPLcommand. In the first case, the DPL command is called a root command and the scriptis called a local script. In the second case, the DPL command is called a referringcommand and the script is called a remote script.

    A root command may define interface variables that are accessible from outside the scriptand which are used to define default values.

    Each root command may define one or more external objects. External object are used tomake a DPL command run with specific power system objects, selections, commands, etc.

    A referring command may overrule all default interface values and all selected externalobjects of the remote command.

    Each DPL command can be called as a subroutine by other DPL commands.The use of remote scripts, external objects and interface variables makes it possible to creategeneric DPL commands, which may be used with different settings in many different projects andstudy cases.

    1.1 The DPL Command ObjectThe DPL command object holds a reference to a remote DPL command when it is not a rootcommand. The example depicted in Fig. 1.1 is apparently a referring command, since its DPLscript reference is set to the remote command \LIBRARY\DPL COMMANDS\CHECKVLOADING.A root command has its own script on the script page of the dialog. A referring command usesthe script of the remote DPL command.

    The DPL command also holds a reference to a selection of objects (General Selection). Thegeneral selection in the example is empty. Only one single General Selection is valid at a timefor all DPL scripts. This means that setting the General Selection in one DPL command dialog,will change the General Selection for all DPL commands in the database.

    The interface section is used to define variables that are accessible from outside the DPLcommand itself. DPL commands that call other DPL commands as subroutines, may use andchange the values of the interface variables of these DPL subroutines.

    The list of External Objects is used to execute the DPL command for specific objects. A DPLcommand that, for example, searches the set of lines for which a short-circuit causes too deep avoltage dip at a specific busbar, would access that specific busbar as an external object.Performing the same command for another busbar would then only require setting the externalobject to the other busbar.

    The most important part of a DPL root command is of course the actual DPL program script.That script is written on the Script page of a DPL root command dialog.

    1.2 The DPL Script Language

    The DPL script language uses a syntax quite similar to the C++ programming language. Thistype of language is intuitive, easy to read, and easy to learn. The basic command set has beenkept as small as possible.

    DPL Manual 3

  • DIgSILENT PowerFactory DPL

    Figure 1.1: A DPL command

    The syntax can be divided into the following parts:

    variable definitions assignments and expressions program flow instructions method calls

    The statements in a DPL script are separated by semicolons. Statements are grouped togetherby braces.

    Example:

    statement1;statement2;if (condition) {

    groupstatement1;groupstatement2;

    }

    1.2.1 Variable DefinitionsDPL uses the following internal parameter types

    double, a 15 digits real number int, a integer number

    DPL Manual 4

  • DIgSILENT PowerFactory DPL

    string, a string object, a reference to a DIgSILENT object set, a container of objects

    Vectors and Matrices are available as external objects.

    The syntax for defining variables is as follows:

    [VARDEF] = [TYPE] varname, varname, ..., varname;[TYPE] = double | int | object | set

    All parameter declarations must be given together in the top first lines of the DPL script. Thesemicolon is obligatory.

    Examples:

    double Losses, Length, Pgen;int NrOfBreakers, i, j;string txt1, nm1, nm2;object O1, O2, BestSwitchToOpen;set AllSwitches, AllBars;

    1.2.2 Assignments and ExpressionsThe following syntax is used to assign a value to a variable:

    variable = expressionvariable += expressionvariable -= expression

    The add-assignment += adds the right side value to the variable and the subtract-assignment-= subtracts the right-side value.Examples:

    double x,y;x = 0.5*pi(); ! x now equals 1.5708y = sin(x); ! y now equals 1.0x += y; ! x now equals 2.5708y -= x; ! y now equals -1.5708

    The following operators and functions are available:

    arithmetic operators: +, -, *, / standard functions:

    sin(x) cos(x) tan(x) asin(x)acos(x) atan(x) sinh(x) cosh(x)tanh(x) exp(x) ln(x) log(x) (basis 10)abs(x) min(x,y) max(x,y) sqrt(x) (square root)trunc(x) frac(x) round(x) sqr(x) (power of 2)pow(x,y) modulo(x,y) ceil(x) floor(x)rand()

    All trigonometric functions are based on radians (RAD).The function rand() returns a uniform distributed random number in the range [0, 1].

    DPL Manual 5

  • DIgSILENT PowerFactory DPL

    1.2.3 Program Flow InstructionsThe following flow commands are available.

    if ( [boolexpr] ) [statlist]if ( [boolexpr] ) [statlist] else [statlist]

    do [statlist] while ( [boolexpr] )while ( [boolexpr] ) [statlist]

    in which

    [boolexpr] = expression [boolcomp] expression[boolcomp] = | = | >= | >= |

    [statlist] = statement; | { statement; [statlist] }

    Unary operators: .not. Binary operators: .and. | .or. | .nand. | .nor. | .eor. Parentheses: {logical expression}

    Examples:

    if (a=b*c) {a = O:dline;c = c + delta;

    }if ({.not.a}.and.{b3}) {

    err = Ldf.Execute();if (err) {

    Ldf:iopt_lev = 1;err = Ldf.Execute();Ldf:iopt_lev = 0;

    }}

    Break and ContinueThe loop statements do-while and while-do may contain break and continue commands. Thebreak and continue commands may not appear outside a loop statement.

    The break command terminates the smallest enclosing do-while or while-do statement. Theexecution of the DPL script will continue with the first command following the loop statement.

    The continue command skips the execution of the following statements in the smallestenclosing do-while or while-do statement. The execution of the DPL script is continued with theevaluation of the boolean expression of the loop statement. The loop statement list will beexecuted again when the expression evaluates to TRUE. Otherwise the loop statement is endedand the execution will continue with the first command following the loop statement.

    Examples:

    DPL Manual 6

  • DIgSILENT PowerFactory DPL

    O1 = S1.First();while (O1) {

    O1.Open();err = Ldf.Execute();if (err) {

    ! skip this oneO1 = S1.Next;continue;

    }O2 = S2.First();AllOk = 1;DoReport(0); !resetwhile (O2) {

    err = Ldf.Execute();if (err) {

    ! do not continueAllOk = 0;break;

    } else {DoReport(1); ! add

    }O2 = S2.Next();

    }if (AllOk) {

    DoReport(2); ! report}O1 = S1.Next();

    }

    1.2.4 Input and OutputThe input command asks the user to enter a value.

    input(var, string);

    The input command will pop up a window with the string and a input line on which the user mayenter a value. The value will be assigned to the variable var.

    The output command writes a line of text to the output window.

    output(string);

    The string may contain =-signs, followed by a variable name. The variable name will then bereplaced by the variables value.

    Example:

    input(diameter, enter diameter);output(the entered value=diameter);

    The example results in the pop up of a window as depicted inFig. 1.2.The following text will appear in the output window:

    DIgSI/dpl - the entered value=12.3400

    DPL Manual 7

  • DIgSILENT PowerFactory DPL

    Figure 1.2: The input window

    The output command is considered obsolete and has been replaced by the more versatileprintf and sprintf functions.See sprintf in 1.8.3, page 21 and printf in 1.8.3, page 21 for more information.

    1.3 Access to Other ObjectsWith the syntax for the parameter definitions, program flow and the input and output, it is alreadypossible to create a small program. However, such a script would not be able to use ormanipulate variables of external objects. It would not be possible, for instance, to write a scriptthat replaces a specific line by possibly better alternatives, in order to select the best line type.Such a script must be able to access specific objects (the specific line) and specific sets ofobjects (the set of alternative line types).

    The DPL language has several methods with which the database objects and their parametersbecome available in the DPL script:

    The most direct method is to create an object, or a reference to an object, in the DPLcommand folder itself. Such an object is directly available as object variable in the script.The variable name is the name of the object in the database.

    The general selection may be used. This method is only useful when the order in which theobjects are accessed is not important. The general selection is automatically filled when aselection is right clicked in either the single line graphic or the database browser and theoption Execute DPL script is selected.

    The list of external objects is mainly used when a script should be executed for specificobjects or selections. The list of external objects is nothing more than a list of aliases. Theexternal object list is used to select specific objects for each alias, prior to the execution ofthe script.

    1.3.1 Object Variables and MethodsIf a database object is known to the DPL command, then all its methods may be called, and allits variables are available. For example, if we want to change a load flow command in order toforce an asymmetrical load flow calculation, we may alter the parameter iopt net. This is doneby using an assignment:

    Ldf:iopt_net = 1; ! force unbalanced

    In this example, the loadflow objects is known as the objects variable Ldf.

    The general syntax for a parameter of a database object is

    DPL Manual 8

  • DIgSILENT PowerFactory DPL

    objectname:parametername

    In the same way, it is possible to get a value from a database object, for instance a result fromthe load flow calculations. One of such a result is the loading of a line object, which is stored inthe variable c:loading. The following example performs the unbalanced loadflow and reportsthe line loading:

    00. int error;01. double loading;02. Ldf:iopt_net = 1; ! force unbalanced03. error = Ldf.Execute(); ! execute load flow04. if (error) {05. exit();06. } else {07. loading = Line:c:loading; ! get line loading08. output(loading=loading); ! report line loading09. }

    This examples is very primitive but it shows the basic methods for accessing database objectsand their parameters.

    1.4 Access to Locally Stored ObjectsThe access to locally stored (references to) objects is only possible if the name of the objectqualifies as a variable name in the DPL script. It will not be possible to access an object whichname is My Loadflow\~{}1*, for instance.

    An example is shown in Fig. 1.3, where a DPL script is shown on the left which has a load flowcommand and a reference to a line in its contents folder on the right.

    Figure 1.3: DPL contents

    The example DPL script may now access these objects directly, as the objects Ldf and Line.In the following example, the object Ldf, which is a load flow command, is used in line 01 toperform a load flow.

    00. int error;01. error = Ldf.Execute();02. if (error) {03. output(Load flow command returns an error);04. exit();05. }

    In line 01, a load flow is calculated by calling the method Execute() of the loadflow command.The details of the loadflow command, such as the choice between a balanced single phase or an

    DPL Manual 9

  • DIgSILENT PowerFactory DPL

    unbalanced three phase load flow calculation, is made by editing the object Ldf in the database.Many other objects in the database have methods which can be called from a DPL script.

    The DPL contents are also used to include DPL scripts into other scripts and thus to create DPLsubroutines.

    1.5 Accessing the General Selection

    Accessing database objects by storing them or a reference to them in the DPL command wouldcreate a problem if many objects have to be accessed, for instance if we want to search the linewith the highest loading. It would be impractical to create a reference to each and every line. Amore elegant way would be to use the DPL global selection and fill it with all lines. The databasebrowser offers several ways in which to fill the DPL selection with little effort. The selection maythen be used to access each line indirectly by a DPL object variable. In this way, we may createa loop in which we search for the highest loading. This is shown in the following example.00. int error;01. double max;02. object O, Omax;03. set S;04.05. error = Ldf.Execute(); ! execute a loadflow06. if (error) exit(); ! exit on error07.08. S = SEL.AllLines(); ! get all selected lines09. Omax = S.First(); ! get first line10. if (Omax) {11. max = Omax:c:loading; ! initialize maximum12. } else {13. output(No lines found in selection);14. exit(); ! no lines: exit15. }16. O = S.Next(); ! get next line17. while (O) { ! while more lines18. if (O:c:loading>max) {19. max = O:c:loading; ! update maximum20. Omax = O; ! update max loaded line21. }22. O = S.Next();23. }24. output(max loading=max for line); !output results25. Omax.ShowFullName();

    The object SEL used in line 08 is the reserved object variable which equals the GeneralSelection in the DPL command dialog. The SEL object is available in all DPL scripts at alltimes and only one single General Selection object is valid at a time for all DPL scripts. Thismeans that setting the General Selection in the one DPL command dialog, will change it for allother DPL commands too.

    The method AllLines() in line 08 will return a set of all lines found in the general selection. Thisset is assigned to the variable S. The lines are now accessed one by one by using the setmethods First() and Next() in line 09, 16 and 22. The line with the highest loading is kept inthe variable Omax. The name and database location of this line is written to the output windowat the end of the script by calling ShowFullName().

    DPL Manual 10

  • DIgSILENT PowerFactory DPL

    1.6 Accessing External ObjectsThe DPL contents makes it possible to access external object in the DPL script. The specialgeneral selection object (SEL) is used to give all DPL functions and their subroutines access toa central selection of objects.

    Although flexible, this method would create problems if more than one specific object should beaccessed in the script. By creating references to those objects in the DPL command itself, theDPL command would become specific to the current calculation case. Gathering the objects inthe general selection would create the problem of selecting the correct object.

    To prevent the creation of calculation-specific DPL commands, it is recommended practice toreserve the DPL contents for all objects that really belong to the DPL script and which are thusindependent on were and how the script is used. Good examples are load flow and short-circuitcommands, or the vector and matrix objects that the DPL command uses for its computations.

    If a DPL script must access a database object dependent on where and how the DPL script isused, an External Object must be added to the external object list in the DPL root command.Such an external object is a named reference to a external database object. The external objectis referred to by that name. Changing the object is then a matter of selecting another object. InFig. 1.4, an example of a external object is given. This external object may be referred to in theDPL script by the name Bar1, as is shown in the example.

    Figure 1.4: DPL external object table

    Example:

    sagdepth = Bar1:u;

    1.7 Remote Scripts and DPL command Libraries

    The easiest way to develop a new DPL command is to create a new ComDpl in the currentlyactive study case and to write the script directly in that DPL object. In such a way, a DPL rootcommand is made. If this root command needs DPL subroutines, then one or more DPLcommand objects may be created in its contents. Each of these subroutines will normally also bewritten as root functions.

    The newly written DPL command with its subroutines may be tested and used in the currentlyactive study case. However, it cannot be executed when another study case is active. In order touse the DPL command in other study cases, or even in other projects, we would have to copy the

    DPL Manual 11

  • DIgSILENT PowerFactory DPL

    DPL command and its contents. This, however, would make it impossible to alter the DPLcommand without having to alter all its copies.

    The solution is in the use of remote scripts. The procedure to create and use remote scripts isdescribed as follows.

    Suppose we have created and tested a new DPL command in the currently active study case.We would like to store this DPL command in a save place and make it possible to use it in otherstudy cases and projects.This is done by the following steps:

    copy the DPL command to a library folder. This will also copy the contents of the DPLcommand, i.e. with all its DPL subroutines and other locally stored objects.

    Generalize the copied DPL command by resetting all project specific external objects. Setall interface variable values to their default values. To avoid deleting a part of the DPLcommand, make sure that if any of the DPL (sub)commands refers to a remote script, allthose remote scripts are also stored in the library folder.

    Activate another study case. Create a new DPL command object (ComDPL) in the active study case. Set the DPL script reference to the copied DPL command. Select the required external objects. Optionally change the default values of the interface variables

    Press the Check button to check the DPL script

    The Check or Execute button will copy all parts of the remote script in the library that areneeded for execution. This includes all subroutines, which will also refer to remote scripts, allcommand objects, and all other objects. Some classes objects are copied as reference, otherclasses are copied completely.

    The new DPL command does not contain a script, but executes the remote script. For theexecution itself, this does not make a change. However, more than one DPL command may nowrefer to the same remote script. Changing the remote script, or any of its local objects orsub-commands, will now change the execution of all DPL commands that refer to it.

    1.7.1 Subroutines and Calling ConventionsA DPL command object may be included in the contents of another DPL command. In that case,the included DPL subroutine may be called in the script of the enclosing DPL command. Inprinciple, this is not different from calling, for example, a load flow command from a DPL script.

    As with most other command objects, the DPL command only has one method:int Execute() ; executes the DPL script.The difference is that each DPL subroutine has different interface parameters, which may bechanged by the calling command. These interface parameters can also be set directly at callingtime, by providing one or more calling arguments. These calling arguments are assigned to theinterface parameters in order of appearance. The following example illustrates this.

    Suppose we have a DPL sub-command Sub1 with the interface section as depicted in Fig. 1.5.The calling command may then use, for example:

    DPL Manual 12

  • DIgSILENT PowerFactory DPL

    Figure 1.5: Interface section of subroutine

    ! set the parameters:Sub1:step = 5.0;Sub1:Line = MyLine;Sub1:Outages = MySelection;! execute the subroutine:error = Sub1.Execute();

    However, using calling arguments, we may also write:

    ! execute the subroutine:error = Sub1.Execute(5.0, MyLine, MySelection);

    1.8 DPL Functions and Subroutines

    The DPL syntax is very small because it mainly serves the purpose of basic operations likesimple calculations, if-them-else selections, do-while loops, etc..

    The strength of the DPL language is the possibility to call functions and to create subroutines. Afunction which can be called by a DPL command is called a method . Four types of methodsare distinguished:

    Internal methods These are the build-in methods of the DPL command. They can be calledalways.

    Set methods These methods are available for the DPL set variables.

    Object methods These methods are available for the DPL object variables.External methods These are the methods which are available for certain external DIgSILENT

    objects, such as the loadflow command, the line object, the asynchronous machine, etc.

    1.8.1 DPL Internal MethodsThe DPL program language has a small set of DPL-specific internal commands:

    Random returns a random numbervalidLDF checks for a valid loadflow resultvalidRMS checks for a valid simulation resultvalidSHC checks for a valid short-circuit resultvalidSIM checks for a valid simulation resultAllRelevant returns all calculation relevant objectsActiveCase returns the active calculation caseSummaryGrid returns the summary gridActiveProject returns the active projectWrite writes a report

    DPL Manual 13

  • DIgSILENT PowerFactory DPL

    ResetCalculation resets the calculationsPostCommand adds a command to the command pipeExe executes a commandClearCommands clears the command pipeGetLanguage returns the current languageDelete deletes the objectEchoOn Re-activates the user interfaceEchoOff Freezes (de-activates) the user-interfaceGetGraphBoard Returns the currently active Graphics BoardGetCaseCommand Returns default command objectsprintf Outputs a formatted stringsprintf Returns a formatted stringError Emits a formatted errorWarn Outputs a formatted warningInfo Outputs a formatted informationNoFinalUpdate Prevents EchoOn() at end of executionGetLocalLib Returns a local library folderGetGlobalLib Returns a global library folder

    More information about these commands can be found in the on-line manual.

    1.8.2 DPL Set MethodsSet methods are functions for the set type parameters.

    set . [SETMETHOD] ( arguments ) ;

    The following [SETMETHOD] methods are available:

    Clear removes all objects from the setIsIn searches for an object in the setAdd adds an objectRemove removes an objectCount returns the number of stored objectsFirst returns the first objectsNext returns the next objectFirstmatch returns the first matching objectNextmatch returns the next matching objectFirstFilt returns the first matching objectNextFilt returns the next matching objectSortToVar sorts the objects to a variable valueSortToClass sorts the objects to their classSortToName sorts the objects to their namesMarkInGraphics marks the objects in the graphic

    More information about these commands can be found in the on-line manual.

    1.8.3 Object MethodsThe object methods are specific for each type of object class. A result file object (ElmRes), forinstance, has a Write method, which would not make sense for a load flow command object.

    The general syntax for an object method equals that of the set method:

    object . [OBJMETHOD] ( arguments ) ;

    DPL Manual 14

  • DIgSILENT PowerFactory DPL

    The following overview lists all the non-specific [OBJMETHOD] methods which are available forall classes.

    Unom returns the nominal voltageMarkInGraphics marks the object in the graphicShowFullName prints the full database path and nameIsClass checks for a certain classAddCopy adds a copy of an objectCreateObject creates a new objectEdit opens the object dialogGetParent Returns the parent folderGetContents Returns the stored objectsHasResults returns if the object has result parametersIsRelevant Returns if the object is used for calculationsIsOutOfService Returns if the object is out of serviceGetConnectionCount Returns the number of electrical connectionsGetCubicle returns the objects cubicleMove Moves an objects to this folderIsInFeeder Returns if the object belongs to the feederVarExists Checks a variable name

    More information about these commands can be found in the on-line manual.

    The following overview lists all the available object specific [OBJMETHOD] methods. Callingthese methods for the wrong class will result in an error message.

    ComRes.ExportFullRange ComEcho.Execute ComEcho.OnComEcho.Off ComTime.ExecuteSetFilt.Get ComDpl.ExecuteIntMat.Get IntMat.SetIntMat.Init IntMat.ResizeIntMat.NRow IntMat.NColIntMat.RowLbl IntMat.ColLblIntVec.Get IntVec.SetIntVec.Init IntVec.ResizeIntVec.Size ElmCoup.CloseElmCoup.Open ElmCoup.IsOpenElmCoup.IsClosed ElmLne.HasRoutesOrSecElmLne.GetType ElmLne.IsCableElmLne.IsNetCoupling ElmLne.SetCorrTypLne.IsCable ElmLne.SetNomCurrElmRes.Clear ElmRes.WriteElmRes.Draw ElmRes.WriteDrawComRel3.Execute ComInc.ExecuteComLdf.Execute ComShc.ExecuteStaSwitch.Close StaSwitch.OpenStaSwitch.IsOpen StaSwitch.IsClosedSetFeeder.GetAll SetFeeder.GetBusesSetFeeder.GetBranches SetPath.GetAllSetPath.GetBusses SetPath.GetBranchesSetPath.AllBreakers SetPath.AllClosedBreakersSetPath.AllOpenBreakers SetSelect.AddRefSetSelect.Clear SetSelect.AllElmSetSelect.AllLines SetSelect.AllBarsSetSelect.AllLoads SetSelect.AllAsm

    DPL Manual 15

  • DIgSILENT PowerFactory DPL

    SetSelect.AllSym SetSelect.AllTypLneSetSelect.All SetSelect.GetAllSetSelect.AllBreakers SetSelect.AllClosedBreakersSetSelect.AllOpenBreakers IntForm.SetText

    More information about these commands can be found in the on-line manual.

    LoadResDatavoid LoadResData (object O)

    Loads the data of a result file (ElmRes) in memory. An error is produced when O is not aElmRes object.

    Argumentsobject O (obligatory) : The result file object

    Return valuevoid

    ExampleExample.

    object obj, res;double x;int Nvar, Nval, n, ix,iy;string str;

    obj = GetCaseCommand(ComInc);res = obj:p_resvar;

    LoadResData(res);Nvar = ResNvars(res);Nval = ResNval(res,0);printf(Nvar=%d Nval=%d, Nvar, Nval);

    ix = 0;while (ix

  • DIgSILENT PowerFactory DPL

    0.030000 : 0.12676 30.73286 12.913600.040000 : 0.12676 30.73286 12.913600.050000 : 0.12676 30.73286 12.91360

    ResNvarsint ResNvars (object O)

    returns the number of variables (columns) in result file. An error is produced when O is not aElmRes object.

    Argumentsobject O (obligatory) : The result file object

    Also see LoadResData() in 1.8.3, page 16 .

    ResNvalint ResNval (object O, int iCrv)

    returns the number of values stored in result object for curve iCrv. An error is produced whenO is not a ElmRes object.

    Argumentsobject O (obligatory) : The result file objectint iCrv (obligatory) : The curve number, which equals the variable or column number.

    Also see LoadResData() in 1.8.3, page 16 .

    GetResDataint ResNval (double x, object O, int iX, int iCrv)

    Returns a value from a result object for row iX of curve iCrv. An error is produced when O isnot a ElmRes object.

    Argumentsdouble d (obligatory) : the returned valueobject O (obligatory) : The result file objectint iX (obligatory) : the row indexint iCrv (optional) : The curve number, which equals the variable or column number, firstcolumn value (time,index, etc.) is returned when omitted.

    Return value0 when ok

    1 when iX out of bound

    2 when iCrv out of bound

    3 when invalid value is returned (INFINITY, DUMMY, etc.)Also see LoadResData() in 1.8.3, page 16 .

    GetCaseObjectobject GetCaseObject (string ClassName)

    Returns the first found object of class ClassName from the currently active calculation case.Creates such an object when no object of the given class was found in the calculation case.

    Argumentsstring ClassName (optional) : Class name of the object

    Return valueThe found or created object.

    ExampleThe following example gets the SetTime object.object Obj;Obj = GetCaseObject(SetTime);

    DPL Manual 17

  • DIgSILENT PowerFactory DPL

    if (Obj) {...

    }

    Also see GetCaseCommand() in 1.8.3, page 18 .

    GetCaseCommandobject GetCaseCommand (string ClassName)

    Returns the default command object of class ClassName from the currently active calculationcase. Creates such a command when possible and when the calculation case not yet containsa command of the given class. Initializes newly created commands according to the projectsettings.

    The buttons on the main menu for loadflow, short-circuit, transient simulation, etc. also openthe corresponding default command from the currently active study case. Using GetCaseC-ommand() in a DPL script will return the same command.

    Argumentsstring ClassName (optional) : Class name of the command

    Return valueThe found or created command.

    ExampleThe following example executes the default loadflow command.

    object Com;Com = GetCaseCommand(ComLdf);if (Com) {

    Com.Execute();}

    Also see GetCaseObject() in 1.8.3, page 17 .

    EchoOnvoid EchoOn ()

    Re-activates the user interface.Arguments

    noneReturn value

    voidExample

    The following example de-activates the user-interface to speed up the calculations, after whichthe user-interface is re-activated again.EchoOff();.. do some calculation ...EchoOn();

    Also see EchoOff() in 1.8.3, page 18 . Also see NoFinalUpdate() in 1.8.3, page 19 .

    EchoOffvoid EchoOff ()

    Freezes (de-activates) the user-interface. For each EchoOff(), a EchoOn() should be called.A EchoOn() is automatically executed at the end of a DPL execution, except for when NoFi-nalUpdate() has been called.

    Argumentsnone

    DPL Manual 18

  • DIgSILENT PowerFactory DPL

    Return valuevoid

    ExampleExample.

    ExampleThe following example de-activates the user-interface to speed up the calculations, after whichthe user-interface is re-activated again.EchoOff();.. do some calculation ...EchoOn();

    Also see EchoOn() in 1.8.3, page 18 . Also see NoFinalUpdate() in 1.8.3, page 19 .

    NoFinalUpdatevoid NoFinalUpdate ()

    Prevents the automatic EchoOn() at end of execution.Arguments

    noneReturn value

    voidExample

    Example.

    EchoOff();.. do some calculation ...NoFinalUpdate();

    Also see EchoOff() in 1.8.3, page 18 . Also see EchoOn() in 1.8.3, page 18 .

    GetLocalLibobject GetLocalLib ([string ClassName])

    Returns the local library for object-types of class ClassName. ClassName may be omitted, inwhich case the complete local library folder is returned.

    Argumentsstring ClassName (optional) : The classname of the objects for which the library folder issought

    Return valueThe library folder

    ExampleThe following example shows the contents of the local library for line types.

    object Lib, O;set S;Lib = GetLocalLib(TypLne);S = lib.GetContents();O = S.First();while (O) {

    O:ShowFullName();O = S.Next();

    }

    Also see GetGlobalLib in 1.8.3, page 20 .

    DPL Manual 19

  • DIgSILENT PowerFactory DPL

    GetGlobalLibobject GetGlobaleLib ([string ClassName])

    Returns the global library for object-types of class ClassName. ClassName may be omitted,in which case the complete global library folder is returned.

    Argumentsstring ClassName (optional) : The classname of the objects for which the library folder issought

    Return valueThe library folder

    ExampleThe following example shows the contents of the global library for line types.

    object Lib, O;set S;Lib = GetGlobalLib(TypLne);S = lib.GetContents();O = S.First();while (O) {

    O:ShowFullName();O = S.Next();

    }

    Also see GetLocalLib in 1.8.3, page 19 .

    Format String SyntaxThe string printing commands printf , sprintf , Error , Warn , and Info all use the sameformat string syntax.

    The format string must contain a valid place holder for every given argument. The placeholderformat is

    [flags] [width] [.precision] type

    Where type is one of the following specifiers:

    d or i For an integer value.

    e For a double value. The printed format is [ ]d.dddd e [sign]ddd where d is a single decimaldigit, dddd is one or more decimal digits, ddd is exactly three decimal digits, and [sign]is + or .

    E Identical to the e format except that E in stead of e is used.

    f For a double value. Printed format is [ ]dddd.dddd, where dddd is one or more decimaldigits. The number of digits before the decimal point depends on the magnitude of thenumber, and the number of digits after the decimal point depends on the requestedprecision.

    g For a double value. Printed format is the f or e format, whichever is more compact for thegiven value and precision. The e format is used only when the exponent of the value is lessthan 4 or greater than or equal to the precision argument. Trailing zeros are truncated, andthe decimal point appears only if one or more digits follow it.

    G Identical to the g format, except that E in stead of e, is used (where appropriate).s For a string.

    The optional flag can be one of the following specifiers:

    - : Left align the result within the given field width.

    DPL Manual 20

  • DIgSILENT PowerFactory DPL

    + : Prefix the output value with a sign (+ or )The optional width specifies the number of characters to be printed and the optional.precision specifies the number of decimals printed.

    ExampleThe following examples shows various placeholder definitions.

    double x;int i;string s;x = 123456789.987654321;i = 2468;s = hello dpl;printf(%f|%15.3f|%E|%.2e|%+f|, x,x,x,x,x);printf(%d|%6d|%-6d|, i,i,i);printf(%s|%-20s|%20s|,s,s,s);! string concat is possible:s = this;s = sprintf(%s %s, s, DPL script);! print and assign in one action:s = printf(%s %s "%s", s, is called, this:loc_name);printf(%s (again),s); ! print again:

    fWriteThe command fWrite is obsolete and has been replaced by the printf command. See printfin 1.8.3, page 21 for more information.

    ToStrThe command ToStr is obsolete and has been replaced by the sprintf command. See sprintfin 1.8.3, page 22 for more information.

    printfstring printf (String Format,String T | double X | int I, ...)

    Outputs a formatted string. The printf() command uses the C++ printf() formatting syntax.Arguments

    String Format (obligatory) : The format stringString T (optional) : string argumentdouble X (optional) : double argumentint I (optional) : int argument

    Return valueThe formatted string

    The output format is defined by the format string. The passed arguments and the passed formatstring must match. An error message will be produced when, for instance, a format string for twostrings is used together with three doubles.

    See the format string syntax in 1.8.3, page 20 for more information.

    Also see sprintf in 1.8.3, page 22 .Also see Error in 1.8.3, page 22 .Also see Warn in 1.8.3, page 23 .Also see Info in 1.8.3, page 23 . Also see Write in 1.8.3, page 24 .

    DPL Manual 21

  • DIgSILENT PowerFactory DPL

    sprintfstring sprintf (String Format, String T | double X | int I, ...)

    Returns a formatted string. The sprintf() command uses the C++ printf() formatting syntax.Arguments

    String Format (obligatory) : The format stringString T (optional) : string argumentdouble X (optional) : double argumentint I (optional) : int argument

    Return valueThe formatted string

    ExampleThe following example redirects the output to a file. The filename is formatted from a path andthe name of the current calculation case. Redirect is an ComOp and StopRedirect is anComCl object in the DPL commandRedirect:f = sprintf(%s%s.out, c:\\MyDocuments\\results0813\\, O:loc_name);Redirect.Execute();Form.WriteOut(Lines); ! write a reportStopRedirect.Execute(); ! stop redirection

    The output format is defined by the format string. The passed arguments and the passed formatstring must match. An error message will be produced when, for instance, a format string for twostrings is used together with three doubles.

    See the format string syntax in 1.8.3, page 20 for more information.

    Also see printf in 1.8.3, page 21 .Also see Error in 1.8.3, page 22 .Also see Warn in 1.8.3, page 23 .Also see Info in 1.8.3, page 23 . Also see Write in 1.8.3, page 24 .

    Errorstring Error (String Format,String T | double X | int I, ...)

    Writes a formatted string as error message to the output window. The DPL execution willcontinue, but a pop-up error message box will appear at the end of execution.

    ArgumentsString Format (obligatory) : The format stringString T (optional) : string argumentdouble X (optional) : double argumentint I (optional) : int argument

    Return valueThe formatted string

    ExampleThe following example writes an error to the output window.

    Error(Index could not be calculated.);

    The output format is defined by the format string. The passed arguments and the passed formatstring must match. An error message will be produced when, for instance, a format string for twostrings is used together with three doubles.

    See the format string syntax in 1.8.3, page 20 for more information.

    DPL Manual 22

  • DIgSILENT PowerFactory DPL

    Also see printf in 1.8.3, page 21 .Also see sprintf in 1.8.3, page 22 .Also see Warn in 1.8.3, page 23 .Also see Info in 1.8.3, page 23 .Also see Write in 1.8.3, page 24 .

    Infostring Info (String Format, String T | double X | int I, ...)

    Writes a formatted string as information message to the output window.Arguments

    String Format (obligatory) : The format stringString T (optional) : string argumentdouble X (optional) : double argumentint I (optional) : int argument

    Return valueThe formatted string

    ExampleThe following example writes an info message to the output window.

    Info(Trying to calculate first index...);

    The output format is defined by the format string. The passed arguments and the passed formatstring must match. An error message will be produced when, for instance, a format string for twostrings is used together with three doubles.

    See the format string syntax in 1.8.3, page 20 for more information.

    Also see printf in 1.8.3, page 21 .Also see sprintf in 1.8.3, page 22 .Also see Error in 1.8.3, page 22 .Also see Warn in 1.8.3, page 23 .Also see Write in 1.8.3, page 24 .

    Warnstring Warn (String Format, String T | double X | int I, ...)

    Writes a formatted string as warning to the output window.Arguments

    String Format (obligatory) : The format stringString T (optional) : string argumentdouble X (optional) : double argumentint I (optional) : int argument

    Return valueThe formatted string

    ExampleThe following example writes a warning message to the output window.

    Warn(No loads attached: using approximation.);

    The output format is defined by the format string. The passed arguments and the passed formatstring must match. An error message will be produced when, for instance, a format string for twostrings is used together with three doubles.

    DPL Manual 23

  • DIgSILENT PowerFactory DPL

    See the format string syntax in 1.8.3, page 20 for more information.

    Also see printf in 1.8.3, page 21 .Also see sprintf in 1.8.3, page 22 .Also see Error in 1.8.3, page 22 .Also see Info in 1.8.3, page 23 .Also see Write in 1.8.3, page 24 .

    Writeint Write (string Format, [object aObj | set aSet], ...)

    Writes out a line of formatted text, using the DIgSILENT output language.Arguments

    string Format (obligatory) : The format stringobject aObj (optional) : An object which is used to get data fromset aSet (optional) : A set which is used to get objects from

    Return value0 on success, 1 on error

    The Write command is used to quickly output a line of formatted output, using the sameformatting language as is used for defining reports and result-boxes. See The DIgSILENToutput language in ??, page ?? for more information.Because data or parameters of more than object is often written out, the DIgSILENT outputlanguage has the special macro ACC(x) to distinguish between these objects. Prior toexecution, all given objects and all objects in the given sets are listed together in a single list.The ACC(x) macro returns the object with the index x in that list. The ACC (acc=access)macro can be used more than once for the same object.Interface variables of the DPL script can also be used in the format string by the DEF macro. Ifthe DPL script has ResX as an interface double, then DEF:ResX will access that variable.Example

    In the following example, two lines of output are written out. The first line only contains normaltext. The second line writes the name and loading of two lines. In this example, ACC(1) refersto the object LineA, and ACC(2) to LineBWrite(The following results are found);Write(# : #.## # , # : #.## # $N,ACC(1):loc_name,ACC(1):c:loading,[ACC(1):c:loading,ACC(2):loc_name,ACC(2):c:loading,[ACC(2):c:loading, LineA, LineB);

    Also see printf in 1.8.3, page 21 .Also see sprintf in 1.8.3, page 22 .Also see Error in 1.8.3, page 22 .Also see Warn in 1.8.3, page 23 .Also see Info in 1.8.3, page 23 .

    strftimestring strftime (String Format)

    Creates a formatted time string.Arguments

    DPL Manual 24

  • DIgSILENT PowerFactory DPL

    String Format (obligatory) : The format stringThe following formatting codes are recognized in the format string.

    %a Abbreviated weekday name%A Full weekday name%b Abbreviated month name%B Full month name%c Date and time representation appropriate for locale%d Day of month as decimal number (01 31)%H Hour in 24-hour format (00 23)%I Hour in 12-hour format (01 12)%j Day of year as decimal number (001 366)%m Month as decimal number (01 12)%M Minute as decimal number (00 59)%p Current locales A.M./P.M. indicator for 12-hour clock%S Second as decimal number (00 59)%U Week of year as decimal number, with Sunday as first day of week (00 53)%w Weekday as decimal number (0 6; Sunday is 0)%W Week of year as decimal number, with Monday as first day of week (00 53)%x Date representation for current locale%X Time representation for current locale%y Year without century, as decimal number (00 99)%Y Year with century, as decimal number%z, %Z Time-zone name or abbreviation; no characters if time zone is unknown%% Percent sign

    Return valueThe formatted time string

    ExampleThe following example shows the date.

    str = strftime(Today is %A, day %d of %B in the year %Y.);printf(%s, str);

    Output

    Today is Wednesday, day 30 of April in the year 2003.

    strlenint strlen (string S)

    returns the length of a string.Arguments

    string S (obligatory) : The string

    strcmpint strcmp (string S1, string S2, int count)

    Compares two strings.Arguments

    string S1 (obligatory) : The first stringstring S1 (obligatory) : The second stringint count (optional) : Number of characters to compare

    Return value-1 when S1 S2, for up to count characters

    0 S1 = S2, for up to count characters

    1 when S1 S2, for up to count characters

    DPL Manual 25

  • DIgSILENT PowerFactory DPL

    strcpyString strcpy (string S, int start, int count)

    copies a substring from a string.Arguments

    string S (obligatory) : The stringint start (obligatory) : The start position in Sint count (optional) : Number of characters to copy

    Return valueThe copied substring

    ExampleExample.

    string S1, S2;S1 = The brown fox;S2 = strcpy(S1, 4, 5);! S2 now equals brown

    strstrint strcpy (string S1, String S2)

    Searches for a substring in a string.Arguments

    string S1 (obligatory) : The stringstring S2 (obligatory) : The substring

    Return valueThe first position in S1 where S2 was found, or -1 when S2 was not found.

    ExampleExample.

    string S1, S2;int i;S1 = The brown fox;i = strstr(s1, brown);S2 = strcpy(S1, i, 5);! S2 now equals brown

    GetPageLenint GetPageLen (int orientation)

    Returns the number of lines per page according to the currently selected printer and papersize.

    Argumentsint orientation (obligatory) : Paper orientation: 0: landscape, 1: portrait

    Return valueThe maximum number of lines that can be printed on a single sheet of paper.

    Deletevoid Delete (object O | set S)

    Deletes an object or a set of objects from the database. The objects are not destroyed but aremoved to the recycle bin.

    Argumentsobject O (optional) : The object to deleteset S (optional) : The set of objects to delete

    Return value

    DPL Manual 26

  • DIgSILENT PowerFactory DPL

    voidExample

    The following example removes all Dummy fuses from the network. The DummyType vari-able is a local variable in the DPL script. A set of objects-to-delete is created first and thenthat set is deleted. This has the advantage that one single entry in the recycle bin is createdwhich contains all deleted fuses. Manually restoring (undelete) the deleted fuses, in case of amistake, can then be done by a single restore command.object O;set S, Del;S = AllRelevant();O = S.Firstmatch(RelFuse);while (O) {

    if (O:typ_id=DummyType) {Del.Add(O);

    }O = S.Nextmatch();

    }Delete(Del);

    Randomdouble Random ([double x1 [,double x2]])

    Returns a pseudo random value. If x1 and x2 are omitted, a value in the range of [0 ... 1] isreturned. If only x1 is given, the possible range is [0 ... x1] and with both x1 and x2, [x1 ... x2].

    Argumentsdouble x1 (optional) : upper/lower limitdouble x1 (optional) : upper limit

    Return valueA pseudo-random number

    ExampleThe following example sets a load to a random active power prior to calculating a loadflow.

    double P;Load:plini = Random(1.2, 2.3);Ldf.Execute();

    validLDFint validLDF ()

    Checks to see if the last load flow results are still valid and available.Arguments

    noneReturn value

    0 if no load flow results are availableExample

    The following example checks if a loadflow is available, and performs one when not.

    int valid;valid = validLDF();if (.not.valid) {

    Ldf.Execute();}

    validRMSint validRMS ()

    DPL Manual 27

  • DIgSILENT PowerFactory DPL

    Checks to see if the last RMS simulation results are still valid and available.Arguments

    noneReturn value

    0 if no RMS simulation results are availableExample

    The following example checks if a RMS simulation is available, and performs one when not.

    int valid;valid = validRMS();if (.not.valid) {

    Rms.Execute();}

    validSHCint validSHC ()

    Checks to see if the last short-circuit results are still valid and available.Arguments

    noneReturn value

    0 if no short-circuit results are availableExample

    The following example checks if a short-circuit result is available, and performs one when not.

    int valid;valid = validSHC();if (.not.valid) {

    Shc.Execute();}

    validSIMint validSIM ()

    Checks to see if the last simulation results are still valid and available.Arguments

    noneReturn value

    0 if no simulation results are availableExample

    The following example checks if a simulation result is available.

    int valid;valid = validSIM();if (.not.valid) {

    output(No simulation result available);}

    AllRelevantSet AllRelevant ()

    Returns a set with all objects which together form the target for all calculations. These are theobjects that are check-marked in the database browser. The set of calculation relevant objectsis determined by the currently active study case and the currently active grids.

    Argumentsnone

    Return value

    DPL Manual 28

  • DIgSILENT PowerFactory DPL

    The set of all calculation relevant objectsExample

    The following example writes the full path and name of all calculation relevant objects in theoutput window.set S;object O;S = AllRelevant();O = S.First();while (O) {

    O.ShowFullName();O = S.Next();

    }

    ActiveCaseObject ActiveCase ()

    Returns the currently active Study Case.Arguments

    noneReturn value

    A IntCase objectExample

    The following example writes the name of the active study case to the output window.object aCase;aCase = ActiveCase();aCase.ShowFullName();

    SummaryGridObject SummaryGrid ()

    Returns the summary grid in the currently active Study Case. The summary grid is the combi-nation of all active grids in the study case.

    Argumentsnone

    Return valueA ElmNet object, or a NULL object when no grids are active

    ExampleThe following example performs a loadflow and returns the total grid active power losses.object SumGrid;SumGrid = SummaryGrid();if (SumGrid) {

    Ldf.Execute();output(Active Power Losses=SumGrid:c:LossP);

    }

    ActiveProjectObject ActiveProject ()

    Returns the currently active projectArguments

    noneReturn value

    A IntPrj objectExample

    The following example prints the name of the active project to the output window.

    DPL Manual 29

  • DIgSILENT PowerFactory DPL

    object Prj;Prj = ActiveProject();Prj.ShowFullName();

    ResetCalculationvoid ResetCalculation ()

    Resets all calculations and destroys all volatile calculation results.Arguments

    noneReturn value

    void (no return value)Results that have been written to result objects (for display in graphs) will not be destroyed. Allresults that are visible in the single line diagrams, however, will be destroyed.Example

    The following example resets all calculations.

    ResetCalculation();

    PostCommandvoid PostCommand (string Command)

    Adds a command to the command pipe in the input window. The posted commands will beexecuted after the DPL command has finished.

    Argumentsstring Command (obligatory) : The command string

    Return valuevoid (no return value)

    ExampleThe following command causes the DIgSILENT program to end after the DPL script has fin-ished.PostCommand(exit);

    Exevoid Exe (string Command)

    Immediately executes the command, bypassing the command pipe in the input window. TheDPL command will continue after the command has been executed. The Exe command isprovided for compatibility and testing purposes only and should only be used by experiencedusers.

    Argumentsstring Command (obligatory) : The command string

    Return valuevoid (no return value)

    ExampleThe following command causes the output or graphical window to be printed.

    PostCommand(pr);

    ClearCommandsvoid ClearCommands ()

    Clears the command pipe of the input window.Arguments

    noneReturn value

    void (no return value)

    DPL Manual 30

  • DIgSILENT PowerFactory DPL

    ExampleThe following command clears the input window.

    ClearCommands();

    ClearCommandsvoid ClearOutput ()

    Clears the output window.Arguments

    noneReturn value

    void (no return value)Example

    The following command clears the output window.

    ClearOutput();

    GetLanguageint GetLanguage ()

    Returns the current program language setting.Arguments

    noneReturn value

    0 = English, 1 = GermanExample

    The following example displays a different message, depending on the language.

    int err, lng;lng = GetLanguage();

    err = Ldf.Execute();if (err) {

    if (lng) {output(Loadflow command returned an error);

    } else {output(Fehler im Lastfluss Kommando);

    }exit();

    }

    GetGraphBoardSetDeskTop GetGraphBoard ()

    Returns the currently active Graphics Board.Arguments

    noneReturn value

    The graphics board objectExample

    The following example looks for an opened Graphics Board and sets its default results to theresults object named Results.

    object aGrf;! Look for opened graphics board.aGrf=GetGraphBoard();

    DPL Manual 31

  • DIgSILENT PowerFactory DPL

    if (aGrf) {! Set default results objectaGrf.SetResults(Results);

    }

    Also seeSetDeskTop.GetPage in 1.8.36, page 80SetDeskTop.SetResults in 1.8.36, page 81SetDeskTop.SetXVar in 1.8.36, page 81SetDeskTop.SetScaleX in 1.8.36, page 81SetDeskTop.SetAutoScaleX in 1.8.36, page 82SetDeskTop.SetAdaptX in 1.8.36, page 83

    Clearvoid Set.Clear ()

    Clears the set.Arguments

    noneReturn value

    voidExample

    The following example clears a set

    set Sbig;Sbig = SEL.AllLines();...Sbig.Clear();

    IsInint Set.IsIn (object O)

    Checks if the set contains object O.Arguments

    object O (obligatory) : an objectReturn value

    1 if the O is in the set.Example

    The following example collects all not selected lines.

    set Ssel, Srel, Snsel;object lne;int i;Ssel = SEL.AllLines();Srel = AllRelevant();lne = Srel.Firstmatch(ElmLne);while (lne) {

    i = Ssel.IsIn(lne);if (i=0) Snsel.Add(lne);lne = Srel.Nextmatch();

    }

    Addint Set.Add ([object O | set S])

    Adds an object or all objects from a set to the set.

    DPL Manual 32

  • DIgSILENT PowerFactory DPL

    ArgumentsOne of the following two parameter has to be givenobject O (optional) : an objectset S (optional) : a set of objects

    Return value0 on success

    ExampleThe following example collects all loads and lines and the first breaker from the general DPLselectionset S, Sbig;object O;Sbig = SEL.AllLines();S = SEL.AllLoads();Sbig.Add(S);S = SEL.AllBreakers();O = S.First();Sbig.Add(O);

    Removeint Set.Remove (object O)

    Removes an object from the set.Arguments

    object O (obligatory) : the object to removeReturn value

    0 on successExample

    The following example removes al short lines from a set

    set S;object O;double l;S = SEL.ALLLines();O = S.First();while (O) {

    l = O:dline;if (l

  • DIgSILENT PowerFactory DPL

    n = S.Count();if (n=0) {

    exit();}

    Objint Set.Obj (int Index)

    Returns the object at the given index in the set.Arguments

    int Index (obligatory) : the index of the object.Return value

    The object at the given index in the set, when Index is in range, NULL otherwise.

    FirstObject Set.First ()

    Returns the first object in the setArguments

    noneReturn value

    The first object or 0 when the set is emptyExample

    The following example writes the full names of all line in the general selection to the outputwindow.set S;object OS = SEL.AllLines();O = S.First();while (O) {

    O.ShowFullName();O = O.Next();

    }

    NextObject Set.Next ()

    Returns the next object in the setArguments

    noneReturn value

    The next object or 0 when the last object has been reachedExample

    The following example writes the full names of all line in the general selection to the outputwindow.set S;object OS = SEL.AllLines();O = S.First();while (O) {

    O.ShowFullName();O = O.Next();

    }

    DPL Manual 34

  • DIgSILENT PowerFactory DPL

    FirstmatchObject Set.Firstmatch (String WildCard)

    Returns the first object from the set which class name matches the wildcardArguments

    String WildCard (obligatory) : class name, possibly containing * and ? charactersReturn value

    The first matching object, or 0 when no such objectExample

    The following example writes all two and three winding transformers to the output window

    set S;object O;S = AllRelevant();O = S.Firstmatch(ElmTr?);while (O) {

    O.ShowFullName();O = S.Nextmatch();

    }

    Nextmatchint Set.Nextmatch ()

    Returns the next object from the set which class name matches the wildcardArguments

    noneReturn value

    The next object, or 0 when no next objectExample

    The following example writes all two and three winding transformers to the output window

    set S;object O;S = AllRelevant();O = S.Firstmatch(ElmTr?);while (O) {

    O.ShowFullName();O = S.Nextmatch();

    }

    FirstFiltObject Set.FirstFilt (String WildCard)

    Returns the first object from the set which name matches the wildcard. The wildcard maycontain (parts of the) name and classname.

    ArgumentsString WildCard (obligatory) : class name, possibly containing * and ? characters

    Return valueThe first matching object, or NULL when no first object exists.

    ExampleThe following example writes all two and three winding transformers whose name start with aT to the output windowset S;object O;S = AllRelevant();O = S.FirstFilt(T*.ElmTr?);while (O) {

    DPL Manual 35

  • DIgSILENT PowerFactory DPL

    O.ShowFullName();O = S.NextFilt();

    }

    Also see NextFilt in 1.8.3, page 36 .

    NextFiltint Set.NextFilt ()

    Returns the next object from the set which name matches the wildcard.Arguments

    noneReturn value

    The next object, or NULL when no next object exists.Example

    The following example writes all two and three winding transformers to the output window

    set S;object O;S = AllRelevant();O = S.FirstFilt(T*.ElmTr?);while (O) {

    O.ShowFullName();O = S.NextFilt();

    }

    Also see FirstFilt in 1.8.3, page 35 .

    SortToVarint Set.SortToVar (int R, string V1, , string V5)

    Sorts the objects in the set to the variable names.Sorts the objects to the values for V1. Within the sorting for V1, a sub-sorting for V2,sub-sub-sorting for V3, etc., until V5 can be performed. The sorting is from higher values tolower when R == 1, and reverse when R == 0.Arguments

    int R (obligatory) : sorting directionstring V1 (obligatory) : first variable namestring V2 (optional) : , , string V5 (optional) : 2nd..5th variable names

    Return value0 on success

    ExampleThe following example writes all lines to the output window, sorted to cable or OHL, nominalvoltage, and length.set S, Sl;object O;S = AllRelevant();Sl = S.AllLines();Sl.Sort(0, t:aohl_, t:uline, dline);O = Sl.First();while (O) {

    O.ShowFullName();O = S.Next();

    }

    DPL Manual 36

  • DIgSILENT PowerFactory DPL

    SortToClassint Set.SortToClass (int R)

    Sorts the objects in the set to their class.Sorts the objects in the set to their class name. The sorting is from A..Z when R = 0 and reversewhen R = 1.Arguments

    int R (obligatory) : sorting directionReturn value

    0 on successExample

    The following example writes all objects to the output window, sorted to classes.set S;object O;S = AllRelevant();S.SortToClass(0);O = S.First();while (O) {

    O.ShowFullName();O = S.Next();

    }

    SortToNameint Set.SortToName (int R)

    Sorts the objects in the set to their name.Sorts the objects in the set to their name. The sorting is from A..Z when R = 0 and reverse whenR = 1.Arguments

    int R (obligatory) : sorting directionReturn value

    0 on successExample

    The following example writes all objects to the output window, sorted to names.set S;object O;S = AllRelevant();S.SortToName(0);O = S.First();while (O) {

    O.ShowFullName();O = S.Next();

    }

    MarkInGraphicsvoid Set.MarkInGraphics ()

    Marks all objects in the set in the currently visible graphic by hatch crossing them.Arguments

    noneReturn value

    voidExample

    The following example will try to mark a set of lines in the single line graphic.

    DPL Manual 37

  • DIgSILENT PowerFactory DPL

    set S;object O;S = SEL.AllLines();S.MarkInGraphics();

    GetParentobject Object.GetParent ()

    Returns the parent folder.Arguments

    noneReturn value

    The parent folder object.Example

    The following example returns the folder in which a line is stored. The function GetBestLine()is an example DPL script wich returns a line.

    object Lne, Fold;Lne = GetBestLine();Fold = Lne.GetParent();...

    Also see GetContents in 1.8.3, page 42 .

    HasResultsvoid Object.HasResults ()

    returns true when the object has calculated result parameters.Arguments

    noneReturn value

    true (1) or false (0)Example

    example.

    example is in preparation

    GetConnectionCountint Object.GetConnectionCount ()

    Returns the number of electrical connections.Arguments

    noneReturn value

    The number of connections.Example

    example.

    example is in preparation

    GetCubicleobject Object.GetCubicle (int N)

    returns the cubicle in which the object is stored, or NULL when the object is not stored in acubicle.

    Argumentsint N (obligatory) : The connection number.

    DPL Manual 38

  • DIgSILENT PowerFactory DPL

    Return valueThe cubicle object or NULL.

    Exampleexample.

    example is in preparation

    Movevoid Object.Move (object O | set S )

    Moves an object or a set of objects to this folder.Arguments

    object O (optional) : Object to move set S (optional) : Set of objects to moveReturn value

    0 on success, 1 on error.Example

    example.

    example is in preparation

    IsInFeedervoid Object.Function (object Feeder [, double OptNested=0] )

    Returns if the object belongs to the feeder area defined by Feeder.Arguments

    object Feeder (obligatory) : The Feeder definition object double OptNested (optional) :Nested feeders option (1 or 0)

    Return value1 if Feeder is a feeder definition and the object is in the feeder area, 0 otherwise.

    VarExistsvoid Object.VarExists (string VarName)

    Checks to see if this object has a currently valid variable called VarNameArguments

    string VarName (obligatory) : The name of the variable.Return value

    1 when VarName is the name of a currently valid variable for this object.Example

    The following example calculates the total length of cables and lines.

    double x;int i;set s;object O;s = AllRelevant();O = s.First();while (O) {

    i = O.VarExists(dline);if (i) {

    x += O:dline;}O = s.Next();

    }printf(Total length = %d, x);

    DPL Manual 39

  • DIgSILENT PowerFactory DPL

    IsNodeint Object.IsNode ()

    Returns 1 if object is a node (terminal or busbar).Arguments

    noneReturn value

    1 if object is s node, 0 otherwise

    GetSizeint Object.GetSize (string VarName,int rows,int cols)

    Returns the size of the variable VarName when this variable is a vector or a matrix.Arguments

    string VarName (obligatory) : The name of the variable int rows (obligatory) : The number ofrows for a vector or matrix int cols (optional) : The number of columns for a matrix

    Return value0 when VarName is a valid variable name, else 1.

    ExampleThe following example prints the matrix resistances from a Tower model with 2 circuits.

    int ierr;double x;int r, rows, c, cols;string s;ierr = Tower.GetSize(R_c,rows, cols);if (.not.ierr) {

    r=0; while (r

  • DIgSILENT PowerFactory DPL

    double|object X (obligatory) : The variable in which to return the resultstring VarName (obligatory) : The name of the variableint rows (obligatory) : The row number for a vector or matrixint cols (optional) : The column number for a matrix

    Return value0 when VarName is a valid variable name and row number and column number are in range,else 1.

    Examplesee GetSize in 1.8.3, page 40

    lnmstring Object.lnm (string VanName)

    Returns the long variable name.Arguments

    string VarName (obligatory) : The variable nameReturn value

    The long name.Example

    The following example prints information about the length of a line.

    string s1,s2,s3;s1 = Line.lnm(dline);s2 = Line.snm(dline);s3 = Line.unm(dline);printf(%s (%s) = %5.3f [%s],s1, s2, Line:dline, s3);

    Example output:

    Length of Line (Length) = 0.547 [km]

    Also see snm in 1.8.3, page 41Also see unm in 1.8.3, page 41

    snm

    string Object.snm (string VanName)Returns the short variable name. By default, the short name equals the long variable name.In some cases, the variable also has a short name which is used to save space in reports ordialogs.

    Argumentsstring VarName (obligatory) : The variable name

    Return valueThe short name.

    Examplesee lnm in 1.8.3, page 41

    Also see unm in 1.8.3, page 41

    unm

    string Object.unm (string VanName)Returns the unit of the variable.

    Argumentsstring VarName (obligatory) : The variable name

    Return valueThe unit name.

    Example

    DPL Manual 41

  • DIgSILENT PowerFactory DPL

    see lnm in 1.8.3, page 41

    Also see snm in 1.8.3, page 41

    GetContentsset Object.GetContents ()

    Returns the set of objects that are stored in the object. Returns an empty set when if theobjects container is empty or if the object is not capable of storing objects.

    Argumentsnone

    Return valueThe set of objects

    ExampleThe following example collects all terminals that are stored in line objects.set S, Lns, Trms;object O;Lns = SEL.AllLines();O = Lns.First();while (O) {

    S = O.GetContents();O = S.Firstmatch(ElmTerm);while (O) {

    Trms.Add(O);O = S.Nextmatch();

    }O = Lns.Next();

    }

    Unomdouble Object.Unom ()

    Returns the nominal voltage of the object.Arguments

    noneReturn value

    The nominal voltageExample

    The following example collects all high voltage lines.

    set S, Shv;object O;double U;S = SEL.AllLines();O = S.First();while (O) {

    U = O.Unom();if (U>VoltageLevel) {

    Shv.Add(O);}O = S.Next();

    }

    MarkInGraphicsvoid Object.MarkInGraphics ()

    DPL Manual 42

  • DIgSILENT PowerFactory DPL

    Marks the object in the currently visible graphic by hatch crossing it.Arguments

    noneReturn value

    voidWhen the currently visible single line graphic does not contain the object, nothing will happen.Example

    The following example will try to mark a set of lines in the single line graphic.

    set S;object O;S = SEL.AllLines();O = S.First();while (O) {

    O.MarkInGraphics();O = S.Next();

    }

    ShowFullNamevoid Object.ShowFullName ()

    Writes the complete path and name to the output window.Arguments

    noneReturn value

    voidBecause the complete database path is written to the output window, the written names can beright clicked in the output window to edit the objects. This procedure is therefore useful forselecting objects which should be inspected or edited after the DPL script has finished.Example

    The following example will write all overloaded lines from the selection to the output window.

    set S;object O;S = SEL.AllLines();O = S.First();while (O) {

    if (O:c:loading>100.0) {O.ShowFullName();

    }O = S.Next();

    }

    IsClassint Object.IsClass (string ClassName)

    Checks to see if the object is of a certain class.Arguments

    string ClassName (obligatory) : The name of the class.Return value

    1 when the object is of the given class, 0 otherwiseExample

    The following example write all overloaded lines and transformers to the output window, wherea different maximum loading is used for lines or transformers.set S;object O;

    DPL Manual 43

  • DIgSILENT PowerFactory DPL

    int i;S = AllRelevant();O = S.First();while (O) {

    i = O.IsClass(ElmLne);if (i) {

    if (O:c:loading>0.85) O.ShowFullName();} else {

    i = O.IsClass(ElmTr2);if (i) {if (O:c:loading>0.95) O.ShowFullName();

    }}O = S.Next();

    }

    GetClassstring Object.GetClass ()

    Returns the class name of the object.Arguments

    noneReturn value

    The class name of the objectExample

    The following example checks to see if two sets start with the same class.

    object O1, O2;O1 = S1.First();O2 = S2.First();i = O1.IsClass(O2.GetClass());if (i) {

    output(Both sets start with the same class);}

    AddCopyvoid Object.AddCopy (set aSet | object aObj [, string | int NM1, ...])

    Copies a single object or a set of objects to the target object. Fold.Copy(aObj) copies objectaObj into the target object Fold, Fold.Copy(aSet) copies all objects in aSet to Fold.

    Fold.Copy(aObj, nm1, nm2, ...) will copy aObj and rename it to the result of the concatenationof nm1, nm2, etc.The target object must be able to receive a copy of the objects. The functionFold.Copy(aObj,...) returns the copy of aObj, Fold.Copy(aSet) returns Fold, when thecopy operation was successful. A NULL object is returned otherwise.

    Copying a set of objects will respect all internal references between those objects. Copying aset of lines and their types, for example, will result in a set of copied lines and line types, wherethe copied lines will use the copied line types.

    Argumentsset aSet (obligatory) : The set of objects to copyorobject aObj (obligatory) : The object to copystring | int NM1 (optional) : The first part of the new namestring | int NM2 (optional) : The next part of the new name...

    DPL Manual 44

  • DIgSILENT PowerFactory DPL

    Return valuevoid

    ExampleThe following example copies a fuse to a set of cubicles. The copies will be named Fuse Nr.0,Fuse Nr.1, etc.object target, copy;set Cubs;Cubs = SEL.GetAll(StaCubic);target = Cubs.First();while (target) {

    copy = target.AddCopy(aFuse, Fuse Nr, n);if (copy) copy.ShowFullName();target = Cubs.Next();

    }

    CreateObjectobject Object.CreateObject (string ClassNm [, string | int NM1, ...])

    Creates a new object of class ClassNm in the target object. The target object must be ableto receive an object of the given class. A fatal DPL error will occur when this is not the case,causing the running DPL command to exit. Fold.CreateObject(aClass, nm1, nm2, ...) willcreate a new object of class aClass and names it to the result of the concatenation of nm1,nm2, etc.

    Argumentsstring ClassNm (obligatory) : The class name of the object to createstring | int NM1 (optional) : The first part of the object namestring | int NM2 (optional) : The next part of the object name...

    Return valueThe created object, or NULL when no object was created

    ExampleThe following example creates a fuse in a set of cubicles. The new fuses will be named FuseNr.0, Fuse Nr.1, etc.object target;set Cubs;int n;Cubs = SEL.GetAll(StaCubic);target = Cubs.First();n = 0;while (target) {

    target.CreateObject(RelFuse, Fuse Nr, n);target = Cubs.Next();n+=1;

    }

    Editvoid Object.Edit ()

    Opens the edit dialog of the object. Command objects (like the ComLdf) will have their Exe-cute button disabled. The execution of the running DPL script will be halted until the edit dialogis closed again.Editing of DPL command objects ComDPL is not allowed.

    Argumentsnone

    Return valuevoid

    DPL Manual 45

  • DIgSILENT PowerFactory DPL

    ExampleThe following example opens a line dialog, prior to calculating a loadflow.MyLine.Edit();Ldf.Execute();

    IsRelevantint Object.IsRelevant ()

    Returns 1 if the object is currently used for calculations. Returns 0 otherwise.Arguments

    noneReturn value

    0 when not usedExample

    The following example checks if a line is used in the calculation.i = MyLine.IsRelevant();if (i) {

    MyLine.ShowFullName();}

    IsOutOfServiceint Object.IsOutOfService ()

    Returns 1 if the object is currently out of service. Returns 0 otherwise.Arguments

    noneReturn value

    0 when not out of serviceExample

    The following example checks if a line is out of service.i = MyLine.IsOutOfService();if (i) {

    MyLine.ShowFullName();}

    1.8.4 ComOutage MethodsSetObjs

    int ComOutage.SetObjs (set S)Sets the list of objects according to S.

    Argumentsset S (obligatory) : the set of objects

    Return valueO on success, 1 on error.

    GetObjobject ComOutage.GetObj (int i)

    Returns the object at position i in the list of objects.Arguments

    int i (obligatory) : the index is the list.Return value

    The object at position i, or NULL when i is out of bound.

    DPL Manual 46

  • DIgSILENT PowerFactory DPL

    1.8.5 ComSimoutage MethodsReset

    int ComSimoutage.Reset ()Resets the intermediate results of the outage simulation.

    Argumentsnone

    Return valueO on success, 1 on error.

    ExecuteCntcyint ComSimoutage.ExecuteCntcy (object O)

    Executes an (additional) ComSimoutage, without resetting results. The results of the outageanalyses will be added to the intermediate results. Object O must be a ComSimoutage object.Outage definitions in O which have already been analyzed will be ignored.

    Argumentsobject O (obligatory) : The ComSimoutage object

    Return valueO on success, 1 on error.

    AddCntcyint ComSimoutage.AddCntcy (object O, string name)

    Executes an (additional) ComOutage, without resetting results. The results of the outage anal-ysis will be added to the intermediate results. Object O must be a ComOutage object. Ifthe outage definition has already been analyzed, it will be ignored. The ComOutage will berenamed to name when name is given.

    Argumentsobject O (obligatory) : The ComOutage object string name (optional) : A name for the outage

    Return valueO on success, 1 on error.

    SetLimitsint ComSimoutage.SetLimits (double vlmin, double vlmax, double ldmax)

    Sets the limits for the outage simulation.Arguments

    double vlmin (obligatory) : The minimum voltage double vlmax (obligatory) : The maximumvoltage double ldmax (obligatory) : The maximum loading

    Return value1 always

    ExampleThe following example analyses all selected outage definitions and adds the results to theintermediate results.set s;object o;

    s = SEL.GetAll(ComOutage);o = s.First();while (o) {

    CA.AddCntcy(o);o = s.Next();

    }

    DPL Manual 47

  • DIgSILENT PowerFactory DPL

    1.8.6 IntCase MethodsActivate

    int IntCase.Activate ()Activates the study case. Deactivates other study cases first.

    Argumentsnone

    Return value0 on success, 1 on error.

    Deactivateint IntCase.Deactivate ()

    De-activates the study case.Arguments

    noneReturn value

    0 on success, 1 on error.

    1.8.7 IntPrj MethodsActivate

    int IntPrj.Activate ()Activates the project. Deactivates other projects first.

    Argumentsnone

    Return value0 on success, 1 on error.

    Deactivateint IntPrj.Deactivate ()

    De-activates the project.Arguments

    noneReturn value

    0 on success, 1 on error.

    1.8.8 TypAsm MethodsCalcElParams

    int typAsm.CalcElParams ()Calculates the electrical parameters from the input data.

    Argumentsnone

    1.8.9 TypAsmo MethodsCalcElParams

    int typAsmo.CalcElParams ()Calculates the electrical parameters from the input data.

    DPL Manual 48

  • DIgSILENT PowerFactory DPL

    Argumentsnone

    1.8.10 Elmfeeder MethodsGetAll

    set Elmfeeder.GetAll (int iNested)Returns a set with all objects belonging to this feeder.

    Argumentsint iNested (optional) : In case of nested feeders, all elements will be returned when iNested=1,otherwise only the objects up to the next feeder will be returned.

    Return valueThe set of feeder objects.

    GetBusesGetBranchesGetNodesBranches

    set Elmfeeder.GetBuses/GetBranches/GetNodesBranches (int iNested)Returns a set with all Buses and/or Branches belonging to this feeder.

    Argumentsint iNested (optional) : In case of nested feeders, all elements will be returned when iNested=1,otherwise only the objects up to the next feeder will be returned.

    Return valueThe set of feeder objects.

    GetObjsset Elmfeeder.GetObjs (string ClassNameint iNested)

    Returns a set with all objects of class ClassName which belong to this feeder.Arguments

    int iNested (optional) : In case of nested feeders, all elements will be returned when iNested=1,otherwise only the objects up to the next feeder will be returned.

    Return valueThe set of feeder objects.

    1.8.11 ComNmink MethodsAddRef

    void ComNmink.AddRef ([object O | set S])Adds shortcuts to the objects to the existing selection

    ArgumentsOne of the following two parameter has to be givenobject O (optional) : an objectset S (optional) : a set of objects

    Return valuevoid

    ExampleThe following prepares and executes an outage simulation for all high loaded lines.

    PrepOut.Clear();S = AllRelevant();O = S.Firstmatch(ElmLne);

    DPL Manual 49

  • DIgSILENT PowerFactory DPL

    while (O) {if (O:c:loading>75) {

    PrepOut.AddRef(O);}O = S.Nextmatch();

    }PrepOut.Execute();

    Clearvoid ComNmink.Clear ()

    Empties the selection.Arguments

    noneReturn value

    voidExample

    The following example creates a selection of all loads.

    PrepOut.Clear();S = AllRelevant();O = S.Firstmatch(ElmLne);while (O) {

    if (O:c:loading>75) {PrepOut.AddRef(O);

    }O = S.Nextmatch();

    }PrepOut.Execute();

    GetAllSet ComNmink.GetAll (String ClassName)

    Returns all objects which are of the class ClassName.Arguments

    String ClassName (obligatory) : The object class name.Return value

    The set of objectsExample

    The following example writes all three winding transformers in the preparation command to theoutput window.set S;object O;S = Prep.GetAll(ElmTr3);O = S.First();while (O) {

    O.ShowFullName();O = S.Next();

    }

    1.8.12 ElmComp MethodsSlotupd

    int ElmComp.Slotupd ()

    DPL Manual 50

  • DIgSILENT PowerFactory DPL

    Performs a slot update for the composite model, to automatically select available models forthe slots.

    Argumentsnone

    Return value0

    Example

    1.8.13 ComRes MethodsExportFullRange

    int ComRes.ExportFullRange ()Executes the export command for the whole data range.

    Argumentsnone

    Return value1

    ExampleThe following example exports a range of results

    object O;set S;S = SEL.GetAll(ElmRes);O = S.First();while (O) {

    Export:pResult = O;Export.ExportFullRange();O = S.Next();

    }

    FileNmResNmint ComRes.FileNmResNm ()

    Sets the filename for the data export.Arguments

    noneReturn value

    1

    1.8.14 ComEcho MethodsOn

    int ComEcho.On ()Turns on the user interface

    ComEcho.On() is obsolete. Use the internal command EchoOn() instead.

    Argumentsnone

    Return value0 on success

    ExampleThe following example turns off the user interface, calls a subroutine and turns it back on again.

    DPL Manual 51

  • DIgSILENT PowerFactory DPL

    aEcho.Off();PerformCalculation();aEcho.On();

    Offint ComEcho.Off ()

    Turns off the user interface

    ComEcho.Off() is obsolete. Use the internal command EchoOff() instead.

    Argumentsnone

    Return value0 on success

    ExampleThe following example turns off the user interface, calls a subroutine and turns it back on again.

    aEcho.Off();PerformCalculation();aEcho.On();

    1.8.15 SetTime MethodsDate

    void SetTime.Date ()Sets the current date.

    Argumentsnone

    Return valuenone

    ExampleThe following example executes a load flow for 14:30 at the current day (the computers systemdate).object Time, Com;

    Time = GetCaseObject(SetTime);Com = GetCaseCommand(ComLdf);

    Time.Date();Time:hour = 14;Time:min = 30;Com.Execute();

    Timevoid SetTime.Time ()

    Sets the current time.Arguments

    noneReturn value

    noneExample

    The following example executes a load flow for the current time and date (the computers systemtime).

    DPL Manual 52

  • DIgSILENT PowerFactory DPL

    object Time, Com;

    Time = GetCaseObject(SetTime);Com = GetCaseCommand(ComLdf);

    Time.Date();Time.Time();Com.Execute();

    1.8.16 IntMon MethodsPrintVal

    void IntMon.PrintVal ()Prints the values of the selected variables to the output window.

    Argumentsnone

    Return valuenone

    PrintAllValvoid IntMon.PrintAllVal ()

    Prints a description for all available variables to the output window.Arguments

    noneReturn value

    none

    NVarsint IntMon.NVars ()

    returns the number of selected variables or, more exact, the number of lines in the variableselection text on the second page of the IntMon dialog, which should contain one variablename per line.

    Argumentsnone

    Return valueThe number of selected variables.

    Example

    GetVarstring IntMon.GetVar (int row)

    Returns the variable name on the given row of the variable selection text on the second pageof the IntMon dialog, which should contain one variable name per line.

    Argumentsnone

    Return valueThe variable name.

    Example

    DPL Manual 53

  • DIgSILENT PowerFactory DPL

    RemoveVarint IntMon.RemoveVar (string name)

    Removes the variable name from the list of selected variable names.Arguments

    The variable name.Return value

    1 when the variable name was not found, 0 otherwise.Example

    ClearVarsint IntMon.ClearVars ()

    Clears the list of selected variable names.Arguments

    noneReturn value

    noneExample

    AddVarint IntMon.AddVar (string name)

    Appends the variable name to the list of selected variable names.Arguments

    The variable name.Return value

    noneExample

    1.8.17 SetFilt MethodsGet

    Set SetFilt.Get ()Returns a container with the filtered objects.

    Argumentsnone

    Return valueThe set of filtered objects

    ExampleThe following example shows the names of objects filtered by the FiltLongLines.SetFilt filterset S;object O;S = FiltLongLines.Get();O = S.First();

    DPL Manual 54

  • DIgSILENT PowerFactory DPL

    while (O) {O.ShowFullName();O=S.Next();

    }

    1.8.18 ComDpl MethodsExecute

    int ComDpl.Execute (user defined arguments)Executes an External DPL script as a subroutine.

    Argumentsuser defined arguments

    Return value0 on success

    ExampleThe following example performs a loadflow and calls the DPL subroutine CheckVoltages tocheck the voltage conditions.int err;err = Ldf.Execute();if (.not.err) err = CheckVoltages(0.94, 1.05);if (err) printf(Voltage conditions are violated);

    1.8.19 IntMat MethodsGet

    double IntMat.Get (int row, int col)Returns the (row, col) value from the matrix. An run-time error will occur when row or col areout of range.

    Argumentsint row (obligatory) : row in matrix: 1..NRow()int col (obligatory) : column in matrix: 1..NCol()

    Return valueValue in matrix.

    ExampleThe following example multiplies two matrices

    int r,c,z,s,s1r,s2c;double v1,v2,v;s = M1.NCol();r = M2.NRow();if (sr) {exit();}s1r = M1.NRow();s2c = M2.NCol();M3.Init(s1r,s2c);r=1;while (r

  • DIgSILENT PowerFactory DPL

    }M3.Set(r,c,v);c+=1;

    }r+=1;

    }

    Setint IntMat.Set (int row, int col, double V)

    Set the value at position (row,col) in the matrix to V. The matrix is automatically resized ifnecessary.

    Argumentsint row (obligatory) : row number: 1..NRows()int col (obligatory) : col number: 1..NCols() double Vj (obligatory) : value

    Return value0 on success

    ExampleSee IntMat.Get in 1.8.19, page 55 for an example

    Initint IntMat.Init (int NRows, int NCols)

    Initializes the matrix. The size is set to (NRows, NCols), all values are set to 0.Arguments

    int NRows (obligatory) : number of rowsint NCols (obligatory) : number of columns

    Return value0 on success

    ExampleSee IntMat.Get in 1.8.19, page 55 for an example

    Resizeint IntMat.Resize (int NRows, int NCols)

    Resizes the matrix. Existing values will not be changed. Added values will be set to 0.Arguments

    int NRows (obligatory) : number of rowsint NCols (obligatory) : number of columns

    Return value0 on success

    ExampleThe following example gets a value from the matrix, possibly resizing it first.

    int Nc,Nr,x,y;Nr = Mat.NRows();Nc = Mat.NCols();x=5;y=3;if ({x>Nr}.or.{y>Nc}) {

    Mat.Resize(x,y);}v = Mat.Get(x,y);

    NRowint IntMat.NRow ()

    DPL Manual 56

  • DIgSILENT PowerFactory DPL

    Returns the number of rows in the matrix. The function NRow() replaces the obsolete functionSizeX().

    Argumentsnone

    Return valueThe number of rows

    ExampleSee IntMat.Get in 1.8.19, page 55 for an example

    NColint IntMat.NCol ()

    Returns the number of columns in the matrix. The function NCol() replaces the obsoletefunction SizeY().

    Argumentsnone

    Return valueThe number of columns

    ExampleSee IntMat.Get in 1.8.19, page 55 for an example

    RowLblint IntMat.RowLbl (String S, int R)

    Sets the label of the Rth row.Arguments

    String S (obligatory) : Labelstringint R (obligatory) : Number of the row

    Return value0 on success

    ExampleThe following example labels some rows.

    Mat.RowLbl(overloaded,1);Mat.RowLbl(overvoltage,2);Mat.RowLbl(undervoltage,3);

    ColLblint IntMat.ColLbl (String S, int C)

    Sets the label of the Cth column.Arguments

    String S (obligatory) : Labelstringint C (obligatory) : Number of the column

    Return value0 on success

    ExampleThe following example labels some columns.

    Mat.ColLbl(transformers,1);Mat.ColLbl(lines,2);Mat.ColLbl(busbars,3);

    1.8.20 IntVec MethodsGet

    DPL Manual 57

  • DIgSILENT PowerFactory DPL

    double IntVec.Get (int i)Returns the value at index i.

    Argumentsint i (obligatory) : Vector index.

    Return valueValue at index i.

    ExampleThe following example adds two vectors.

    int i,j;double v1,v2;i = Vec1.Size();j = Vec2.Size();if (ij) {

    output(invalid operation);exit();

    }Vec3.Init(i);i=1;while (i

  • DIgSILENT PowerFactory DPL

    Return value0 on success

    ExampleThe following example adds a value to a dynamically scaled vector.

    int i,s;i = 5;s = Vec.Size();if (i>s) {

    Vec.Resize(i);}Vec.Set(i,V);

    Sizeint IntVec.Size ()

    Returns the size of the vector.Arguments

    noneReturn value

    The size of the vectorExample

    See IntVec.Get in 1.8.20, page 57 for an example

    1.8.21 ElmCoup MethodsClose

    int ElmCoup.Close ()Closes the buscoupler

    Argumentsnone

    Return value0 on success

    ExampleThe following example gathers all open couplers before closing them.

    int opn;set S, So;