Skip to content

3. Quickstart Guide PSCAD

MARVIenerginet edited this page Mar 25, 2025 · 17 revisions

System Requirements

Developed with PSCAD release 5.0.2 (2023/04/26) with Python 3.7.2 (embedded) dependent on Python packages as specified in requirements.txt

Since the script uses the embedded PSCAD Python environment, the external packages cannot be installed and imported in the standard way. The easiest way around this is the following procedure:

  1. Install Python 3.7.2
  2. Install requirements from PSCAD requirements.txt into the Python 3.7.2 installation (or a virtual environment). This can be done by executing “python -m pip install -r requirements.txt”.
  3. Adapt the path in config.ini so it points to the python 3.7.2 installations site-packages folder. The default path is C:\Program Files\Python37\Lib\site-packages.

Note: An example setup of the MTB can be found in the folder setup_examples named SimpleSolarFarm.pscx with the workspace setup in MTB_Setup_Example.pswx. 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.

3.1 Preparation

  • Extract or copy all test bench files and your model (.pscx-file) into the same common folder on your PC.



  • Edit the config.ini file, e.g., to specifiy the path of the testcases.xlsx sheet, if it is not placed within the common folder. The location of the result files is defined by the export path, along a line of other software specific settings for PSCAD itself, like the number of parallel runs with the Volley setting.

excel_settings

3.2 Model Setup in PSCAD

3.2.1 Importing the MTB into the PSCAD workspace

  • Open a workspace with all the models and libraries required for running simulations, including ETRAN libraries and any resources. In this example, the model under test is called 'SimpleSolarFarm'.
  • Load in the MTB.pslx project into the workspace. Do this by right-clicking on the Projects folder, click 'Add Existing Project...'.
  • Load in the interface.f file. Do this by right-clicking the Resources folder, click 'Add' -> 'Source Code (*.f, *.for, *.f90, *.c, *.cpp)'.
  • Load in the execute_pscad.py file. Do this by right-clicking the Resources folder, click 'Add' -> 'Script\Apps (*.py, *.exe, *.bat)'.


3.2.2 Connection of MTB block to POC

  • Disconnect and disable the power grid from the POC in the model. Make sure to keep any measurements present at POC (Shown below in the red dotted box.). Otherwise, the model might not work properly.

  • Copy the test bench from the MTB project into the model. Do this by right-clicking the MTB block and clicking 'Copy'. Then go to the model, right-click, and click 'Paste'. The last step is to connect the MTB block to the POC.


3.2.3 Connection of MTB controls to the Power Plant Controller (PPC)

3.2.3.1 MTB output signals

  • You can see the different signals the MTB outputs by right-clicking on the MTB block and selecting 'Edit Parameters...'. Then go to 'Signal outputs'

  • The different output signals are summarized below
  1. Pref signal
    The 'Pref signal' is the active power reference. It is given in per unit with a base value determined by the 'Pn' value in the 'Settings' sheet in the testcases.xlsx excel document.
  2. Qref signal
    The 'Qref signal' is the reactive power reference for both reactive power control (Q), voltage control (Qu), and power factor control (Qpf) mode. It changes its value based on the Q mode selected at the given time. It is given in per unit when in Q or Qu mode. In Q mode the base value is the 'Pn' value in the 'Settings' sheet. In Qu mode, the base value is the 'Un' value in the 'Settings' sheet. In Qpf mode the value is the desired power factor which can be from -1 to 1.
  3. Qref Q mode
    The 'Qref Q mode' signal is the reactive power reference when in reactive power control mode. It is given in per units with a base value determined by the 'Pn' value in the 'Settings' sheet.
  4. Qref Qu mode
    The 'Qref Qu mode' signal is the reactive power reference when in voltage control mode. It is given in per units with a base value determined by the 'Un' value in the 'Settings' sheet.
  5. Qref Qpf mode
    The 'Qref Qpf mode' signal is the reactive power reference when in power factor mode. The reference can take any value between -1 and 1.
  6. Qref mode 3-6
    These outputs can be used to create custom Q modes
  7. Pmode signal
    The 'Pmode signal' is an integer output determining the active power mode. The modes are:
    1. mtb_Pmode = 0: FSM and LFSM disabled
    2. mtb_Pmode = 1: LFSM enabled, FSM disabled
    3. mtb_Pmode = 2: FSM enabled, LFSM disabled
    4. mtb_Pmode = 3: FSM and LFSM enabled
  8. Qmode signal
    The 'Qmode signal' is an integer output determining the reactive power mode. The modes are:
    1. mtb_Qmode = 0: Reactive power mode (Q)
    2. mtb_Qmode = 1: Voltage mode (Qu)
    3. mtb_Qmode = 2: Power factor mode (Qpf)
  9. Custom signal 1-10
    These outputs can be used to create custom signal outputs. In the testcases.xlsx excel document they are used just like the other output signals by inserting an event. Their type names are 'Signal 1', 'Signal 2', and so on. They can be used to for example implement System Guard control or lower the available active power of solar or wind power plants.

3.2.3.2 Conversion of input signals to the PPC.

  1. Pref and Qref_Q
    In this given example the PPC takes its active and reactive power inputs in MW and Mvar. Therefore simple calculations have to be done. In the MTB project, conversion blocks are given as templates. The example plant is rated at 10 MW. The 'mtb_Pref' and 'mtb_Qref_Q' signals are therefore multiplied by 10.

  1. Qref_Qu
    The nominal voltage level 'Un' is determined by the POC. If the plant in normal operation is run at a different voltage, a conversion has to be made to the 'Qref Qu mode' signal. For example, if a plant is connected to the 150 kV level the nominal voltage is 152 kV. It might be desirable to run the plant at a higher voltage of 161.9 kV and therefore the base value in the PPC is set to 161.9 kV. If the plant is run in Qu mode the MTB sends a reference in pu based on the nominal voltage of 152 kV. A conversion factor of 152/161.9 = 0.9388 is therefore inserted to convert between the base values.

  1. Pmode and Qmode
    If the PPC takes different integer values for the P modes or Q modes than the MTB provides, X-Y tables can be used for the conversion. In this given example the PPC P modes match the MTB outputs, but the Q modes do not. The PPC takes the Qmode inputs, reactive power mode = 3, voltage mode = 1, and power factor mode = 2. It is therefore necessary to route the numbers 0->3, 1->1, 2->2. This is done with the X-Y table found in the MTB project. To set it up insert it into the model and double-click on the block. Click on the '...' button in the data table row. Change the table to match your desired output.

3.2.3.3 Connection of signals to the PPC

  1. Standard signals
  • This step is different for every model. In this example, the P, Q, Qu, and Qpf references are connected in the main canvas. The Qmode and Pmode parameters are connected inside the PPC block.
  • Insert the used adapters and make the necessary connections.

  1. System guard signals
  • For some plants system guard is a requirement. In the MTB this functionality is tested with custom signals 1 and 3. 'Signal 3' is used to enable system guard and 'Signal 1' gives the reference in per unit with a base value given by 'Pn'. In the MTB project, two adapters are given to help with the implementation. In this example, the system guard setpoint is given in percent.

  • To set up system guard insert the adapters into the main canvas and connect the signals. In this example, the signals are found in the PPC.

  1. Available power signals
  • Some MTB cases test changes in available power for solar and wind power plants. Custom signal 2 is used for this purpose. It can take any value between 0 and 1 which corresponds to 0 to 100 % available power. The MTB project contains an adapter to interface with the original P available signal already in the model. The signal is usually connected inside the inverter model. Because of this a 'Wireless Radio Link' is needed to send the signal from the main canvas into the inverter canvas.

  • An example of how to implement the adapter is detailed in the steps below.
  1. Insert the transmitter radio link into the main canvas
  2. Double-click on the inverter to go to the inverter canvas

  1. Insert the receiver radio link, logic gate, and selector into the inverter canvas

  1. Check if the receiver radio link has the correct source defined. The main canvas is usually called 'main' but can have different names. Check this by right-clicking on the main canvas and click 'Canvas Settings...'. The name of the canvas is stated in the title.

  1. Connect the original P available value to 'P_available_OriginalSignal'. Connect 'P_available_input' to the solar cell irradiance input.
  2. Scale the Pavailable signal. In this case, 1 pu corresponds to an irradiance of 1000W/m2.


3.2.4 Connection of additional MTB measurements (Optional)

  • The MTB block takes measurements at POC. It is possible to add additional measurement points in the model. This measured data will be exported alongside the POC measurements. The block required to do this is called 'Unit measurement' and can be found in the MTB project.

  • Copy and paste the block into the model and connect it to the point of interest. When pasting in the block use 'Paste Special' -> 'Paste Transfer' to avoid any issues. In this example, the unit measurement block is placed at the inverter terminals.

  • To set up the measurement block the voltage base and apparent power base have to be set. This is done by right-clicking on the block and selecting 'Edit Parameters...'. Now specify the apparent power base and voltage base. The units are in MVA and kV. In this specific example, the Sbase is 10 MVA and the Vbase is 33 kV. The 'Unit alias' parameter specifies the prefix of the output values names.

3.3 Script Execution

3.3.1 Running all selected cases (Volley mode)

  • The model is now set up and can be run. An example of a finished model can be seen below.

  • The MTB will run the cases in parallel. The amount of usable cores depends on both the computer processor and the PSCAD license available. The MTB is by default set to run with a volley count of 8. This means that 8 cases are run simultaneously. To change the volley count change the 'Volley' parameter in the config.ini file.

  • To run the simulation, right-click on the 'execute_pscad.py' script and press 'Run'.

  • You can follow along to see the progress by going to the workspace and selecting 'Simulations Sets' -> 'MTB' -> '?Model name?'. Click on a simulation task to view the preliminary results. A lot of different plots are available inside the MTB block. Double-click on the MTB block to access them. The numbering of the simulation tasks does not match the rank of the cases specified in the testcases.xlsx file. This is because the test bench intelligently chooses which cases to run in parallel based on case simulation time. This ensures that the overall simulation time is minimized. To see which simulation task corresponds to which simulation case go to the 'Script Output' tab at the bottom of PSCAD. Here the 'execute_pscad.py' script outputs the 'Rank' (given by testcases.xlsx) and the 'Task ID' (corresponding simulation task in PSCAD) alongside the 'Casename'.

3.3.2 Running individual cases (Manual mode)

  • To run individual cases right click on the MTB block and select 'Edit Parameters...'. Change the 'Mode' parameter to Manual. Select the desired 'Manual rank'. The rank corresponds to the given rank in the testcases.xlsx Excel file. To run the individual case click on 'Run' in the 'Compile And Run' section in PSCAD.

  • When simulating individual cases like this the data is not saved. To run and save an individual case the best approach is to change the testcases.xlsx Excel file to only have one case that has 'TRUE' selected. Then run the MTB as described previously with the MTB block in 'Volley' mode.

3.4 Script Execution Finished

  • Once the script has finished and the simulation runs are complete the output files can be accessed. They are found in the specified path from the config.ini file, by default 'export'. The test bench creates a set of '.csv'- and corresponding '.inf'-files that can be used with the plotter.py to plot the results and optionally compare it with results from PowerFactory. See the Quickstart Guide Plotter.

3.5 Troubleshooting

3.5.1 Wrong compiler

  • Running PSCAD with the wrong compiler might lead to errors looking like this

  • Or this

  • To change the compiler go to File -> Application Options -> Dependencies. We use the Intel fortran compilers.

3.5.2 UnicodeDecodeError

  • If the PSCAD project name or the name of the folder the project is stored in contains the letters "æ/ø/å", the execute_pscad.py script will give the following error. To fix this, change the file or folder name.