opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
783 stars 316 forks source link

Move muscle stiffness calculation to Muscle.h #3685

Closed pepbos closed 8 months ago

pepbos commented 8 months ago

This PR moves the muscle stiffness computation of all derived muscle classes to the base class: Muscle.

This is a cleanup of the MuscleDynamicsInfo, which contains fields that are cheap to compute, but are still cached. It also serves to unify the computation of the outputs across all muscles.

Note on stiffness calculations

The muscle stiffness calculation differed slightly between the different muscles. In Millard2012EquilibriumMuscle the calculation included the following checks:

For the RigidTendonMuscle and the muscle in testMuscleMetabolicsProbes.cpp the stiffness was always zero. This PR does not change that result for these muscles.

Brief summary of changes

Testing I've completed

Unit tests passing.

Looking for feedback on...

@nickbianco the method calcMuscleStiffness(...) in DeGrooteFregley2016Muscle was used for the computation for MuscleDynamicsInfo.muscleStiffness, but is no longer needed. It is however a public function, and it is used in the unit test. What would you recommend doing here? Leave as is? Remove from class, and move to unit test? Flag as deprecated?

https://github.com/opensim-org/opensim-core/blob/98c70b1fd5bc74da63e69a52e860c742840a9a16/OpenSim/Actuators/DeGrooteFregly2016Muscle.h#L605

CHANGELOG.md (choose one)


This change is Reviewable