Main Content

Solver Resets

The Solver Profiler logs events that cause the solver to reset its parameters because solver resets do incur computational cost. In addition to the total number of resets, you can also see a breakdown by type of reset event.

Note

A solver reset event can have multiple causes. As a result, the number ofTotal solver resetevents in theStatisticspane may be less than the sum of the solver resets of each type.

Zero-Crossing

Some zero crossing events occur at discontinuities in the signal. Consider the example model of a bouncing ball from theZero-Crossing Eventssection.

Open theex_spi_show_zcmodel and launch Solver Profiler.

The Solver Profiler records46solver resets,45of them are caused by Zero Crossing events from theex_spi_show_zc/Switchblock. The solver resets are displayed on the Step Size plot as green dots. Compare the step-size and theSolver Resethighlighting with the outputxof theSecond-Order Integratorblock, which is the height of the ball from the ground. Observe that the solver resets occur when the ball bounces off the ground.

Discrete Signal

Solver resets also occur when your model has a discrete signal driving a block with continuous states, as seen in this example model.

The discreteSine Waveblock outputs a 1 rad/s sine wave with a discrete sample timets= 2.

The Solver Profiler report shows that four solver resets occur due to discrete signals driving a continuous block. These resets occur at every execution of theSine Waveblock.

ZOH Signal

This type of solver reset occurs when a block output is not executed during a trial or minor time step and gets updated only during the integration or major time step. As a result, the block output changes discontinuously from one major time step to the other. As a result the solver resets. SeeFixed-in-Minor-Stepsample time.

This example model shows a simple plant and controller that tracks a sinusoidal reference signal. The source of this signal is aSine Waveblock whose sample time is specified to be fixed-in-minor-step.

Observe from the results of the profiling session that there are80ZOH Signalsolver resets in the simulation.

Note

When you selectContinuous Statesfor logging or enable theSaveStatesparameter, the derivative of a continuous block driven by a Fixed-in-Minor-Step signal isNaN.

This is because the drivingFixed-in-Minor-Stepblock updates its value only at every major time step. The signal driven to the continuous block is therefore discontinuous and the state is non differentiable.

The plot shows the outputs of theSine WaveandIntegratorblocks in the example model.

Tip

Solver resets caused due to ZOH signals are serious compared to solver reset events caused by discrete signals and can significantly slow down the simulation. This is because ZOH signal reset events occur at every major step of the solver. Reconfigure your simulation to avoid these resets, if needed.

Block Signal

Sometimes, the block can be configured to reset the solver when certain conditions are satisfied during its execution. Consider thesldemo_bouncemodel of a bouncing ball which can be found in theCapture the Velocity of a Bouncing Ball with the Memory Blockexample.

观察分析的结果130solver resets triggered by a block. A solver reset event can have multiple causes. In this case, zero crossings and block changes cause a solver reset event.

One setting that causes theBlock Changesolver reset event is theReinitialize dx/dt when x reaches saturationparameter. This setting is necessary to properly simulate the dynamics of a bouncing ball.

Initial Reset

When you run a simulation, the solver needs to reset its parameters for the first time. This event is shown as theInitial Resetevent in the Solver Profiler report. It occurs once at the start of the simulation.

Internal

There are some reset events that are internal to the Simulink®engine. These reset events are necessary for the engine to correctly configure itself for accurate simulation.