Check and Improve Simulation Accuracy
Check Simulation Accuracy
Simulate the model over a reasonable time span.
Reduce either the relative tolerance to 1e-4 (the default is 1e-3) or the absolute tolerance.
Simulate the model again.
Compare the results from both simulations.
If the results are not significantly different, the solution has converged.
If the simulation misses significant behavior at the start, reduce the initial step size to ensure that the simulation does not step over that behavior.
Unstable Simulation Results
When simulation results become unstable over time,
Inaccurate Simulation Results
If simulation results are not accurate:
For a model that has states whose values approach zero, if the absolute tolerance parameter is too large, the simulation takes too few steps around areas of near-zero state values. Reduce this parameter value in the Solver pane of model configuration parameters or adjust it for individual states in the function block parameters of the Integrator block.
If reducing the absolute tolerances does not improve simulation accuracy enough, reduce the size of the relative tolerance parameter. This change reduces the acceptable error and forces smaller step sizes and more steps.
Certain modeling constructs can also produce unexpected or inaccurate simulation results.
A Source block that inherits sample time can produce different simulation results if, for example, the sample times of the downstream blocks are modified (see How Propagation Affects Inherited Sample Times).
A Derivative block found in an algebraic loop can result in a loss in solver accuracy.