# Solver Configuration

Physical network environment and solver configuration

**Library:**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

`Port_1`

— Connection port

untyped conserving port

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

`Equation formulation`

— Specify how the solver treats sinusoidal variables

`Time`

(default) | `Frequency and time`

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.

`Index reduction method`

— Choose index reduction method for solving nonlinear high-index DAEs

`Derivative replacement`

(default) | `Projection`

| `None`

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.

`Start simulation from steady state`

— Select whether to start simulation from the initial state or from steady state

off (default) | on

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.

`Consistency tolerance`

— Tolerance used for initial conditions and transient initialization computation

`1e-9`

(default) | positive scalar

This parameter affects the nonlinear solver used for computing initial conditions and for transient initialization. It 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). 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.

The default value is applicable to most cases.

`Use local solver`

— Use sample-based local solver for physical network in the model

off (default) | on

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.

`Solver type`

— Solver type used by local solver for updating the states

`Backward Euler`

(default) | `Trapezoidal Rule`

| `Partitioning`

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.

`Sample time`

— Sample time for the local solver

`0.001`

(default) | positive scalar

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.

`Partition method`

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

`Robust simulation`

(default) | `Fast simulation`

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`

.

`Partition storage method`

— Select method used for storing partitioning data when using Partitioning local solver

`As needed`

(default) | `Exhaustive`

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`

.

`Partition memory budget [kB]`

— Memory budget for exhaustive method of storing partition data

`1024`

(default) | positive scalar

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 Model Statistics Available when Using the Partitioning Solver.

#### Dependencies

To enable this parameter, select the **Use local solver** check
box. Set **Solver type** to `Partitioning`

and **Partition storage method** to
`Exhaustive`

.

`Use fixed-cost runtime consistency iterations`

— Lets you perform transient initialization at a fixed computational cost

off (default) | on

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.

`Nonlinear iterations`

— Number of Newton iterations for transient initialization

`3`

(default) | positive integer

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.

`Mode iterations`

— Number of mode iterations for transient initialization

`2`

(default) | positive integer

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.

`Compute impulses`

— Lets you manage computational cost of impulse detection during transient initialization

off (default) | on

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.

`Impulse iterations`

— Number of impulse iterations for transient initialization

`2`

(default) | positive integer

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.

`Linear Algebra`

— Specify how the solver treats matrices

`auto`

(default) | `Sparse`

| `Full`

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.

`Number of threads (specify n for 2^n)`

— Use multithread linear algebra to speed up desktop simulation on a multicore machine

`0`

(default) | positive integer

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.

`Delay memory budget [kB]`

— Memory budget for processing delays

`1024`

(default) | positive scalar

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.

`Apply filtering at 1-D/3-D connections when needed`

— Automatically provides additional derivative needed by Simscape Multibody™ blocks

on (default) | off

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.

`Filtering time constant`

— Time constant for the delay, in seconds

`0.001`

(default) | positive scalar

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.

## Model Examples

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using Simulink® Coder™.

## Version History

**Introduced in R2007a**

## Comando MATLAB

Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:

Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)