Page 1 of 1

Speeding up CMC

Posted: Wed Aug 28, 2019 3:40 am
by danielfng
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

Re: Speeding up CMC

Posted: Wed Aug 28, 2019 4:32 am
by jimmy
Have you considered using Static Optimization rather than CMC? It will offer significant speed improvements.

Re: Speeding up CMC

Posted: Wed Aug 28, 2019 5:44 am
by danielfng
Hi James,

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

Re: Speeding up CMC

Posted: Fri Aug 30, 2019 6:37 am
by danielfng
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.

Re: Speeding up CMC

Posted: Mon Sep 09, 2019 4:13 am
by danielfng
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!