Main Content

Use Local Solvers in Referenced Models

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, larger step size.

Using a local solver can improve simulation performance by allowing you to:

  • Reduce redundant calculations in components with slower time dynamics.

  • Choose a different solver that is better suited for a component.

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 Simulate DC Motor Step Response Using Local Solver.

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.

  • Output — The output method for each block in the system executes according to block position in execution order.

  • Update — The update method for each block in the system executes according to block position in execution order. The update method typically includes calculation of discrete state values.

  • Advance — The solver calculates continuous state values and determines the next major time step based on the solver selection, the solver parameter values, and the system dynamics.

When you use a local solver, the local solver computes state values for the referenced model during the update method of 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. The local solver extrapolates the values from outside of the model reference that it uses for the local advance that occurs as part of the update phase.

In the top solver advance phase and the output phase for the next time step, which both occur between all local advances, the top model might need values that are calculated by a local solver for a model reference. Because each local solver is ahead of the top solver, the top 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 each Model 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 local solver settings using the configuration parameters of the referenced model:

  • Use local solver when referencing model — When you select this parameter, the software uses the solver and step size specified in the configuration parameters for the referenced model.

  • Solver — Local solver selection. The local solver must be a fixed-step solver.

  • Fixed-step size (fundamental sample time) — Step size for local solver. If the top solver is also a fixed-step solver, the step size you specify must be an integer multiple of the step size used in the top model.

Configure these local solver settings using the Model block parameters:

  • Input Signal handling — How the local solver extrapolates inputs from the top model during the local advance stage

  • Output signal handling — How the top solver interpolates required values from the model reference during the system advance phase

Additional Considerations for Local Solvers

  • The top solver can be a variable-step or fixed-step solver. Local solvers must be fixed-step solvers. When the parent solver is also a fixed-step solver, the local solver step size must be an integer multiple of the step size for the parent solver.

  • 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:

    • Operate with time constants one or more orders of magnitude larger than other parts of the system

    • Have continuous states that are decoupled from the rest of the system

  • A local solver operates on continuous states in the system and has no effect for models that do not contain continuous states. When you configure a local solver in a system that does not contain continuous states, the software issues an error.

  • When you use a local solver in a model hierarchy that uses an implicit top solver, the Solver Jacobian Method configuration parameter value for the top model must be Full perturbation.

  • Referenced models configured to use a local solver do not support model arguments or variable-size signals on the model interface.

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

    • Multitasking execution

    • Saving or restoring a model operating point

    • Fast restart

    • Linearization

  • Local solvers are not supported for referenced models inside for-each subsystems.

  • Fixed-step zero-crossing detection is not supported in models that use a local solver.

See Also


Model Settings

Related Topics