This PR replaces separate calls to calcValue and calcDerivative on the muscle curves in Millard2012EquilibriumMuscle by calcValueAndDerivative, which is more efficient.
The MuscleLengthInfo::userDefinedLengthExtras and FiberVelocityInfo::userDefinedVelocityExtras buffers are used to store the derivatives of the curves until needed.
Measuring the wallclock time of Rajagopal forward integration, and CMC running-model (using Millard muscles) shows around 10% perf benefit:
main
with this PR
CMC-Running Model
25.8 [s]
22.9 [s] (-12.4%)
Rajagopal Forward Integration
6.4 [s]
5.8 [s] ( -9.8% )
Brief summary of changes
There are 4 relevant muscle curves in Millard2012EquilibriumMuscle which are calling calcValue and calcDerivative, which is combined to calcValueAndDerivative by this PR:
Added calcValueAndDerivative method to:
ActiveForceLengthCurve.h
TendonForceLengthCurve.h
FiberForceLengthCurve.h
TendonForceLengthCurve.h
Regarding the ActiveForceLengthCurve and TendonForceLengthCurve:
moved computing curve derivative to calcMuscleLengthInfo, and store result in MuscleLengthInfo::userDefinedLengthExtras
moved Millard2012EquilibriumMuscle::calcFiberStiffness to anonymous namespace (this was using the derivative values)
Regarding the ForceVelocityCurve:
use calcValueAndDerivative during calcDampedNormFiberVelocity() instead of calcValue followed by calcDerivative.
return last evaluation of fiberForceVelocityCurve from calcDampedNormFiberVelocity()
Regarding the TendonForceLengthCurve:
Compute fiberstiffness and tendonforcelength multiplier during calcFiberVelocityInfo() and store in FiberVelocityInfo::userDefinedVelocityExtras
Testing I've completed
Unit tests are passing, and Rajagopal forward simulation as well as CMC on running-model gives no change in results.
This PR replaces separate calls to
calcValue
andcalcDerivative
on the muscle curves inMillard2012EquilibriumMuscle
bycalcValueAndDerivative
, which is more efficient.The
MuscleLengthInfo::userDefinedLengthExtras
andFiberVelocityInfo::userDefinedVelocityExtras
buffers are used to store the derivatives of the curves until needed.Measuring the wallclock time of Rajagopal forward integration, and CMC running-model (using Millard muscles) shows around 10% perf benefit:
Brief summary of changes
There are 4 relevant muscle curves in
Millard2012EquilibriumMuscle
which are callingcalcValue
andcalcDerivative
, which is combined tocalcValueAndDerivative
by this PR:Added
calcValueAndDerivative
method to:ActiveForceLengthCurve.h
TendonForceLengthCurve.h
FiberForceLengthCurve.h
TendonForceLengthCurve.h
Regarding the
ActiveForceLengthCurve
andTendonForceLengthCurve
:calcMuscleLengthInfo
, and store result inMuscleLengthInfo::userDefinedLengthExtras
Millard2012EquilibriumMuscle::calcFiberStiffness
to anonymous namespace (this was using the derivative values)Regarding the
ForceVelocityCurve
:calcValueAndDerivative
duringcalcDampedNormFiberVelocity()
instead ofcalcValue
followed bycalcDerivative
.fiberForceVelocityCurve
fromcalcDampedNormFiberVelocity()
Regarding the
TendonForceLengthCurve
:calcFiberVelocityInfo()
and store inFiberVelocityInfo::userDefinedVelocityExtras
Testing I've completed
Unit tests are passing, and Rajagopal forward simulation as well as CMC on running-model gives no change in results.
CHANGELOG.md
This change is