Re: Colvars: Are the derivatives of optimal rotation matrix wrt atomic coordinates applied implicitly?

From: Giacomo Fiorin (
Date: Wed Mar 13 2019 - 10:39:20 CDT

Hi Haochuan, those are special cases (yet rather common, as they are
default behavior) when the RMSD is computed over the same atoms used in the
fitting. The fit gradients happen to be zero, because the optimal rotation
is by definition the one that minimizes the RMSD, and the fit gradients are
disabled to save compute time. For eigenvector, it is a more complicated
to justify in a sentence, but it turns out that the fit gradients also
cancel out in the special case when the group used in the variable and the
group used for fitting coincide.

In your new variable, you should verify first that it behaves like RMSD and
eigenvector with respect to this, and only in that case disable the fit
gradients for good. Otherwise, it is probably safer to not disable them
via a hard-coded instruction but leave the option to disable them at run
time, which is always available.


On Wed, Mar 13, 2019 at 11:10 AM <> wrote:

> Dear Jérôme,
> I changed my code to use enable(f_ag_fit_gradients) and it seems I get the
> correct gradients! Thanks a lot!
> By the way, I have seen that the constructor of colvar::rmsd and
> colvar::eigenvector uses disable(f_ag_fit_gradients), and that's why I also
> disable it in my class constructor. Why is the feature disabled in these
> cases?
> Best regards,
> Haochuan Chen
> 在 2019/3/13 下午10:37, Jérôme Hénin 写道:
> Dear Haochuan,
> Yes. That is handled at the atom group level by enableFitGradients, which
> defaults to true. Cases where the calculation is not supported will trigger
> a dependency failure, so you cannot miss them.
> Best,
> Jérôme
> On Wed, 13 Mar 2019 at 14:04, <> wrote:
>> Dear NAMD and Colvars developers,
>> If I have a vector *v* = *R* * *X* - *X*_ref, where the *X* is current
>> Cartesian coordinates of a set of atoms, *X*_ref is the reference
>> coordinates and *R* is the optimal rotation matrix, and in the C++
>> interface I have correctly setup the ref_pos of atom_group *X* in the
>> C++ interface. Assuming I have a scalar function f(*v*) and I know the
>> derivative of f with respect of *v* (df/d*v*), can I use df/d*v *as the
>> atomic gradients of atom_group *X*? In other words, can I assume d*R*/d
>> *X* is automatically computed when I have setup b_rotate and ref_pos of
>> *X* in the atom_group initialization?
>> Thanks,
>> Haochuan Chen

Giacomo Fiorin
Associate Professor of Research, Temple University, Philadelphia, PA
Contractor, National Institutes of Health, Bethesda, MD

This archive was generated by hypermail 2.1.6 : Tue Dec 31 2019 - 23:20:36 CST