Local Solver Basics
When a local solver is enabled, Simulink® solves model reference as a separate differential equation with its own solver. Both a different solver and a different step size can be used. The top solver and local solver work together to integrate continuous states in the model. The local solver is responsible for all continuous states inside the model reference, while the top solver is responsible for all other states elsewhere in the model, including those in other model references that do not have a local solver.
At each step, the simulation loop executes output, update, and advance phases. Typically, states are integrated forward in the advance phase. When you use a local solver, the local states are integrated during the update phase for the model reference. The other states of the model are integrated during the advance phase. Because the states in the model reference with a local solver are integrated before the rest of the states in the model, advancing the local solver can require extrapolation. You can control the extrapolation method using the Input Signal Handling parameter.
When you use a local solver, you can specify both a different solver and a different step size, which means that the time steps taken by the local solver may not match the time steps taken by the solver for the top model. When the top solver and local solver take different time steps, the software interpolates the outputs of the model reference. You can control the interpolation method using the Output Signal Handling parameter.
The result of a simulation that uses a local solver might differ from the result of an equivalent simulation that solves the model with one solver, because using a local solver involves interpolation and extrapolation.
Why Use Local Solver?
You can speed up simulation by using an inexpensive solver on a subset of the model.
An inexpensive solver could be a lower-order solver, for example, using an
ode1 solver instead of
ode3, or using a solver
with a larger step size.
The choice of solver and step size involves a tradeoff between computational cost and accuracy. A local solver allows you to fine-tune this tradeoff for different subsections of the model.
In addition to a cost-accuracy tradeoff, a local solver can introduce further inaccuracies due to the interpolations or extrapolations it requires to communicate with the rest of the model. Input and output signal handing can mitigate some of these effects, but are not always appropriate. Follow these guidelines to get the most out of local solver usage.
Zero-Order Holdoption in the Input Signal Handling parameter for these situations:
To achieve lowest computational cost
When the model has no input ports, when the input ports do not drive continuous derivatives, or when a significant portion of the derivative is based on the state itself, for example, from feedback loops in the model.
To improve stability of the local solver at a given step size
Autoinput signal handling option to apply extrapolation and improve accuracy.
Zero-Order Holdoutput signal handling option for lowest computational cost.
Autooutput signal handling option to apply interpolation and potentially improve accuracy.
Look for subsections of the model with time constants separated by several orders of magnitude. These subsections may often correspond to different modeling domains, such as electrical versus mechanical.
Additionally, you can easily apply a local solver if some states are completely disconnected from others, for example, if a model contains two dynamic systems in the model that do not interact.
Local solvers are not supported for models that do not have continuous states. A local solver has no effect on discrete states, which always run at their registered sample time.
The top solver can be fixed step or variable step. The local solver must be fixed step.
If the top solver is fixed step, then the step size for the local solver must be greater than or equal to the step size for the top solver.
Local solvers are supported only for the second level of the model hierarchy. You can configure a local solver for a model referenced by a Model block in the top model. You cannot configure a local solver on a Model block inside a model reference.
To use a local solver, the model must have continuous states.
The top solver must use the full perturbation solver Jacobian method, and this parameter only applies when the top solver is implicit. For more information on Jacobian methods, see Choose a Jacobian Method for an Implicit Solver.