Identify solver performance bottlenecks
Open the Solver Profiler by clicking the hyperlink in the lower-right corner of the Simulink® Editor.
Continuous States
— Save model states to fileBy default, the profiler does not save the states of the model. Enabling this parameter configures the profiler to save the states to the profiler data MAT file.
Simscape States
— Save Simscape™ states to fileEnable this parameter to save Simscape states to the profiler data MAT file.
Zero Crossing
— Save zero crossing data to fileEnable this parameter to save zero crossing information to the profiler data MAT file
Model Jacobian
— Save model JacobianOption to log the solver Jacobian matrices to memory. This option is useful for simulations that use implicit solvers. For a comparison of solvers, see Compare Solvers.
For a more detailed explanation of the solver Jacobian, see Choose a Jacobian Method for an Implicit Solver.
Simscape Stiffness
— Log stiffness analysis of Simscape statesEnable this parameter to log the stiffness analysis of Simscape states to the profiler data MAT file. For more information on Simscape representation of stiffness and other phsyical system concepts, see How Simscape Models Represent Physical Systems (Simscape)
From
— Profiler start timeTime, in seconds, of the simulation that the profiler starts analyzing the model. This is not the same as the start time of the simulation.
To
— Profiler stop timeTime, in seconds, of the simulation to which the profiler should profile the model. By default, the analysis continues until the end of the simulation. Changing this parameter does not change the stop time of the model which you specify in the Model Configuration Parameters.
A value less than the configured stop time of the model stops the profiling and
simulation at StopTime
.
Buffer
— Memory impact of loggingMaximum number of events that are logged. If the number of logged events reaches
this value and memory is available, increase BufferSize
. If memory
is limited, consider lowering the value.
Solver Exception
— Show solver exception eventsEnable this parameter to highlight solver exception events in the Step Size plot of the Solver Profiler.
Solver Reset
— Show solver reset eventsEnable this parameter to highlight solver reset events in the Step Size plot of the Solver Profiler.
Zero Crossing
— Show zero crossing eventsEnable this parameter to highlight zero crossing events in the Step Size plot of the Solver Profiler.
Jacobian Update
— Show Jacobian update eventsEnable this parameter to highlight Jacobian update events in the Step Size plot of the Solver Profiler.
Rule Customization
— Change thresholds for profiler rulesClick Rule Customization in the Solver Profiler to access the rule set. You can change the thresholds for most of these rules and also select which rules you want to apply selectively during a simulation run.
To modify a rule, enable its customization and then enter a desired threshold value.
You can override the settings on the Rule Set dialog box by specifying a custom rule set.
Create a rule set as a MATLAB® script and specify the path to the script in the Custom Rule Set section of the Rule Set dialog box.
A simple rule set example looks as follows:
function diagnosticsString = customRule(profilerData) if isempty(profilerData.zcEvents) diagnosticsString{1} = 'No zero crossing event detected.'; else diagnosticsString{1} = 'Zero-crossing events detected.'; end end
profilerData
. This array of structures organizes all the
information that the Solver Profiler collects during a profiling run. It contains the
following substructures.
Substructure | Fields |
---|---|
stateInfo : Stores information on block
states |
|
blockInfo : Cross-reference of blocks and state
IDs |
|
zcSrcInfo : Stores information on blocks causing zero
crossing events |
|
zcEvents : Cross-reference of the time stamps of zero
crossing events and the corresponding state IDs |
|
exceptionEvents : Cross-reference of exception event
timestamps, the ID of the corresponding state that caused the event, and the
cause. |
|
resetTime : Stores timestamps of solver
resets. | None |
tout : Stores simulation times. | None |
Data Types: double