How do I troubleshoot very slow simulation using a global variable step solver on a relatively simple Simscape model?

I have a relatively simple Simscape model, but when I try to simulate it with a global variable step solver, the simulation gets stuck in the early time steps and doesn't get anywhere no matter how long I give it. The time values in the simulation progress bar still change, but the step sizes are very very small.
When I enable a local fixed step solver, the simulation works, but the behavior of my results at the beginning of simulation are not expected (I see oscillations and overshoot).

 Akzeptierte Antwort

There are many reasons for a simulation to be slow, but if the model works with a local fixed step solver and is a relatively small, straightforward model to begin with, this indicates that there may be an issue with the model itself and some of the underlying assumptions or constraints.
The recommended workflow for physical modeling is to start with a variable step global solver (ode23t is relatively robust and stable, so we recommend it for many Simscape models) and resolve any issues that occur before moving on to using local solvers. Local solvers provide a fixed-cost method of simulation, since they discretize a subset of the model and use a fixed step size, but if there are underlying issues with the model, the use of local solvers can make it more difficult to troubleshoot. 
Given that you are able to achieve expected steady-state values using the local solver, but the initial oscillations and overshoot are unexpected, it is possible that some initial conditions are making it difficult for the solver to perform simulation at the early time steps. Based on your knowledge of your system, it may be valuable to investigate whether the initial conditions and values of your signals during simulation are expected.
The Solver Profiler and the Simscape Results Explorer are valuable tools for troubleshooting slow simulations. To run the Solver Profiler on your model, click the hyperlink in the bottom right-hand corner of the model (which displays the current solver) and then click the Solver Profiler button. It is recommended to set your model to use the ode23t solver and select all three logs in the toolstrip of the Solver Profiler (States & Zero Crossings, Simscape States, and Model Jacobian). The simulation does not need to run to completion in order to use the Solver Profiler - you can stop it at any time using the Stop button in the Profiler toolstrip. The "Suggestions" tab, which is generated when you stop the Profiler, may provide some helpful information regarding possible root causes of the slow simulation. You can launch the Simscape Results Explorer using the Simscape Results button in the Solver Profiler toolstrip. This will allow you to view signal values and determine whether they are expected in the context of your system.
For more information about how to use the Solver Profiler and Simulink Results Explorer, execute the following commands in MATLAB R2020a:
To access the Solver Profiler documentation:
>> web(fullfile(docroot, 'simulink/slref/solverprofiler.html'))
To access the Simscape Results Explorer documentation:
>> web(fullfile(docroot, 'physmod/simscape/ug/using-the-simscape-results-explorer.html'))
For information on how initial conditions can be set in Simscape, use the following command:
>> web(fullfile(docroot, 'physmod/simscape/ug/how-simscape-simulation-works.html'))
The following MathWorks Blog contains background information on solvers and some guidelines for selecting the correct one for your model: https://blogs.mathworks.com/student-lounge/2017/12/08/solver-choice/
The following documentation links contain information about selecting solvers for Simscape models specifically:
Please follow the link below to search for the required information regarding the current release:

Weitere Antworten (0)

Kategorien

Produkte

Version

R2018b

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by