Variable step solver causes my model to explode, but fixed step solver doesn't cause that
Show older comments
So I'm trying to simulate a monoped (single leg of a robot) jumping vertically high in Simscape Multibody and optimize the design in a loop. Everytime the optimization algo chooses different parameters of the leg dimensions, the model is updated and resimulated. The specific logged data like, energy consumption and max height reached are then used to calculate the cost. The jumping trajectory is being passed as a timeseries from workspace to a PD controller that generates the torque value for the respective revolute joint.
The issue the desired results of the monoped jumping occurs only when the model is run at a fixed step with tolerance of 1e-4. If the change the tolerance to 1e-3, the leg slips and fails to track the given trajectory. The idea behind decreasing the tolerance is to speedup the process since it is an optimization. For a higher tolerance (1e-5) the desired result is obtained but there is a huge difference between the logged data. For eg. I'm getting 1.8m jump height while using tolerance 1e-4 and 2.2m height while using tolerance 1e-5. How can I know which is close if tolerance keeps on affecting the result? Again, if I change the solver type to variable solver, which intuitively should give better results, fails to even track the passed trajectory completely. The model explodes - starts rotating violently without any sense.
Is there something very simple that I'm missing? I mean if such dependency on solver type exist, how would I know my entire simulations are not a bluff and ill conditioned? What should I do?
Answers (1)
Ritam
on 16 Apr 2026 at 5:10
0 votes
From the behaviour you described, this appears to be a solver selection and configuration issue that is commonly observed in hybrid, stiff multibody models. In such systems, solver settings influence not only numerical accuracy but also event timing, which can significantly alter outcomes like jump height and energy consumption.
As a first step, you may want to try the daessc variable‑step solver, which is specifically designed for Simscape physical networks and is generally more robust for stiff, contact‑rich models. In addition, the issue may also be influenced by configuration parameters such as maximum step size, or zero‑crossing handling, rather than the solver choice alone.
You may find the below documentations helpful for your use case:
- Solver - Solver that computes states and outputs for simulation - MATLAB: Provides an overview of available Simulink solvers, explains how they compute system states, and details how solver type, tolerances, and step size affect simulation stability and accuracy
- Simulating an Electronic, Mechatronic, or Electrical Power System - MATLAB & Simulink: Explains how to balance accuracy and performance in physical simulations by tuning solver tolerances, maximum step size, and related parameters, with guidance applicable to stiff and hybrid Simscape models.
- Setting Up Solvers for Physical Models - MATLAB & Simulink: Describes best practices for harmonizing Simulink and Simscape solvers, recommends implicit solvers, and outlines when to adjust local solver and configuration settings for robustness and speed.
If the above resources help you, I would recommend you to reach out to MathWorks Technical Support through https://www.mathworks.com/company/aboutus/contact_us.html.
Categories
Find more on Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!