Simulating Transients


In this section you

  • Learn how to create an electrical subsystem

  • Simulate transients with a circuit breaker

  • Compare time domain simulation results with different line models

  • Learn how to discretize a circuit and compare results thus obtained with results from a continuous, variable time step algorithm

Simulating Transients with a Circuit Breaker

One of the main uses of SimPowerSystems™ software is to simulate transients in electrical circuits. This can be done with either mechanical switches (circuit breakers) or switches using power electronic devices.

First open your circuit1 system and delete the current source connected at node B2. Save this new system as circuit2. Before connecting a circuit breaker, you need to modify the schematic diagram of circuit2. You can group several components into a subsystem. This feature is useful to simplify complex schematic diagrams.

Use this feature to transform the source impedance into a subsystem:

  1. Select the two blocks identified as Rs_eq and Z_eq by surrounding them by a box with the left mouse button and use the Edit > Create subsystem menu item. The two blocks now form a new block called Subsystem.

  2. Using the Edit > Mask subsystem menu item, change the icon of that subsystem. In the Icon section of the mask editor, enter the following drawing command:


    The icon now reads Equivalent Circuit, as shown in the figure above.

  3. You can double-click the Subsystem block and look at its content.

  4. Insert a circuit breaker into your circuit to simulate a line energization by opening the Elements library of powerlib. Copy the Breaker block into your circuit2 window.

The circuit breaker is a nonlinear element modeled by an ideal switch in series with a resistance. Because of modeling constraints, this resistance cannot be set to zero. However, it can be set to a very small value, say 0.001 Ω, that does not affect the performance of the circuit:

  1. Open the Breaker block dialog box and set its parameters as follows:


    0.001 Ω

    Initial state

    0 (open)





    Switching times


  2. Insert the circuit breaker in series with the sending end of the line, then rearrange the circuit as shown in the previous figure.

  3. Open the scope U2 and click the Parameters icon and select the Data history tab. Click the Save data to workspace button and specify a variable name U2 to save the simulation results; then change the Format option for U2 to be Array. Also, clear Limit data points to last to display the entire waveform for long simulation times.

You are now ready to simulate your system.

Continuous, Variable Time Step Integration Algorithms

Open the PI section Line dialog box and make sure the number of sections is set to 1. Open the Simulation > Configuration Parameters dialog box. As you now have a system containing switches, you need a stiff integration algorithm to simulate the circuit. In the Solver pane, select the variable-step stiff integration algorithm ode23tb.

Keep the default parameters (relative tolerance set at 1e-3) and set the stop time to 0.02 seconds. Open the scopes and start the simulation. Look at the waveforms of the sending and receiving end voltages on ScopeU1 and ScopeU2.

Once the simulation is complete, copy the variable U2 into U2_1 by entering the following command in the MATLAB® Command Window.

U2_1 = U2;

These two variables now contain the waveform obtained with a single PI section line model.

Open the PI section Line dialog box and change the number of sections from 1 to 10. Start the simulation. Once the simulation is complete, copy the variable U2 into U2_10.

Before modifying your circuit to use a distributed parameter line model, save your system as circuit2_10pi, which you can reuse later.

Delete the PI section line model and replace it with a single-phase Distributed Parameter Line block. Set the number of phases to 1 and use the same R, L, C, and length parameters as for the PI section line (see Circuit to Be Modeled). Save this system as circuit2_dist.

Restart the simulation and save the U2 voltage in the U2_d variable.

You can now compare the three waveforms obtained with the three line models. Each variable U2_1, U2_10, and U2_d is a two-column matrix where the time is in column 1 and the voltage is in column 2. Plot the three waveforms on the same graph by entering the following command.

plot(U2_1(:,1), U2_1(:,2), U2_10(:,1),U2_10(:,2),

These waveforms are shown in the next figure. As expected from the frequency analysis performed during Analyze a Simple Circuit, the single PI model does not respond to frequencies higher than 229 Hz. The 10 PI section model gives a better accuracy, although high-frequency oscillations are introduced by the discretization of the line. You can clearly see in the figure the propagation time delay of 1.03 ms associated with the distributed parameter line.

Receiving End Voltage Obtained with Three Different Line Models

Discretizing the Electrical System

An important product feature is its ability to simulate either with continuous, variable step integration algorithms or with discrete solvers. For small systems, variable time step algorithms are usually faster than fixed step methods, because the number of integration steps is lower. For large systems that contain many states or many nonlinear blocks such as power electronic switches, however, it is advantageous to discretize the electrical system.

When you discretize your system, the precision of the simulation is controlled by the time step. If you use too large a time step, the precision might not be sufficient. The only way to know if it is acceptable is to repeat the simulation with different time steps and find a compromise for the largest acceptable time step. Usually time steps of 20 µs to 50 µs give good results for simulation of switching transients on 50 Hz or 60 Hz power systems or on systems using line-commutated power electronic devices such as diodes and thyristors. You must reduce the time step for systems using forced-commutated power electronic switches. These devices, the insulated-gate bipolar transistor (IGBT), the field-effect transistor (FET), and the gate-turnoff thyristor (GTO) are operating at high switching frequencies.

For example, simulating a pulse-width-modulated (PWM) inverter operating at 8 kHz would require a time step of at most 1 µs.

You now learn how to discretize your system and compare simulation results obtained with continuous and discrete systems. Open the circuit2_10pi system that you saved from a previous simulation. This system contains 24 electrical states and one switch. Open the Powergui, click Configure Parameters, and in the Powergui block parameters dialog box set Simulation type to Discrete. Set the sample time to 25e-6 s. When you restart the simulation, the power system is discretized using a 25 µs sample time.

Open the Simulation > Configuration Parameters dialog box and on the Solver pane set the simulation time to 0.2 s. Start the simulation.

    Note   Once the system is discretized, there are no more continuous states in the electrical system. So you do not need a variable-step integration method to simulate. In the Simulation > Configuration Parameters > Solver pane, you could have selected the Fixed-step and Discrete (no continuous states) options and specified a fixed step of 25 µs.

To measure the simulation time, you can restart the simulation by entering the following commands.

tic; sim(gcs); toc

When the simulation is finished the elapsed time in seconds is displayed in the MATLAB Command Window.

To return to the continuous simulation, open the Powergui block parameters dialog box and set Simulation type to Continuous. If you compare the simulation times, you find that the discrete system simulates approximately 3.5 times faster than the continuous system.

To compare the precision of the two methods, perform the following three simulations:

  1. Simulate a continuous system.

  2. Simulate a discrete system, with Ts = 25 µs.

  3. Simulate a discrete system, with Ts = 50 µs.

For each simulation, save the voltage U2 in a different variable. Use respectively U2c, U2d25, and U2d50. Plot the U2 waveforms on the same graph by entering the following command.

plot(U2c(:,1), U2c(:,2), U2d25(:,1),U2d25(:,2),

Zoom in on the 4 to 12 ms region of the plot window to compare the differences on the high-frequency transients. The 25 µs compares reasonably well with the continuous simulation. However, increasing the time step to 50 µs produces appreciable errors. The 25 µs time step would therefore be acceptable for this circuit, while obtaining a gain of 3.5 on simulation speed.

Was this topic helpful?