Page 1 of 1

Discrepancy Between Calculated Muscle Forces and Static Optimization Results

Posted: Tue Dec 17, 2024 12:40 am
by huhu
After performing static optimization, I obtained two files: `HYOID_Scaled_StaticOptimization_activation.sto` and `HYOID_Scaled_StaticOptimization_force.sto`. I am now using the activations obtained from the static optimization to calculate muscle forces and comparing them to the forces from the static optimization results. The code snippet is as follows.

Code: Select all

for i in range(nCoords):
        coord = coord_set.get(i)
        coord_value = data.get(i * 2)  
        coord_speed = data.get(i * 2 + 1)
        coord.setValue(state, coord_value)
        coord.setSpeedValue(state, coord_speed)
model.realizeVelocity(state)

Code: Select all

for i in range(nMuscles):
        muscle = MuscleSet.get(i)
        muscle_force[j, i] = muscle.calcInextensibleTendonActiveFiberForce(state, 1.0)*\
                            activation_data.get(i)
Below are the results of the comparison. The calculated results do not match exactly. How should this be interpreted? Am I missing something?

Re: Discrepancy Between Calculated Muscle Forces and Static Optimization Results

Posted: Thu Dec 19, 2024 5:37 am
by tkuchida
Are there any constraints in the model? If so, you should use

Code: Select all

coord.setValue(state, coord_value, False)
and then call the assembler after the loop. Please see the comments in the documentation for the Coordinate::setValue() method here: https://simtk.org/api_docs/opensim/api_ ... f2e88d7c42.

Re: Discrepancy Between Calculated Muscle Forces and Static Optimization Results

Posted: Mon Dec 23, 2024 7:01 pm
by huhu
Thank you for your reply, but I found that after making this adjustment, there is no noticeable difference in the results. Here is the code snippet:

Code: Select all

for i in range(nCoords):
        coord = coord_set.get(i)
        coord_value = data.get(i * 2)  
        coord_speed = data.get(i * 2 + 1)
        coord.setValue(state, coord_value, False)
        coord.setSpeedValue(state, coord_speed)
model.assemble(state)    
model.realizeVelocity(state)

Re: Discrepancy Between Calculated Muscle Forces and Static Optimization Results

Posted: Thu Dec 26, 2024 8:20 pm
by nicos1993
Hello Huhu,

How are you calculating the coordinate speeds when you manually try to calculate muscle forces? Perhaps differences between your coordinate speeds and those calculated by the static optimization tool differ (impacting the force-velocity multiplier) which may explain the differences you observe.

Thanks,

Nicos