| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimPowerSystems |
| Contents | Index |
| Learn more about SimPowerSystems |
| On this page… |
|---|
Choosing an Integration Algorithm |
Simulink software provides a variety of solvers. Most of the variable-step solvers work well with linear circuits. However circuits containing nonlinear models, especially circuits with circuit breakers and power electronics, require stiff solvers.
Best accuracy and fastest simulation speed is usually achieved with ode23tb.
Solver | ode23tb |
Relative tolerance | 1e-4 |
Absolute tolerance | auto |
Maximum step size | auto |
Initial step size | auto |
Solver reset method | fast |
Normally, you can choose auto for the absolute tolerance and the maximum step size. In some occasions you might have to limit the maximum step size and the absolute tolerance. Selecting too small a tolerance can slow down the simulation considerably. The choice of the absolute tolerance depends on the maximum expected magnitudes of the state variables (inductor currents, capacitor voltages, and control variables).
For example, if you work with high-power circuit where expected voltage and currents are thousands of volts and amperes, an absolute tolerance of 0.1 or even 1.0 would be sufficient for the electric states. However, if your electrical circuit is associated with a control system using normalized control signals (varying around 1), the absolute tolerance is imposed by the control states. In this case, choosing an absolute tolerance of 1e-3 (1% of control signal) would be appropriate. If, on the other side, you are working with a very low power circuit with expected currents of milliamperes, you should probably set the absolute tolerance to 1e-6.
Note Usually, keeping the Solver reset method parameter of the ode23tb solver to its default value (Fast) will give best simulation performance. However, for some highly nonlinear circuits it may be necessary to set this parameter to Robust. When you build a new model, we recommend that you try both the Robust and the Fast reset methods. If you do not notice a difference in simulation results, then keep the Fast method, which provides fastest simulation speed. |
Three methods are available for continuous simulation of switches and power electronic devices:
Purely resistive switch — The switch is modeled as a current source and is part of the linear circuit. The state-space model of the circuit is recalculated at each switch opening or closing. When the switch is in series with an inductive element, a snubber is required.
Ideal switch — The switch is modeled using the Ideal Switching Device method, described in the next section. The state-space model of the circuit is recalculated at each switch opening or closing. Contrary to the above method, snubbers are not required.
Inductive switch — The switch contains a series inductance (Diode and Thyristor with Lon > 0, IGBT, MOSFET, or GTO). The switch is simulated as a current source driven by voltage across its terminals. The nonlinear element (with a voltage input and a current output) is then connected in feedback on the linear circuit, as shown in the Interconnection of Linear Circuit and Nonlinear Models.
Modeling switches, such as circuit breakers or power electronic devices, as current sources implies that the on-state switch resistance Ron cannot be zero. Also, as switches are modeled by a current source, they cannot be connected in series with an inductive circuit or with another switch or current source. In such a case, you must add a circuit (R or RC snubber) in parallel with the switches so that their off-state impedance has a finite value. If the real circuit does not use snubbers, or if you want to simulate ideal switches with no snubber, you must at least use resistive snubbers with a high resistance value in order to introduce a negligible leakage current. The drawback of introducing such high-impedance snubbers is that the large difference between the on-state and the off-state switch impedance produces a stiff state-space model. For example, if a 1 H inductance is connected to a voltage source by a switch having a on-state resistance Ron= 0.001 ohms and a snubber resistance Rs= 1e6 ohms, the time constant L/R of this first order circuit varies from 1000 s when the switch is closed to 1 µs when the switch is open. If you simulate this circuit with a continuous solver, such a wide range of time constants requires a variable-step stiff solver such as ode23tb. The model stiffness will affect the simulation speed. If the snubber resistances are too large, the solver may become extremely slow or even fail to find a solution. If you are using a discretized model, you may observe numerical oscillations if your sample time is too large.
When you model switches using the Ideal Switching Device method, snubbers are not required. To enable this method:
Open the Powergui dialog and select Configure parameters. The Powergui block parameters dialog box opens.
In the Solver tab of this dialog box, set the Simulation type parameter to Continuous and select Enable use of ideal switching devices.
Additional options are displayed, allowing you to disable switch snubbers, as well as their Ron resistance (Ron=0) and their forward voltage (Vf=0) when applicable.
You can select Disable snubbers in switching devices, which is a convenient way of disabling snubbers of all switches. Otherwise, you may disable individually snubbers of selected switches by specifying Rs=inf in their block menu. You can also simulate perfectly ideal switches by disabling the resistances (Ron) and the forward voltages (Vf).
Eliminating the snubbers reduces the circuit stiffness and lets you use a non-stiff solver, for example, ode45 instead of ode23tb, and achieve correct results and good simulation speed.
Assuming a circuit containing nx states, ns switches, and ny voltage or current outputs, the software determines:
nx state derivatives to be computed from the A and B matrices of
![]()
ns switch variables (either voltages across open switches or currents through closed switches)
ny output variables to be computed from the C and D matrices of
![]()
Therefore a total of nx + ns + ny equations is obtained.
Unknown variables are state derivatives dx/dt, outputs y, and switch variables (switch voltages or switch currents). Known variables are state variables x and inputs u (voltage sources or current sources).
As the switch status (open or closed) is undetermined, circuit equations are expressed using both switch voltages (vD1, vD2) and switch currents (iD1, iD2).
These equations express Kirchhoff current laws (KCL) at circuit nodes and Kirchhoff voltage laws (KVL) for the independent loops. These equations are completed by the output equations.
Computation of the state-space model is incorporated in an S-function and performed "on the fly" each time a switch status is changing. To get a listing of the circuit equations in the Command window, select the Display circuit differential equations check box in the Solver tab of Powergui block parameters dialog box.
Continuous Solver Required. The Ideal Switching Device method is not supported with discretized models.
Specifications of Snubber Values. This method has been primarily developed to avoid use of snubbers across switches; however, the method works when you use snubbers. For example, models of the Power Electronic Models demos will work when you keep snubbers, Ron and Vf in service.
For discretized models, change the Simulation type from Discrete to Continuous and select Enable use of ideal switching devices. Then specify a continuous solver (recommended solver: ode23tb with relative tolerance 1e-4).
If you specify resistive snubber values that are too large, the circuit model may become badly conditioned and cause the simulation to stop. In such a case, reduce snubber resistances so that the resulting leakage current remains acceptable (for example 0.01% to 0.1% of switch nominal current).
Specification of Ron When Vf is Greater Than Zero. In some circuits, using switches with a forward voltage Vf greater than zero and Ron=0 may cause simulation to stop and display an error message due to a State-Source dependency. To avoid this problem, specify a small Ron value.
Consider the full-wave rectifier shown in the following figure.
Full-Wave Rectifier

When you simulate this circuit without using the ideal switching method, you must use snubbers across diodes D1 and D2 because these elements are connected in series with inductances (transformer leakage inductances of the two secondary windings and filter inductance L). Otherwise, when you start the simulation you will get an error message.
Using the powerlib library, build the following model.

Use the following parameters, which are typical for a 60 W, 120 Vac / 24 Vdc converter.
Voltage Source block Vs:
Amplitude | 120*sqrt(2) |
Phase | 0 |
Frequency | 60 |
Linear Transformer block Tr:
Units | SI |
Nominal power and frequency | 60, 60 |
Winding 1 parameters | 120, 0, 0 |
Winding 2 parameters | 20, 0, 0.01 |
Winding 3 parameters | 30, 0, 0.01 |
Magnetization resistance and reactance | inf, inf |
Series RLC Branch blocks, L, C, and R:
R | 0.2 |
L | 500e-6 |
C | 10 |
Set the Simulation type parameter of the Powergui block to Continuous, and define the following solver:
Type | Variable-step |
Solver | ode23tb |
Relative tolerance | 1e-4 |
Solver reset method | Fast |
Stop time | 0.1 |
Other parameters | auto |
Start the simulation. You should get the following waveforms.

Now, increase the snubber resistance by specifying Rs = 1e8 Ω in the two diode blocks and simulate again. Note that when using such high snubber resistances with default solver parameters, simulation results become incorrect. In order to get correct results, you must increase the solver accuracy by either decreasing the Relative tolerance to 1e-6, limiting the Max step size to 1e-6, or setting the Solver Reset Method to Robust.
When you try to get rid of snubbers in large circuits containing many power electronic devices, reduction of solver tolerances may result in unacceptable simulation time. In some circumstances, the solver may even fail to find a solution.
Open the Powergui block parameters dialog box and select Enable use of ideal switching devices check box. Select Disable snubbers in switching devices and click OK. Make sure that your solver parameters are as shown in the previous section. Simulate and observe that waveforms are practically unchanged.
To simulate perfectly ideal switches you can disable the diode resistances (Ron) and the forward voltages (Vf). Open the Powergui block parameters dialog box and select the two corresponding parameters. Simulate and observe that setting Ron and Vf to zero has little impact on waveforms.
Eliminating the snubbers has reduced the circuit stiffness and using the ode45 solver instead of ode23tb produces correct results and good simulation speed. If you attempt to use the ode45 solver with the original solution method, you will observe numerical oscillations unless you use a Relative tolerance of 1e-6, which results in slow simulation.
![]() | Choosing an Integration Method | Simulating Discretized Electrical Systems | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |