Main Content

Solver Configuration

Physical network environment and solver configuration

  • Solver Configuration block

Libraries:
Simscape / Utilities

Description

Each physical network represented by a connected Simscape™ block diagram requires solver settings information for simulation. The Solver Configuration block specifies the solver parameters that your model needs before you can begin simulation.

Each topologically distinct Simscape block diagram requires exactly one Solver Configuration block to be connected to it.

Ports

Conserving

expand all

Conserving connection port. This port is untyped. You can connect it anywhere on a physical network circuit by creating a branching point on a connection line between conserving ports of any type. The block provides solver setting to the whole physical network, regardless of the connection type.

Parameters

expand all

Specifies how the solver treats sinusoidal variables.

Use the Frequency and time value to speed up simulation of systems with a single nominal frequency. For more information, see Frequency and Time Simulation Mode.

Choose nonlinear index reduction method best suited for the network connected to the Solver Configuration block:

  • Derivative replacement — In this method, parts of the DAE are differentiated analytically and appended to the original system. For each additional equation, a derivative is selected to be replaced by a new algebraic variable called a dummy derivative. For more information, see https://epubs.siam.org/doi/abs/10.1137/0914043?journalCode=sjoce3. This option corresponds to the nonlinear index reduction method used in previous releases. It is recommended that you start with this method.

  • Projection — Use this option if the Derivative replacement method fails due to issues with dynamic state selection.

  • None — If your model does not contain nonlinear high-index DAEs, use this option to completely bypass nonlinear index reduction and remove the analysis overhead.

By default, when this check box is cleared, simulation starts from the initial state obtained from the initial conditions computation.

When you select this check box, the solver attempts to find the steady state that would result if the inputs to the system were held constant for a sufficiently large time. For more information, see Initial Conditions Computation. Simulation then starts from this steady state.

For models compatible with frequency-and-time equation formulation, when you select this check box, the solver attempts to perform sinusoidal steady-state initialization. In other words, initialization is performed using frequency-time equations, and then the simulation proceeds using the actual equation formulation and other options selected in the Solver Configuration block. For more information, see Frequency and Time Simulation Mode.

Note

Using the Initial state option on the Data Import/Export pane of the Configuration Parameters dialog box overrides the Start simulation from steady state option.

This parameter affects the nonlinear solver used for computing initial conditions and for transient initialization. Select the state-based tolerance source:

  • Model AbsTol and RelTol — Use the model tolerance settings, specified as Absolute tolerance and Relative tolerance parameters on the Solver pane of the Configuration Parameters dialog box.

  • Local tolerance settings — Replace the model tolerance settings with local values. When you select this option, the Absolute tolerance and Relative tolerance parameters appear in the Solver Configuration block dialog box.

Independent of whether you use the model tolerances or the local tolerance settings, the Tolerance factor parameter provides a scaling factor for these values. The resulting value determines how accurately the algebraic constraints are to be satisfied at the beginning of simulation and after every discrete event (for example, a discontinuity resulting from a valve opening, a hard stop, and so on).

Specify a local value to be used for computing initial conditions and for transient initialization, instead of using the Absolute tolerance parameter on the Solver pane of the Configuration Parameters dialog box.

Dependencies

To enable this parameter, set Consistency tolerance to Local tolerance settings.

Specify a local value to be used for computing initial conditions and for transient initialization, instead of using the Relative tolerance parameter on the Solver pane of the Configuration Parameters dialog box.

Dependencies

To enable this parameter, set Consistency tolerance to Local tolerance settings.

This parameter provides the scaling factor for the state-based absolute and relative tolerances, independent of whether you use the model tolerances or the local tolerance settings. Decrease the parameter value (that is, tighten tolerance) to obtain a more reliable time simulation. Increase the parameter value (that is, relax the tolerance) if solving for initial conditions failed to converge, or to reduce the computation time.

Lets you use a sample-based local solver with a sample time specified by the Sample time parameter. In sample-based simulation, all the physical network states, which are otherwise continuous, become represented to Simulink® as discrete states. The solver updates the states once per time step. This option is especially useful for generated code or hardware-in-the-loop (HIL) simulations.

Note

If you use a local solver, simultaneous use of Simulink or Simulink Control Design™ linearization tools is not recommended.

Select the solver type used for updating the states:

  • Backward Euler — Tends to damp out oscillations, but is more stable, especially if you increase the time step.

  • Trapezoidal Rule — Captures oscillations better than Backward Euler, but is less stable.

  • Partitioning — Lets you increase real-time simulation speed by partitioning the entire system of equations corresponding to a Simscape network into a cascade of smaller equation systems. Not all networks can be partitioned. However, when a system can be partitioned, this solver provides a significant increase in real-time simulation speed. For more information, see Understanding How the Partitioning Solver Works and Increase Simulation Speed Using the Partitioning Solver.

Regardless of which local solver you choose, the Backward Euler method is always applied:

  • Right at the start of simulation.

  • Right after an instantaneous change, when the corresponding block undergoes an internal discrete change. Such changes include clutches locking and unlocking, valve actuators opening and closing, and the switching of the PS Asynchronous Sample & Hold block.

Dependencies

To enable this parameter, select the Use local solver check box.

Specify the local solver sample time, in seconds. The solver updates the states once per time step.

Dependencies

To enable this parameter, select the Use local solver check box.

Select whether to prioritize speed or robustness when using Partitioning local solver:

  • Fast simulation — Improve simulation performance by solving most differential equations using the forward Euler scheme.

  • Robust simulation — Increase simulation robustness by solving more equations using the backward Euler scheme.

Dependencies

To enable this parameter, select the Use local solver check box and set Solver type to Partitioning.

When you use the Partitioning solver, it solves the small switched linear equations consecutively. You can choose to store the matrix inverses, to improve the simulation performance. Then, if the same configuration is detected in a subsequent time step, the partitioning solver uses the stored matrix inverses, instead of recomputing them. Select the method used for storing partitioning data:

  • As needed — Compute matrix inverses during simulation, as needed. This method does not require as much memory but can result in performance spikes.

  • Exhaustive — Compute and store matrix inverses before simulation. This method improves the simulation performance but requires more memory. Use the Partition memory budget [kB] parameter to specify the maximum allowed memory budget for storing the data.

Dependencies

To enable this parameter, select the Use local solver check box and set Solver type to Partitioning.

Specify the maximum memory budget, in kB, allowed for storing cached partition data. If this budget is exceeded, simulation errors out. You can adjust the default value based on your available memory resources and on the Total memory estimate data in the Statistics Viewer. For more information, see Partitioning Solver Statistics.

Dependencies

To enable this parameter, select the Use local solver check box. Set Solver type to Partitioning and Partition storage method to Exhaustive.

If you select this check box, you can specify the number of nonlinear and mode iterations for transient initialization. If the system does not converge once it performs the specified number of iterations, it ignores the failure and goes to the next step.

If you clear the check box, the system uses a more robust and time-consuming algorithm, performing as many iterations as necessary to reach convergence, and errors out if it fails to reach convergence at the time of transient initialization.

Selecting and clearing Use local solver automatically selects and clears the Use fixed-cost runtime consistency iterations check box as well, because these are the recommended settings for real-time and HIL simulations. However, you can select and clear the two check boxes independently of each other. For more information, see Fixed-Cost Simulation.

Specify the number of Newton iterations to be performed at the time of transient initialization.

Dependencies

To enable this parameter, select the Use fixed-cost runtime consistency iterations check box.

Specify the number of mode iterations to be performed at the time of transient initialization.

Dependencies

To enable this parameter, select the Use fixed-cost runtime consistency iterations check box and clear the Use local solver check box. Only one major mode update per step is performed when using local solvers, therefore this parameter is not available if the Use local solver check box is selected.

Lets you manage computational cost of impulse detection during transient initialization, both for global and local solvers.

Event-based methods of state reinitialization and impulse handling let you model physical phenomena, such as collisions and bouncing balls, and provide a significant boost in simulation speed for such models. However, impulse detection can add cost to transient initialization. This cost is proportional to the number of impulse iterations performed to reach convergence.

If you select the Compute impulses check box, you can specify the number of impulse iterations to perform during transient initialization. If the system does not converge upon reaching these numbers, it ignores the failure and goes to the next step.

If you clear the check box, the system computes impulses as many times as necessary to reach convergence.

Dependencies

To enable this check box, select the Use fixed-cost runtime consistency iterations check box.

Specify the number of impulse iterations to be performed at the time of transient initialization. If the system does not converge upon reaching these numbers, it ignores the failure and goes to the next step.

Dependencies

To enable this parameter, select the Compute impulses check box.

Certain model configurations, such as parallel clutches locking, or current sensors connected in parallel, allow an infinite number of solutions, which makes them statically indeterminate. Regularization is a transformation that turns models with indeterminate Through variables into solvable systems. By default, if the solver encounters a statically indeterminate system, it applies runtime regularization to solve it.

Clear the Resolve indeterminate equations check box to speed up simulation on a multicore machine by using the Maximum threads for function evaluation parameter. However, models that have statically indeterminate equations can fail at run time.

Dependencies

To enable this check box, select the Use fixed-cost runtime consistency iterations check box.

Specify the maximum number of threads for function evaluation when using the Backward Euler solver for real-time simulation. The actual number of threads used is the nearest power of 2 not to exceed the parameter value. For example, if you specify 5 as the parameter value, the solver uses 4 threads. The default, 1, corresponds to single-thread function evaluation.

To use multithread function evaluation, you must clear the Resolve indeterminate equations check box. If you select the Resolve indeterminate equations check box, the solver warns and switches to single-thread function evaluation.

Other unsupported simulation modes include frequency-and-time simulation, delay, scalable compilation, accelerator mode, and rapid accelerator mode. You can generate code using Simulink Real-Time™, but other types of code generation are not supported.

Dependencies

To enable this parameter, select the Use local solver check box, set the Local solver parameter to Backward Euler, and select the Use fixed-cost runtime consistency iterations check box.

Specifies how the solver treats matrices:

  • auto — The solver automatically selects the appropriate option, either sparse or full, for treating the matrices.

  • Sparse — The solver treats matrices as sparse.

  • Full — The solver treats matrices as full.

Specify the number of threads for multithread linear algebra by providing an integer exponent for 2. The number of threads equals 2 to the power of the parameter value. The default, 0, corresponds to single-thread linear algebra.

For small models, multithread algorithms that use numbers higher than 0 may be slower than single-thread.

Dependencies

To enable this parameter, select the Use local solver check box and set the Linear algebra parameter to Sparse. For a global solver, Simulink solves the equations without using Simscape linear algebra algorithms.

Specify the maximum memory budget, in kB, allowed for processing delays when simulating models that contain either blocks from the Delays library or custom blocks using the delay Simscape language construct. The purpose of this parameter is to protect against excessive memory swapping. If this budget is exceeded, simulation errors out. You can adjust this value based on your available memory resources.

This option is applicable only for models that connect blocks from Simscape Multibody library to Simscape blocks, or blocks from other add-on products. Use the Statistics Viewer to determine whether your model has 1-D/3-D connections. For more information, see 1-D/3-D Interface Statistics.

When a Simscape Multibody block is connected directly to a Simscape network, an additional derivative may be required for the network to be solved. When you select this check box, the solver automatically applies input filtering to the signal entering the Simulink-PS Converter block to obtain this additional derivative. The Filtering time constant parameter provides the time constant for the delay.

Note

This check box is selected by default. If you clear it, and the 1-D/3-D connection requires the additional derivative, the solver issues an error message.

This parameter specifies the filtering time constant, in seconds, for the automatic input filtering for 1-D/3-D connections. The parameter value applies globally to all connections belonging to the network that includes this Solver Configuration block.

Dependencies

To enable this parameter, select the Apply filtering at 1-D/3-D connections when needed check box.

Multibody

Lets you use a sample-based local solver for the connected Simscape Multibody network. Using a local solver can reduce the computational cost for a complex Simulink model that has simple Simscape Multibody networks. A Simscape Multibody network using a local solver appears to the global Simulink solver as if it has discrete states. The local solver updates the states once per time step.

Note

This setting is independent from the Use local solver setting in the main part of the block dialog box, which applies to the Simscape network connected to the block.

Select the solver type used for updating the states in the Simscape Multibody network:

  • First-order explicit formula — Explicit fixed-step solver that uses the same mathematical equations as ode1.

  • Second-order explicit formula — Explicit fixed-step solver that uses the same mathematical equations as ode2.

  • Third-order explicit formula — Explicit fixed-step solver that uses the same mathematical equations as ode3.

  • Fourth-order explicit formula — Explicit fixed-step solver that uses the same mathematical equations as ode4.

  • Fifth-order explicit formula — Explicit fixed-step solver that uses the same mathematical equations as ode5.

  • Eight-order explicit formula — Explicit fixed-step solver that uses the same mathematical equations as ode8.

Dependencies

To enable this parameter, in the Multibody section, select the Use local solver check box.

Specify the Multibody local solver sample time, in seconds. The solver updates the states of the connected Simscape Multibody network once per time step.

Dependencies

To enable this parameter, in the Multibody section, select the Use local solver check box.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2007a

expand all