MATLAB Answers


How to reduce number of solver resets with Simscape Multibody Contact Force Library?

Asked by David Hu on 7 Jun 2018
Latest activity Answered by Steve Miller on 2 Apr 2019
I've been using the solver profiler tool to see how I can speed up my simulation, and it gives me warning that my simulation has a dense group of solver exceptions and zero crossings (which create solver resets and slow down my system). With the contact force library blocks, I have turned on damping and set the damping factor to be very high - the objects look like they stick upon contact, instead of bouncing. However, in the profiler it is clear that the objects are simply bouncing infinitesimally while in contact with each other. Is there another way to stop the bouncing from happening, or another block type/library I should be using instead to model contact?


Sign in to comment.




1 Answer

Answer by Steve Miller on 2 Apr 2019

Hi - it will take some trial and error to find settings that will result in fast simulation. You will need to adjust stiffness, damping, solver type, and solver tolerances. Guidelines are given in the documentation for the Simscape Multibody Contact Forces LibrarySimscape Multibody Contact Forces Library, but those are generic starting points and you will need to tailor it to your system.
Here are some suggestions:
  1. Try ode23t and see if it does better than ode15s. I do not recommend using ode45, and note that the "auto" setting for the solver will often select ode45.
  2. Try making the solver tolerances 10x smaller or 10x larger (start with Relative Tolerance 1e-4, Absolute tolerance 1e-5)
  3. Make your stiffness and damping really soft and within a factor of 10 of each other. Then, gradually increase the stiffness and damping together until you get good behavior.
  4. Make sure you are using the right number of contact forces. Generally, a plane is defined by 3 points - if you have many more, you will create lots of additional zero crossings.
  5. You can run the model until it settles, then save that state of the model to the workspace and restart from there. See
The solver profiler will help you, but for problems of this nature it is mainly useful to help you evaluate if your current settings are better or worse than the previous test you ran, rather than pointing to the solution.


Sign in to comment.