Recent bugs fixed in Colvars library

We have recently discovered errors in the calculation of applied forces of the following collective variables (CVs) in Colvars: eigenvector with rotational fitting enabled, distanceZ with dynamic axis enabled, orientationAngle, orientation, and coordNum or selfCoordNum with pairlist. Restraints along those CVs using Colvars may be ineffective, i.e. produce a trajectory inconsistent with the restraint, or have otherwise unexpected results. Below are details:

  • eigenvector with rotational fitting: the gradients with respect to the fitting group (fit gradients), which are normally enabled for all CVs, were disabled by default for eigenvector. However, numerical tests show that these fit gradients cannot be ignored (link). This issue does not affect calculations of eigenvector when the keyword rotateToReference is disabled, or of other CVs irrespective of rotational fitting.

  • orientation and orientationAngle: because the two quaternions q and -q represent identical orientations, Colvars uses the convention that the first component q0 >= 0, flipping the sign if needed from the calculated quaternion to simplify analysis of trajectories. However, the same correction was not applied to the gradients (link), resulting in inconsistently applied forces over a simulation. This issue does not affect the other rotational CVs (orientationProj, tilt, spinAngle, eulerPhi, eulerTheta, eulerPsi).

  • coordNum and selfCoordNum with pairlist: when using these two types of coordination number with pairlist enabled, a factor was missing when calculating the gradients of the switching function with respect to the atomic coordinates. Note that the relative errors between the wrong and correct gradients are linearly correlated with the pairlist tolerance. For example, a pairlist tolerance of 0.01 could make the gradients 1% smaller or larger than the correct results. This issue has been fixed (link), and is specific to the pairlist, i.e. does not occur when the parameter β€œtolerance” is 0 (default).

  • distanceZ with dynamic axis: when defining an optional β€œref2” group, the reference axis is dynamically defined as the distance vector between β€œref” and β€œref2”. The gradients with respect to the dynamic axis were incorrectly calculated, and have now been fixed (link). The issue does not affect calculations when the axis is explicitly given using the keyword β€œaxis”, or when it is omitted to use the default axis (0, 0, 1).

The above bugs may affect your simulations only if you are using Colvars to apply biasing forces along the above CVs with the specified options. For that purpose, you should update to the latest LAMMPS maintenance release or to the latest feature release, both of which contain a version of Colvars updated for those bugfixes. Note: because VMD does not apply forces to atoms, calculations of the above variables from a pre-existing trajectory are still reliable even without the bugfix.

Please let us know through this forum if your work was affected by the above bugs: if you are unable to update to the bugfix release, feel free to reach out for suggested workarounds. We thank you for your patience addressing these bugs, and for your help making your colleagues aware of them.

Sincerely, the Colvars developers

4 Likes