Simulating with Continuous Integration Algorithms

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.



Relative tolerance


Absolute tolerance


Maximum step size


Initial step size


Solver reset method


Normally, you can choose auto for the absolute tolerance and the maximum step size. In some instances 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 is 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 you are working with a very low power circuit with expected currents of milliamperes, set the absolute tolerance to 1e-6.

    Note   Usually, keeping the Solver reset method parameter of the ode23tb solver to its default value (Fast) produces the best simulation performance. However, for some highly nonlinear circuits it might 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.

Simulating Switches and Power Electronic Devices

Three methods are available for continuous simulation of switches and power electronic devices:

  • Purely resistive switch — The switch and the linear elements are simulated as a variable topology 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. The state-space model of the circuit is recalculated at each switch opening or closing. 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.

      Note   You have the choice to simulate diodes and thyristors with or without Lon internal inductance. In most applications, it is not necessary to specify an inductance Lon. However, for certain circuit topologies, you might have to specify a switch inductance Lon to help commutation.

Using the Ideal Switching Device Method

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 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 affects the simulation speed. If the snubber resistances are too large, the solver might become extremely slow or even fail to find a solution. If you are using a discretized model, you might 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:

  1. Open the Powergui dialog box. In the Solver tab, set the Simulation type parameter to Continuous.

  2. 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 disables snubbers of all switches. Otherwise, you may individually disable snubbers of selected switches by specifying Rs=inf in their block menus. 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, to achieve correct results and good simulation speed.

State-Space Equations

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


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 each time a switch status is changing.

To get a list of the circuit equations in the Command Window, select the Display circuit differential equations check box in the Solver tab of the 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 was developed to avoid use of snubbers across switches. However, the method still works when you use snubbers. For example, models of the Power Electronic Models examples will work when you keep snubbers, Ron and Vf, in service.

For discretized models, in the Powergui block, 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 might 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 might 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 Simscape™ Power Systems™ prompts an error message.

  1. Open the power_FullWaveRectifier example. The parameters are typical for a 60W, 120 Vac / 24 Vdc rectifier. Resistive snubbers (Rs = 1e6 Ω) are used across diodes.

  2. Open the Configure parameters section of the Powergui block. Clear the Enable use of ideal switching devices parameter.

  3. Set the Simulation type parameter of the Powergui block to Continuous, and define the following solver:





    Relative tolerance


    Solver reset method


    Stop time


    Other parameters


  4. Start the simulation. You see the following waveforms.

  5. Increase the snubber resistance by specifying Rs = 1e8 Ω in the two diode blocks and simulate again. When using such high snubber resistances, simulation results become incorrect. To get correct results, you must increase the solver accuracy by either limiting the Max step size to 1e-7, 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 maximum step size or solver tolerances might result in an unacceptable simulation time. In some circumstances, the solver might even fail to find a solution..

  6. Open the block parameters of the Powergui block and select Enable use of ideal switching devices parameter. Select Disable snubbers in switching devices parameter. To simulate perfectly ideal switches, you can also disable the diode resistances (Ron) and the forward voltages (Vf).

  7. Make sure that your solver parameters are as shown in 3. Simulate and observe that waveforms are correct.

  8. Eliminating the snubbers has reduced the circuit stiffness. You can now use ode45 solver instead of ode23tb.

Was this topic helpful?