Main Content

Local Solver Basics

This page provides an overview of local solver usage in Simulink®, including when and how to use this feature.

How Do Local Solvers Work?

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 global and local solvers work together to integrate continuous states in the model. The local solver is responsible for all continuous states inside the model reference, while the global solver responsible for all other states elsewhere in the model, including those in other model references that do not have a local solver.

How Do Local Solvers Work?

At each step, the simulation loop executes Output, Update and Advance phases, where the states are integrated forward in the advance step. However, when you use a local solver, the local states are integrated during the update phase of the model reference block. The other states of the model are integrated during the advance phase.

Therefore, the local solver states are integrated first, before the rest of the simulation advances in time. As a result, advancing the local solver can require some form of extrapolation. You can control extrapolation using the Input Signal Handling parameter.

Since the local solver steps may not correspond to the global solver steps, the output of the running model reference may require interpolation. You can control interpolation using the Output Signal Handling parameter.

Due to extrapolation or interpolation, the simulation results with a local solver will not necessarily match standalone simulation results of the same model with a global solver.

Why Use Local Solvers?

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.

Choice of solver and step size represents a tradeoff between computational cost and accuracy. A local solver allows you to fine-tune this tradeoff for different subsections of the model.

Tips

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.

  1. Use the Zero-Order Hold option 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

  2. Use the Auto input signal handling option to apply extrapolation and improve accuracy.

  3. Use the Zero-Order Hold output signal handling option for lowest computational cost.

  4. Use the Auto output signal handling option to apply interpolation and potentially improve accuracy.

  5. 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.

  6. A local solver has no effect on discrete states, which always run at their registered sample time. Thus, using a local solver is not supported if the model has no continuous states.

Considerations

  • The global solver can be fixed or variable-step. However, the local solver must be fixed-step.

  • If the top solver is fixed-step, then the local solver fixed-step size must be greater than or equal to the top step size.

  • Local solvers are allowed at the second level of the global model hierarchy, that is, the models referenced directly from the top model.

  • Local solvers are supported for normal simulation mode.

  • A model must have continuous states to apply a local solver.

    When a model is purely discrete, a local solver simply advances the time forward.

  • A global solver must use the full perturbation solver Jacobian method, and this parameter only applies when a global solver is implicit. For more information on Jacobian methods, see Choose a Jacobian Method for an Implicit Solver.

See Also

|