MATLAB Answers

slow simulation - computation problems

3 views (last 30 days)
Ruben Hefele
Ruben Hefele on 8 Jan 2021
Answered: Steve Miller on 3 Jun 2021
I'm simulating a tractor in combination with an implement. I'm using simscape multibody in combination with simscape hydraulics. In multibody the physical parts are modelled e.g. cylinders and in hydraulics I'm modelling the hydraulic pump and oil flow to and in the cylinders.
Everything seems to work. The problem is that the simulation computes very slow even though I already optimised the controllers for the cylinder position. Simulation time = 10s vs. computation time = more than an hour...
Any suggestions how to resolve this issue?
Many thanks in advance.
Yifeng Tang
Yifeng Tang on 27 Apr 2021
Hard to tell exactly what's going on without looking at the model itself, but I can try to offer a few guesses on what might be the issue, based on my past experience with hydraulics+multibody models.
1. solver settings: not necessarily the solver itself, but things like tolerances and zero-crossings. Take a look at this example from MATLAB Central, and try to replicate the solver settings in there.
2. initial conditions: it's rather difficult to know before hand if all the target states of the joints in the multibody model is consistent with the forces and positions in the hydraulic cylinders, and there is a good chance that they are not at the beginning. The gravity will then pull things downwards and if the hydraulic circuits and joints doesn't have enough damping components (resistance, orifice, friction), there can be high frequency vibrations that go on and on. The hydraulic circuit can behave like very stiff springs. The simulation can be very slow because of this. Now your simulation runs, but very slowly, you can check in the result explorer, zoom in, and see whether you see any high frequency vibrations. The mid point of the pressure in the cylinders usually gives you a some idea where the equilibrium should be and you can try to set the initial conditions accordingly.
3. Use solver profiler to identify the blocks that's forcing small time steps.

Sign in to comment.

Answers (1)

Steve Miller
Steve Miller on 3 Jun 2021
There are many good suggestions in the comments.
Please note:
  1. Simulating with ode23t is a dynamic analysis, not steady state
  2. The Solver Profiler is an excellent tool for diagnosing model issues.
  3. Please refer to this MATLAB Answers post for additional suggestions to speed up your model
If you can post the model, we can offer more suggestions.

Community Treasure Hunt

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

Start Hunting!