matlabperformancesimulationsimulinksimscape

How to speed up simulation of Simscape based Physical model?


I am working on modeling and controlling of a hydraulic system. Modeling of the system is modeled in Matlab simscape in simulink environment which is looks like this System and for basic controlling to control the piston position (Piston Pos in figure) I have established simple feedback to check the position.

While I run the simulation when this comes to control the position Simulation takes too much time. For example if I gave desired piston position 300 mm than while output comes to around 290-294 mm simulation time reaches at around 5.18sec than it is stuck on that for longer time.

I want to know that, is there any way to speed up the simulation ?

I am using Matlab simulink solver ode23t due to simscape modeling.


Solution

  • Speeding up simulations in general is vast subject. It seems the issue here is an event which triggers multiple small time-step in the variable step solver. This can be perfectly normal, for example a clutch engaging, or a valve opening. To check whether or nor this is the case you can execute (make sure time-logging is enabled):

    semilogy(tout(2:end), diff(tout))

    Sharp downward spikes indicate small time-steps were taken. For a more in-depth analysis you can use the Solver Profiler:

    https://www.mathworks.com/help/simulink/ug/examine-solver-behavior-using-solver-profiler.html

    This will give you detailed information as to which components are causing solver resets. Such behavior can be difficult to debug if you're not used to the tool. I'd highly recommend getting in touch with MathWorks tech support if the behavior persists. They'll be able to look at your model and diagnose the issue.