Use Local Solvers in Referenced Models - MATLAB & Simulink (original) (raw)

When you use referenced models to represent system components, you can configure each referenced model to use a local solver. When you use a local solver in a referenced model, the software solves the model reference as a separate set of differential equations using the local solver. The referenced model can use a solver that is the same or different from the solver used in the top model. Whether the local solver is the same or different, the local solver can use a different, smaller (since R2024a) or larger step size.

Using a local solver can facilitate system composition and integration. When you use local solvers, you can solve referenced models in system-level simulations using the same solver and step size used to design and test each model in isolation. Using local solvers can also reduce the number of configuration adjustments you need to make to configuration parameters in referenced models while integrating the model into a larger system.

For some systems, using a local solver can improve simulation performance by allowing you to:

The choice of solver and solver settings involves a trade off between speed and accuracy in simulation. When you use local solvers, you can make different choices based on the requirements for each component.

For an example about using a local solver, see Improve Simulation Performance by Using Local Solvers.

How Local Solvers Work

In a typical simulation that uses only one solver, the simulation loop executes in three phases for each major time step: output, update, and advance. In each phase, each block in the model executes the block method that corresponds to the phase according to the execution order.

When you use a local solver, the local solver computes state values for the referenced model during the update method for the referenced model. As part of the update method, the local solver performs a local advance for the model reference to calculate the next local time step. Because the local solver advance occurs before the system-level advance phase, the local solver execution gets ahead of the execution for the top model. When the local advance phase uses values that come from the parent model, the local solver extrapolates those values to the local time.

The top solver advance phase and the output phase for the next time step both occur between each local advance. In the top solver advance and output phases, the top solver might use values that are calculated by the local solver. Because the local solver is ahead of the top solver, the local solver provides interpolated values to the top solver.

Because using a local solver involves interpolation and extrapolation, simulation results might not match between equivalent simulations of the same model with and without the use of the local solver.

How to Configure Local Solvers

Configure the settings for a local solver using a combination of the configuration parameters for the referenced model and the block parameters for eachModel block that references the model. The configuration parameter values in the referenced model have the same value for every instance of that model. You can configure the Model block parameter values differently for each model reference instance.

Configure these options using the configuration parameters of the referenced model:

Configure these options using the Model block parameters:

Additional Considerations for Local Solvers

You must determine whether a local solver provides benefit based on the dynamics and characteristics of your system. When evaluating where a local solver might provide benefit, look for model components that:

Local solvers for referenced models operate on continuous states in the referenced model. Because using a local solver for a referenced model with only discrete states has no effect on simulation results, local solvers are not supported for models that do not contain continuous states. When a model contains no continuous states, the software always uses the discrete solver. The fixed-step discrete solver is not supported as a local solver.

Model hierarchies that contain one or more referenced models configured to use a local solver do not support:

Model hierarchies that contain one or more referenced models configured to use a local solver support these capabilities for only normal mode simulations:

Referenced models configured to use a local solver do not support software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation.

Local solvers are not supported for referenced models that directly or indirectly reference another model that has both continuous and discrete sample times, except when the model with continuous and discrete sample times:

Local solvers are not supported for models referenced by Model blocks:

When the top solver or a parent solver is implicit, the Solver Jacobian Method configuration parameter value for the top or parent model must be the default value auto orFull perturbation.

See Also

Blocks

Model Settings

Topics