# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

## Simulating with Continuous Integration Algorithms

### 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

`$\stackrel{˙}{x}=A·x+B·u$`
• `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

`$y=C·x+D·u$`

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 Diagnostic Viewer, select the Display circuit differential equations check box in the Solver tab of the Powergui block parameters dialog box.

### 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 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

In the Preferences tab of the powergui block, you can select Disable snubbers in switching devices, which disables snubbers of all switches in your model. 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.

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).

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.