compute gyration/molecule bug

Dear Steve,

My colleagues and me have encountered an unexpected behavior compute gyration/molecule.

It frequently outputs NaN instead of the off-diagonal components of gyration tensor.

The issue arises from the sqrt() in (compute_gyration_molecule.cpp:215) which may be called with negative argument.

The sqrt() calls were probably added after this discussion in the mail list: http://sourceforge.net/p/lammps/mailman/message/32333536/ .

Regards,

Vasily

Certainly something that we did not foresee then. Eric at the time had the most sensible solution. Make all gyration related computes output squared quantities and note this in the documentation.

-s-

Attached is a patch to modify lammps so that it outputs squared Rg instead of their square roots. I feel responsible for the issue so I gave it a shot (and it seemed trivial enough). First time I modify lammps (or any cpp program) so I may have missed something. The only non-obvious modification that I did was to the fix_spring_rg.cpp file which seems to expect the square root of Rg. I also modified the relevant files in the documentation.

Since this is my first time I outline how I generated the patch file. For the record and in case somewhat can point out any mistakes:

  1. clone the repository via git

  2. create and checkout an new branch

  3. modify files

  4. git diff --no-prefix > patch.diff

That is it. Hopefully it is satisfactory.

Salomon

rgfix.diff (5.53 KB)

Salomon - thanks for the patch, but
I think we should put the code back to the way it was originally.
For the scalar result, you get Rg, not Rg^2, since Rg

is what the user expects. For the tensor, I didn’t think about
the fact the cross-terms could be negative, so I think the

tensor should be the squared values, e.g. RgxRgy, which could
be negative. So long as we document it, the user can figure
out what to do with either the scalar or tensor values.

I will post a patch.

Steve