Parameters self-update without initSystem()
Posted: Wed Jun 23, 2021 12:12 pm
Hi fellow modelers,
I'm scripting in Matlab to set muscle parameters and obtain the according tendon force, and triggered a potential bug when parameters are changed after initSystem(). [I changed the post title as I realized the bug is not in initSystem() itself.]
My understanding is that, initSystem() must be called after muscle parameters are reset, otherwise simulation will be based on default parameters.
However, this theory seems to be model-dependent: with Arnold Model, yes; but with Gait2392 and Rajagopal Model, if initSystem() is called before parameters reset, muscle dynamics somehow changes, but it's not the same as when called after.
Please try the test code below in Matlab as an example:
soleus is activated 100% in default joint coordinates, and its optimal fiber length and tendon slack length are changed into 10 and 20 cm. [I wanted to attach a figure but was warned "the board attachment quota has been reached."]
For Gait2392, Arnold and Rajagapal:
1. The original tendon forces under this state are respectively 2794.3, 2942.0, 5205.6
2. initSystem() before parameter reset, the values become 3340.1, 2942.0, 5741.5
3. initSystem() after parameter reset, the values become 3164.4, 2822.6, 5254.6
Theoretically No.3 is the right answer, which is also the result I get manually from OpenSim, but why do the values change for Gait2392 and Rajagopal Model in No.2?
More precisely, why would some models partially update themselves without initSystem()?
I'm scripting in Matlab to set muscle parameters and obtain the according tendon force, and triggered a potential bug when parameters are changed after initSystem(). [I changed the post title as I realized the bug is not in initSystem() itself.]
My understanding is that, initSystem() must be called after muscle parameters are reset, otherwise simulation will be based on default parameters.
However, this theory seems to be model-dependent: with Arnold Model, yes; but with Gait2392 and Rajagopal Model, if initSystem() is called before parameters reset, muscle dynamics somehow changes, but it's not the same as when called after.
Please try the test code below in Matlab as an example:
soleus is activated 100% in default joint coordinates, and its optimal fiber length and tendon slack length are changed into 10 and 20 cm. [I wanted to attach a figure but was warned "the board attachment quota has been reached."]
For Gait2392, Arnold and Rajagapal:
1. The original tendon forces under this state are respectively 2794.3, 2942.0, 5205.6
2. initSystem() before parameter reset, the values become 3340.1, 2942.0, 5741.5
3. initSystem() after parameter reset, the values become 3164.4, 2822.6, 5254.6
Theoretically No.3 is the right answer, which is also the result I get manually from OpenSim, but why do the values change for Gait2392 and Rajagopal Model in No.2?
More precisely, why would some models partially update themselves without initSystem()?
Code: Select all
import org.opensim.modeling.*
modelFile = ;
myModel = Model(modelFile);
myMuscle = myModel.getMuscles().get("soleus_r");
% 1. Set muscle parameters here {
myMuscle.set_optimal_fiber_length(0.1);
myMuscle.set_tendon_slack_length(0.2);
% }
myState = myModel.initSystem();
myMuscle.setActivation(myState, 1);
% 2. Set muscle parameters here {
% }
myModel.equilibrateMuscles(myState);
myMuscle.getTendonForce(myState)
% 3. Set muscle parameters here {
% }
myModel.initSystem();
myMuscle.setActivation(myState, 1);
myModel.equilibrateMuscles(myState);
myMuscle.getTendonForce(myState)