In this tutorial, you will learn how to build your first electrical circuit using the SPS library, interface it with standard Simulink® blocks, and avoid common connection errors.
The circuit we will model represents an equivalent 735-kV power system feeding a 300-km transmission line, compensated by a shunt inductor at its receiving end. A single-line diagram is used to simplify matters; only one of the three phases is represented.
The Circuit to Be Modeled
This is our end goal:
Step 1: Building the Electrical Circuit
1. Open the Library
- At the MATLAB® command prompt, enter:
sps_lib - Open a new blank model and save it (e.g.,
circuit1.slx).
2. Add the Source
- Add the
AC Voltage Sourceblock from the OPAL-RT SPS Software > Sources library.
Or - In the Simulink model, just click and start typing “three-pha…” and chose the Three-Phase Source block from OPAL-RT SPS Software/Sources
- Set the Amplitude, Phase, and Frequency. Note: The amplitude for a sinusoidal source is its peak value. In this case, use 424.4e3 * \sqrt(2) volts.
- Set Source resistance to 2 and Source inductance to 0
- Rename the block to
Vs.
3. Add the Impedances (Passives)
- Add the
Parallel RLC Branchblock from the OPAL-RT SPS Software > Passives library to act as the equivalent impedance. Or by typing “Three-Phase Parallel RLC Branch” in the Simulink model. - Set parameters and name it
Z_eq.
4. Add the Transmission Line
- Add a
PI Section Lineblock from the OPAL-RT SPS Software > Power Grid Elements library. Or by typing “Three-Phase PI…” in the Simulink model. - Concept: A PI section approximates the distributed R, L, and C parameters of a line. Set its parameters according to the diagram for a single line section.
5. Add the Load (Shunt Reactor)
- Add a
Series RLC Loadblock from the OPAL-RT SPS Software > Passives library. Or by typing “Three-Phase Serie RLC Load” in the Simulink model. - Name it
110 Mvar. - Set Vn = 424.4e3, fn = 60, P = 110e6/300, and Q_L = 110e6. Set Q_c = 0 (the capacitor icon will disappear).
Step 2: Measuring & Interfacing with Simulink
SPS blocks feature special electrical terminal ports (squares/circles). You cannot connect these directly to standard Simulink signal ports (triangles >). You need a measurement block acting as an interface.
1. Add Measurement Blocks
- Add a
Voltage Measurementblock from OPAL-RT SPS Software > Sensors and Measurements. - Name it
U1. - Connect its positive input to the node before the line, and its negative input to a
Groundblock.
2. Add Scopes and Per Unit (p.u.) Conversion
- Add a Simulink
Gainblock to convert the voltage into a normalized per unit (p.u.) system. The scaling factor K is 1 / (424.4e3 * \sqrt{2} / \sqrt{3}). - Add a
Scopeblock to the output of the Gain block. - Duplicate this entire measurement setup for the end of the line (
U2).
Step 3: The Engine (powergui)
Before you hit run, there is one mandatory block!
Add the powergui block from the SPS library to your model.
Why? The powergui block is the environment block for SPS models. It stores the equivalent Simulink circuit that represents the state-space equations of your electrical blocks. It also opens tools for steady-state analysis and initialization.
If you start the simulation without a powergui block, you will get an error.
Now, hit Run and open your scopes to see the results!
Troubleshooting: Connection Rules for Capacitors & Inductors
Pay particular attention when connecting capacitors and inductors to sources. If you get an error when starting the simulation, check for these two illegal topologies:
Error 1: Voltage source in parallel with a capacitor
You cannot connect a voltage source directly in parallel with a capacitor (or a series of capacitors).
- The Fix: Add a small resistance in series between the voltage source and the capacitors.
Error 2: Current source in series with an inductor
You cannot connect a current source in series with an inductor (or parallel inductors).
- The Fix: Add a large resistance in parallel with the inductor.

