Skip to content

Commit

Permalink
Use WithinRel comparison for fiber stiffness since were using a finit…
Browse files Browse the repository at this point in the history
…e-differenced estimate
  • Loading branch information
nickbianco committed Oct 2, 2024
1 parent 3587789 commit 5f3a5e7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions OpenSim/Actuators/Test/testDeGrooteFregly2016Muscle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,20 +634,20 @@ TEST_CASE("DeGrooteFregly2016Muscle basics") {
SimTK::Real fiberStiffnessAlongTendon =
diffFiberStiffnessAlongTendon.calcDerivative(
muscle.get_optimal_fiber_length());
CHECK(muscle.getFiberStiffnessAlongTendon(state) ==
Approx(fiberStiffnessAlongTendon));
CAPTURE(muscle.getFiberStiffnessAlongTendon(state));
CAPTURE(fiberStiffnessAlongTendon);
CHECK_THAT(muscle.getFiberStiffnessAlongTendon(state),
Catch::Matchers::WithinRel(fiberStiffnessAlongTendon, 1e-6));

SimTK::Real tendonStiffness = SimTK::Infinity;
CHECK(muscle.getTendonStiffness(state) == SimTK::Infinity);
SimTK::Real muscleStiffness = muscle.calcMuscleStiffness(
tendonStiffness, fiberStiffnessAlongTendon);
CAPTURE(muscleStiffness);
CAPTURE(tendonStiffness);
CAPTURE(fiberStiffnessAlongTendon);
CAPTURE(muscle.getTendonStiffness(state));
CAPTURE(muscle.getFiberStiffnessAlongTendon(state));
CHECK_THAT(muscle.getMuscleStiffness(state),
Catch::Matchers::WithinAbs(muscleStiffness, 1e-10));
Catch::Matchers::WithinRel(muscleStiffness, 1e-6));
CHECK_THAT(muscle.getFiberActivePower(state),
Catch::Matchers::WithinAbs(0.0, 1e-10));
CHECK(muscle.getFiberPassivePower(state) ==
Expand Down

0 comments on commit 5f3a5e7

Please sign in to comment.