-
Notifications
You must be signed in to change notification settings - Fork 19
2. Quickstart Guide PowerFactory
Developed with PowerFactory 2025 SP4 with Python 3.11 dependent on Python packages as specified in requirements.txt
The dependencies can be installed by executing the command "python –m pip install –r requirements.txt"
Note
An example setup of the MTB can be found in the folder setup_examples named MTB_Setup_Example.pfd. This is purely an example to showcase the setup of the MTB and the model used is not in any way representative of a compliant model or plant._
Extract or copy all test bench files into a common folder on your PC.

- Fill in the model-specific information in the 'Settings' sheet in the testcases.xlsx file. The Excel guide can be found here Quickstart Guide Excel
Note
The following are new for MTB 2.0:
-
Default P available associated with the signal mtb_s_pavail_pu, the Event Type Pavail, and the initial power available at t=0, Pavail0
-
Default Q(U) droop associated with the signal mtb_s_qudroop, the Event Type QUdroop, and the initial Q(U) droop setting at t=0, QUdroop0. This previously was a constant V droop associated with the constant mtb_c_vdroop
-
Main Transformer Grounded is associated with the signal mtb_s_mtrfrgnd and initial main transformer grounding configuration, MtrfrGnd0. No event is associated with this signal.
- Edit the config.ini file if required.
-
Under the [General] section,
- Casesheet path specifies the file path of the testcases.xlsx sheet to be used
- Export folder specifies the location where the PSCAD .psout, output files will be moved to after the PSCAD simulations are done
-
Under the [Python] section,
- Python path specifies any additional paths to be added to the Python path, see System Requirements
-
Under the [PowerFactory] section,
- Parallel enables PowerFactory parallel task automation
- QDSL copy grid specifies the grid where the QDSL controller will be copied to as a workaround as QDSL controller sometimes fails when not in same grid as calc. relevant statgens. Leave blank to disable.
-
Right-click the Network Data folder in your PowerFactory model and Import MTB.pfd from the common folder. The project must be inactive to import using this method. Note: The MTB grid naming must remain MTB.
-
Activate the MTB grid and replace the external grid with MTB. Remember to deactivate the existing external grid, as well as any linked dynamic control used for the external grid. Do this by selecting the elements and marking them as Out of Service.
-
Connect the cubicle at POC, formerly used for the external grid, to the element ”meas.ElmSind”. Copy the cubicle from the busbar used for the external grid and then paste the cubicle to the element ”meas.ElmSind”, Terminal j.
There are two main ways to connect the MTB to the model PPC both found in the following sections.
- The first method is to connect the MTB via the execute script, where reference signals and the corresponding models are linked.
- The second method is to assign the PPC and connect the signals to the MTB via the graphic of the MTB frame.
To add additional custom signals, please refer to 2.5 Custom signal setup
Note
The execute script has other relevant parameters regardless of the method for connecting the MTB to the model PPC. For instance the "Only Setup" and "Post_run_backup". If the value in "Only_setup" is set to 1, the MTB will only set up the selected cases and plots but not run and output any result files. If "Post_run_backup" is set to 1, the MTB will create a project version right after the MTB has been run._
Important
When utilizing the predefined case sets from testcases.xlsx,
- custom signal 1 is used as system protection (SIPS) setpoint in p.u.,
- custom signal 3 is used as system protection (SIPS) activation signal.
- Open the execute.ComPython script and add the active and reactive PPC controller signal names to the respective value rows in the Input Parameters table.
- Add the PPM and PPC controller block instances responsible for controlling the active- and reactive power references. Depending on your specific PPM and PPC configuration, this can be a single or multiple blocks, as shown in the figure below.
<\p>
For the example shown above,
- Pmax is the attribute of the DPL control block (either and input signal or parameter) that control the Maximum Power Available imit of the Power Park Module (PPM)
- Psp_ppu is the attribute of the DSL control block (either and input signal or parameter) that control the Active Power Reference in pu
- Qsp_qpu is the attribute of the DSL control block (either and input signal or parameter) that control the Reactive Power Reference in pu, for Q mode control
- QUsp_upu is the attribute of the DSL control block (either and input signal or parameter) that control the Voltage Reference at the POC in pu for Q(U) mode control
- QPFsp_pf is the attribute of the DSL control block (either and input signal or parameter) that control the Power Factor Reference at the POC for PF control mode
- QUslope is the attribute of the DSL control block (either and input signal or parameter) that control the Q-U droop value in % for Q(U) mode control
Important
Some Power Park Controllers (PPC) sets the base value of the reactive power (Q) equal to 0.33 × the base value of the active power (P) in accordance with the Danish grid codes. In these cases, the MTB reactive power reference needs to be scaled by a factor of 3.03
- Open the MTB composite frame type (this can be done by right-clicking and selecting "Mark in Graphic"). Scroll down to the "User blocks" area (shaded area in the navigation pane on the picture below) to insert the PPC active- and reactive power control block types.
Important
Using this setup method requires that the plant references needed to be connected to the User blocks are modeled as signals and not internal parameters in the Pcontrol and Qcontrol blocks of the PPC.
- Select the DSL Model type to place in the MTB Slot by editing the slot and selecting the relevant type from the project library.
Note
DSL instances are coloured green, whereas DSL (library) types are coloured red.
- This needs to be done for the PPM Active Power controller, and the PPC's Active- and Reactive power controllers, e.g.
- Use the signal wiring to connect the MTB reference signals Pref, Qref (for Q mode), Uref (for Q(U) mode), and PF (PF mode) to their respective inputs of the PPC controller's P- and Q-control blocks, and if possible, also the Pavail and Q(U)droop signals
Important
For this example, the PPM controller does not have a Pavail input signal, but only an "Pmax" parameter that can only be set via the execute script Similarly, the PPC controller does not have a Q(U)droop input, and only a "Q(U)droop" or "Q(U)slope" parameter that can only be set via the execute script
- Add the ElmDsl model instances for the PPM P-control as well as the PPC P- and Q-control at the bottom of the Net Elements in the MTB composite model "MTB.ElmComp"
The initializer_script.ComDpl is a DPL script used to configure or change arbitrary parameters or objects in the model. The script is executed for each case manually when running the MTB execute.ComPython script. Many of the input parameters are automatically setup with case specific information from the testcases.xlsx sheet. Additional input parameters and external objects can be appended if needed. To configure or change arbitrary parameters or objects, code must be input to the script tab of the object, examples could be changes for ElmGenstat parameters, changes to a ElmQdsl block based on the vmode etc. Generally the initializer_script.ComDpl is used to setup the:
- initial available power, or "Pavail0"
- active power control mode
- reactive power control modes
- initial Q-U droop value for QUmode, or "QUdroop0"
- initial grounding of the main transformer, or "MtrfrGnd0"
- Add the Pcontrol block of the PPM, the Pcontrol and Qcontrol block of the PPC, and the main transformer object to the External Objects' "object" columns.
-
If the test cases include cases where the power available is limited to a value other than the default value, the parameter in the DSL block that corresponds to this, e.g. "Irradiance" or "Pmax" have to be assigned to the "Pavail0" initial value
-
The MTB P control modes are set up with the following default values:
- 0 = No power-frequency relation, i.e. constant power
- 1 = Limited Frequency Sensitivity Mode (LFSM)
- 2 = Frequency Sensitivity Mode (FSM)
- 3 = LFSM + FSM
If the frequency sensitivity modes are controlled by a parameter value or if the input signal is not graphically connected in the MTB frame, the FSM part of the script should be uncommented, and the control mode parameter set to what it is in the Pcontrol element of the project PPC. Ensure that the FSM parameter's parameter name in the active power control module corresponds with the parameter name after Pcontrol:____. The variable name is sometimes named FSMenable or somewhere along these lines.
-
The MTB Q control modes are set up with the following default values:
- 0 = Q reference mode,
- 1 = Q(U) mode, and
- 2 = PF (cosphi) mode
If these values do not correspond with the values in the project Qmode parameter, the script must be used to change the values. To achieve this, open the script tab in the "initializer_script.ComDpl". Scroll to the bottom of the script and uncomment the section of code that assigns a new value to the Qmode parameter. Ensure that the variable name for the Qmode corresponds with the name in the PPC´s Qcontrol dsl model. It is usually named something with "mode".
-
If the testcases include cases where the Q-U droop value ischanged from the default value, the initial Q-U droop or Q-U slope has to be assigned
-
If the testcases include cases where the main transformer's grounding configuration is changed, uncomment the section of code that control the grounding configuration of the main transformer
Important
If the plant's P available or the Q(U) droop inputs are not connected as signals (see MTB connection via the MTB frame), or if these are parameters within the plant, these inputs/parameters should be initialized in the initializer script to their respective initial values, i.e. Pavail0 and QUdroop0,
This next part can be done in two ways. The first is to utilize the MTB built-in Station- and Power Frequency controllers and connect them to the inverter element. The second uses the qdsl element "initializer_qdsl" to control the inverter ElmGenstat.
- Open the Station controller under the MTB folder and add the inverter ElmGenstat to the Machines column.
- Open the Power Frequency controller, and under the Load Flow tab, add the inverter.
- To initialize the testbench, the second method uses the initializer_qdsl.ElmQdsl. The Qdsl script is located in the MTB composite frame folder. It is by default "Out of Service" and should be "put in service" before running the test bench.
- Choose a Qdsl type from the MTB library that best fits the setup of the park model and fill in the data that is not "Set by Script".
By default the "mtb_init_example_4" is selected and recommended for use. This type requires the input of the user being PPM upper current limit in p.u., the plant nominal reactive power in Mvar and the upper and lower reactive power limits of the plant in p.u. all at the bottom of the parameter pane.
- Select the load flow tap of the Qdsl block and connect the respective network elements, e.g., the park inverter (setting up the simplified model).
- Edit the "execute.ComPython" script by selecting the Python script "execute_pf.py" in the script tab. The complete file path must be defined in the field ‘Script file.’ Click the ‘…’ button and navigate to the execute_pf.py script.
OBS: There might be some issues with the script while setting up the plots and exporting the result files. Go to Tools > User Settings > Parallel Computing > Advanced to fix this. In this tab, check the box "Transfer complete project to all processes".
- Pressing Execute, the script does both simulation and plotting of results automatically.
Note: When executing the script, active variations are consolidated, meaning all changes recorded in the active variations will be applied to the Network Data Folder.
When the script is finished, the output window should look like the snapshot below, with the text ”Python Script ‘execute’ successfully executed” at the bottom.
The study cases set to "TRUE" in the testcases.xslx document should be visible in the project overview.
- All simulation results are exported to the 'Results' folder, as seen in the picture below. Each has a unique ID to match the study case. The study cases created by the MTB allow users to review all simulations in PowerFactory.
- The test bench creates a set of '.csv'-files that can be used with the MTB Plotter to plot the results and, if relevant to your project, compare them with the results from PSCAD. These can also be found in the 'Results' folder.
If you wish to record more signals or parameters from your model, like monitoring the inverter's active and reactive power output or other DSL blocks, such as protection blocks or PLLs, you can do so from the execute script.
-
Scroll down to the Measurement object inputs starting from line 18 in the Input parameters table. Here you must give your object a name and the parameter or list of parameters you wish to record the results of. See the picture below.
-
Add the object from which you want to record the signal values to the External objects table in the same script. Make sure that the object is placed in the correct Meas_obj_X line that corresponds with the chosen string in the Input parameters table:
The MTB allows for changing additional custom signals specific for a given PPC. It is possible to connect and control additional signals/parameters from the PPC or other DSL models, such as the protection block in the model either through the execute script or the MTB frame itself. The custom signals can then be changed in the testcases.xslx sheet for each case they are needed.
To setup custom signals from the execute script, rows 12-16 can be used for this.
- Input the signal you wish to control to the attribute row and the needed scaling value. The MTB works on a p.u. scale.
- Connect the object from which the signal is from in the external objects pane.
From the MTB frame graphic:
- Copy the existing slots from the User Blocks section of the frame and place them down by the Custom signals slots. You can also select a new one from the Blocks and Signals under drawing tools. The MTB frame type's Graphical Freeze Mode (the lock icon) must be unlocked in both cases.
- Connect the MTB signals to the desired signal input in the object block(s).
- Make sure that the P- and Q-control blocks are from the PPC, not the inverter when setting up the MTB.
For further questions or help, please check if the README or the Quickstart Guides contains the answer.
Otherwise, please contact the Energinet simulation model team: simuleringsmodeller@energinet.dk