Do you have an example of the digexfun interface?

Dynamic Simulation

In PowerFactory, the digexfun interface allows for continuous-time as well as discrete time models to be linked into RMS or EMT simulations: With this option you can define your own user defined DSL function (or time-continuous models). No state variables are allowed as arguments to this DSL function, thus no complex transfer functions can be implemented.

PowerFactory may call the DSL function multiple times at each time step hence special care should be taken when the DLL model contains state variables. The digexfun code should take care of these cases in the sense that the state variables should be consistently updated.   There is a folder named 'digexfun' in the installation directory of PowerFactory which contains an example with the necessary source code files for creating the digexfun.dll. The digexfun.dll enhances the function set of DSL and is read by PowerFactory at program start. The example was created and tested using Microsoft Visual C++ 6.0. The created DLL (digexfun.dll) is stored in the installation directory of PowerFactory. Please note that several digexfun_*.dll files with different names, starting with 'digexfun' can be used.

The most important files:

  • digexfun.dsw: Workspace for MS Visual C++.
  • userfunc.cpp: You may modify this file by adding the code for your function action.
  • digexfun.def: Add the new function name here, like it is shown for the already coded example functions.
  • digexfun.cpp: File needed for compiling, but you should not modify this file. It is not required to change this file to implement your own functions.
  • userfun.cpp: Contains a description on the top of the file describing the steps needed to interface your C++ function to DSL.
  • digexfun.dll: This is the DLL file itself and is located in the Power Factory installation directory.

Please note that PowerFactory loads digexfun.dll (if available) while the software starts up. Therefore the DLL is read-only while PowerFactory is running. You have to quit PowerFactory before linking the project digexfun.

The attached PowerFactory example project ExampleDigexfunMyselect.pfd includes a generic model (*.ElmDsl) which uses the function 'myselect' which is defined in the digexfun.dll, set in the file digexfun.def.

In this example an event is simply used to change the value of the parameter dbool, so that initially has the value y_2 and y_1 afterwards.

Instead of creating the DLL with Visual Studio (C compiler), it can be generated using the C-coder of Matlab (Real-Time Workshop in previous Matlab versions). However, for the necessary settings in Matlab, you would have to contact The Mathworks.