Page 1 of 1

Speed up integrator

Posted: Fri Dec 09, 2022 4:36 am
by shivangi2208
Hello,
I have a MATLAB code that takes about 7-8 mins to run, with the following line taking more than 5 mins


state = manager.integrate(timed); with timed = time(i+1)-time(i);

I was looking for a way to speed up the integration process. Can we use any other method or function?
Any help would be appreciated.

Regards,
Shivangi

Re: Speed up integrator

Posted: Thu Jan 19, 2023 5:16 pm
by ongcf
If you're using the default integrator in OpenSim, it will use the Runge-Kutta-Merson integrator which is a variable step integrator. This means that it will take as large of time steps that it can take, while keeping error below some tolerance for each step. If you are integrating in a loop, you may be disrupting this variable step, if the time step you've chosen is smaller than the time step the integrator would have taken otherwise. So, it may be good to just let the integrate() function try to integrate to the final time in one go.

You may also be able to use setIntegratorAccuracy() to allow the integrator to take larger steps, but then it would be important to do a sensitivity analysis to ensure that the results are reasonable ant not changing too much as you loosen the accuracy.