opensim-org / opensim-core

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

Fix for issue #3783. Bhargava metabolic model returning the correct muscle mass. #3840

Closed stingjp closed 4 months ago

stingjp commented 4 months ago

Previously, when adding a muscle to a Bhargava2004SmoothMuscleMetabolics component, the muscle mass is calculated based on either the provided muscle mass or specific tension and stored in a member variable via Bhargava2004SmoothedMuscleMetabolics_MuscleParameters::setMuscleMass(). Example here.

However, during deserialization, setMuscleMass() is never called for all connected muscles leaving the muscle masses set to zero, which obviously produces incorrect metabolic cost values.

Fixes issue #3783

Brief summary of changes

Included the extendConnectToModel method in the header file for Bhargava2004SmoothMuscleMetabolics, so that it could be called in the .cpp file. In the method, looped through the muscles that are stored in the list property for the metabolics object, and called setMuscleMass.

Testing I've completed

Tested the changes locally using the edited sandboxSandbox.cpp file. The file now works as a simple test by creating a model, adding the metabolic component, and printing the model. It then loads in the model file, and verifies that the returned muscle mass matches what was originally set.

Looking for feedback on...

First pull request - any feedback welcome.

CHANGELOG.md (choose one)


This change is Reviewable

stingjp commented 4 months ago

@nickbianco Thanks for the comments, totally makes sense. I should now have all the changes that you mentioned committed, including adding a short entry to the CHANGELOG_MOCO.md. Let me know if anything else is out of place!

stingjp commented 4 months ago

Fixed!

stingjp commented 4 months ago

Good catch, done!

nickbianco commented 4 months ago

Thanks @stingjp!