Identify and Resolve System Stiffness in Simscape Models
In Simscape™ models, system stiffness can increase the computational costs, cause solution instability, or prevent the model from running in real-time simulation. To resolve system stiffness, you must adjust the equations that contribute to stiffness. To determine which variables and equations have the most impact on system stiffness, use the Stiffness Impact Analysis option in the Solver Profiler tool. After identifying the variables and equations that impact your model the most, you modify them to make the system less stiff.
Configure the Stiffness Analysis
To prepare your model for stiffness analysis, set the model to normal simulation mode. The Solver Profiler does not support stiffness analysis in accelerator or rapid accelerator mode. Then, open the Solver Profiler. In the Debug tab, in the Performance section, click Performance > Solver Profiler.
When you inspect the model stiffness, you must specify the times in the simulation that you inspect. To set the system stiffness inspection times, click the Simscape Stiffness drop-down. In the Time Point(s) property, enter the times. To enter multiple time values, enter the times as a vector.
![The Solver Profiler. The Simscape Stiffness button is expanded, and the Time Point(s) property is set to the vector [0, 1, 2]](stiffness4.png)
Run the Simulation and Inspect Model Stiffness
To evaluate the model stiffness, click Run. The Solver Profiler simulates the model and calculates the stiffness at each time step in the Time Point(s) property. If the time steps do not match the times in the Time Point(s) property, the tool calculates the stiffness analysis at the closest time steps before and after the specified times.
Note
If the system is algebraic, high-index, uses frequency-and-time equation formulation, or contains Simscape Multibody™ blocks, the Solver Profiler does not produce stiffness analysis results and issues a warning.
To view the stiffness impacts, in the bottom pane, open the Simscape Stiffness tab. The analysis lists the time steps, the state that contributes to the stiffness, and the eigenvalue calculated at the state. The greater the magnitude of a negative eigenvalue, the more unstable the system is due to stiffness. This image shows the results of a model where the current through the Resistor block contributes most to the stiffness at each time step.

Update the Model
After determining stiffness, adjust the parameters to reduce the stiffness. For example, in the analysis shown above, the current associated with the resistor contributes the most to the system stiffness at each time step. The Resistor block derives the current from the resistance by using this equation:
v == R*i;To reduce the stiffness due to the current, reduce the value of the
Resistance property in the Resistor
block. Suppose that the original value of the Resistance property is
1e-6
Ohm. Setting the Resistance to
1e-3
Ohm and rerunning the simulation reduces the eigenvalues to
-1.00000e+06 and changes the responsible state to the voltage at the
capacitor.

After making the adjustment, determine if the reduction is sufficient, or if you require additional adjustments.
See Also
Solver Configuration | Solver Profiler | Simscape Variable Scaling Analyzer