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
$$\dot{x}=A\xb7x+B\xb7u$$
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\xb7x+D\xb7u$$
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 (v_{D1}, v_{D2}) and switch currents (i_{D1}, i_{D2}).
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 statespace model is incorporated in an Sfunction 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.
Simulink^{®} software provides a variety of solvers. Most of the variablestep 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 

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 highpower 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 1e3 (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 1e6.
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.
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 nonstiff 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 StateSource dependency. To avoid this problem, specify a small Ron value.