Absolute tolerance for solver tolerance calculation
Model Configuration Pane: Solver
Specify the largest acceptable solver error as the value of the measured state approaches zero.
At each time step, the solver:
Calculates the value of each state
Estimates the error in each state calculation
Determines the acceptable error for each state using the relative tolerance, absolute tolerance, and state values
The acceptable error considered for each state on each time step is determined by either the relative tolerance or the absolute tolerance, whichever results in a larger tolerance. The solver calculates the acceptable error based on the relative tolerance by multiplying the relative tolerance and the state value.
ei = reltol * |x|,
ei is the acceptable error based on relative tolerance at that time step.
reltol is the value specified for the Relative tolerance parameter.
x is the state value.
When ei is larger than the value specified for the Absolute tolerance parameter, the relative tolerance determines the tolerance for that state on that time step. When the absolute tolerance is greater than ei, the absolute tolerance determines the tolerance for that state on that time step. In general, the absolute tolerance applies when the state values approach zero.
For more information, see Error Tolerances for Variable-Step Solvers.
To enable this parameter:
Set the solver Type to
Set the Solver parameter to a value other than
discrete (no continuous states).
auto | positive scalar number
By default, the value is
auto, and the software scales the value of the absolute tolerance based on the state values during simulation. The software determines the initial absolute tolerance based on the value of the relative tolerance.
abstol = reltol * 1e-3 when reltol ≤ 1e-3
abstol = 1e-6 when reltol > 1e-3,
where abstol is the absolute tolerance and reltol is the relative tolerance.
As the simulation progresses, the absolute tolerance for each state is scaled to the maximum value that state has reached up to the current time step times the relative tolerance.
abstol = xmax * reltol
For example, if a state reaches a value of
1 during the simulation and the relative tolerance is
1e-4, the absolute tolerance is initialized to
1e-7 and reaches a value of
1e-4 by the end of the simulation.
When you specify the absolute tolerance as a positive scalar number, you can choose whether to scale the absolute tolerance based on state values during simulation using the Auto scale absolute tolerance parameter.
Some blocks have a block parameter that allows you to specify an absolute tolerance value for the software to use when computing the acceptable error for those block states. When you specify a value for the block parameter, the software uses the block parameter value instead of the model configuration parameter value when calculating acceptable state errors for states of that block. Such blocks include:
Consider specifying the block parameter value when the states in your model vary widely in magnitude.
If your simulation results do not seem accurate, and if your model has states with values that approach zero, then the absolute tolerance might be too large.
Specifying a small absolute tolerance might slow the simulation because the solver might take more steps than necessary near time points where the state values are near zero.
To check the accuracy of a simulation, you can reduce the absolute tolerance and simulate the model again. If the results of the two simulations are not significantly different, then the solution has converged.
The table summarizes recommended values for this parameter based on considerations related to code generation.
|Type: string | character vector
'auto' | positive scalar number
Introduced before R2006a