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

Force::computePotentialEnergy() should not default to return 0.0 #3775

Open aseth1 opened 6 months ago

aseth1 commented 6 months ago

Force's potential_energy Output dispatches to virtual computePotentialEnergy() that has a default implementation that returns 0.0 Only a handful of Forces implement it so the rest are returning 0.0, which is wrong for any type of energy accounting.

An immediate fix is to have it return NaN which would make energy book keeping invalid, which is preferable over being wrong. Users of OpenSim have no idea why it would be wrong.