Speeding up CMC

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Daniel Gordon
Posts: 34
Joined: Fri May 06, 2016 7:57 am

Speeding up CMC

Post by Daniel Gordon » Wed Aug 28, 2019 3:40 am

Hello,

We're doing some work for which we want to run small CMC simulations using the gait1018 model as quickly as possible. I was wondering if anyone could share some insight as to the best parameters to modify to speed up the CMC computation speed? (Of course at the cost of accuracy I assume).

I have modified the CMC time window but wonder which of the optimisation or integrator settings might be best to modify?

Kind regards,

Daniel

Tags:

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Speeding up CMC

Post by jimmy d » Wed Aug 28, 2019 4:32 am

Have you considered using Static Optimization rather than CMC? It will offer significant speed improvements.

User avatar
Daniel Gordon
Posts: 34
Joined: Fri May 06, 2016 7:57 am

Re: Speeding up CMC

Post by Daniel Gordon » Wed Aug 28, 2019 5:44 am

Hi James,

I hadn't but on reading up that seems like a good idea, I'll try that. Thanks for the suggestion!

User avatar
Daniel Gordon
Posts: 34
Joined: Fri May 06, 2016 7:57 am

Re: Speeding up CMC

Post by Daniel Gordon » Fri Aug 30, 2019 6:37 am

Hi again,

I've noticed quite a disparity in the results of a metabolics probe between SO and CMC (I knew there would be differences but it seems vast).

CMC is reporting values from ~500 - 2000 whereas for SO it is around 74 - 77 only. This is for the same set of input data. I have noticed that in the force files the SO .sto file somehow has the ground reaction forces in there whereas in the CMC force .sto file they are not.

My implementation of SO in Matlab is as follows:

Code: Select all


            % Import OpenSim Analyze Tool.
            import org.opensim.modeling.AnalyzeTool;
            import org.opensim.modeling.Model;
            
            % Temporarily copy SO settings folder to new location.
            [folder, name, ext] = fileparts(settings);
            temp_settings = [results filesep 'temp'];
            copyfile(folder, temp_settings);
            settings = [temp_settings filesep name ext];
            
            % Modify pelvis COM in actuators file.
            obj.modifyPelvisCOM(settings);
            
            % Load tool.
            soTool = AnalyzeTool(settings);
            
            % Setup external loads.
            external_loads = xmlread(load);
            external_loads.getElementsByTagName('datafile').item(0). ...
                getFirstChild.setNodeValue(obj.grfs_path);
            temp = [results filesep 'temp.xml'];
            xmlwrite(temp, external_loads);
            soTool.setExternalLoadsFileName(temp);
            
            % Load and assign model.
            soTool.setModelFilename(obj.model_path);
            
            % Assign parameters.
            soTool.setCoordinatesFileName(obj.best_kinematics);
            soTool.setInitialTime(timerange(1));
            soTool.setFinalTime(timerange(2));
            soTool.setResultsDir(results);
            
            % Print new temp settings file.
            soTool.print(settings);
            
            % Reload tool from these settings.
            soTool = AnalyzeTool(settings);
            
            % Run tool.
            soTool.run();

I couldn't get the SO to work properly without printing and reloading the settings file.

Can anyone see where I might be going wrong?

Cheers.

User avatar
Daniel Gordon
Posts: 34
Joined: Fri May 06, 2016 7:57 am

Re: Speeding up CMC

Post by Daniel Gordon » Mon Sep 09, 2019 4:13 am

Just as an update I switched from running the AnalyzeTool with a SO and metabolics probe concurrently to running an analysis with the first SO first and a second analysis with only metabolics probe reporter afterwards. After this the metabolics look more reasonable. Not sure why the first attempt didn't work though!

POST REPLY