Today I learned the magic of CFM (constraint force mixing). If CFM is not introduced, the matrix A will somehow manages to get itself into singularity at some uncertain timesteps. I think physically the system just moves to a lock-up position when A becomes singular. The simplest solution used by ODE is to add a (diminutive) positive value (CFM) to the diagonal of A such that A will keep away from singularity. A quote from the ODE manual – A nonzero value of CFM allows the original constraint equation to be violated by an amount proportional to CFM times the restoring force lambda that is needed to enforce the constraint.

However, since the global CFM is an arbitrary value added to the diagonal of A, it is inherently unfair comparison when two different As are formulated and applied with the same value of CFM. This case happens when I try to compare the results of the Smith and Baraff formulations. Without the errors introduced by the CFM, the results match pretty well while subjected to some numerical roundoff errors. But the risk is either result may blow up under different circumstances without the help of the CFM. Adding the CFM allows the errors to accumulate and my guess is the errors will become substantial after many timesteps.

The system I used for this method comparison is of course my favorite piston assembly simulation. I may just try imposing the CFM to only one of the boundary joints to reduce the errors while retaining stability. After looking around for a while, it seems that only the CFM of the limit motor can be changed …