Speed up integrator

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Shivangi Giri
Posts: 50
Joined: Sun Jul 02, 2017 3:04 am

Speed up integrator

Post by Shivangi Giri » Fri Dec 09, 2022 4:36 am

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

Tags:

User avatar
Carmichael Ong
Posts: 378
Joined: Fri Feb 24, 2012 11:50 am

Re: Speed up integrator

Post by Carmichael Ong » Thu Jan 19, 2023 5:16 pm

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.

POST REPLY