Colvars Angles

Hi All,
I am new to using the colvars package/fix.

I would like to apply two constraints to a pair of atoms.

First, I would like to apply a harmonic potential between the two atoms, based on their distance from one another. This seems to work fine.

I would also like to apply a constraint to keep the two particles parallel to a single axis.
The relevant block for defining this angle in the .colvars file is below:

colvar {
name angle

orientationangle {
atoms {
atomnumbers 1 9022
}
refpositions (0, 0, 0) (10, 0, 0)

}
}

This block produces output that makes sense most of the time, but intermittently has values that are wrong. The output from the .traj file is below:

step one fa_one angle E_h_pot x0_one W_h_pot

0 2.63443126732797e+01 4.96706198016085e+00 7.10991472947676e+00 4.11195078579324e+00 2.80000000000000e+01 -2.15239352473637e+00
1 2.63445235947703e+01 4.96642921568898e+00 7.10980348107483e+00 4.11090319240818e+00 2.80000000000000e+01 -4.30451285153493e+00
2 2.63447172415882e+01 4.96584827523553e+00 7.10970573171377e+00 4.10994151544328e+00 2.80000000000000e+01 -6.45638043747032e+00
3 2.63448937414113e+01 4.96531877576597e+00 7.10962199287174e+00 4.10906509082901e+00 2.80000000000000e+01 -8.60801857363558e+00
4 2.63450534150514e+01 4.96483975484581e+00 7.10955270220001e+00 4.10827229854957e+00 2.80000000000000e+01 -1.07594491340688e+01
5 2.63451967319910e+01 4.96440980402706e+00 7.10949824538948e+00 4.10756078371999e+00 2.80000000000000e+01 -1.29106933824805e+01
6 2.63453243392690e+01 4.96402698219292e+00 1.79979388626225e+02 4.10692731332322e+00 2.80000000000000e+01 -1.50617717414308e+01
7 2.63454369997417e+01 4.96368900077495e+00 7.10943484838600e+00 4.10636808273571e+00 2.80000000000000e+01 -1.72127036417666e+01
8 2.63455356106389e+01 4.96339316808321e+00 7.10942624765969e+00 4.10587862349585e+00 2.80000000000000e+01 -1.93635073479360e+01
9 2.63456211470618e+01 4.96313655881467e+00 7.10943305980519e+00 4.10545408357378e+00 2.80000000000000e+01 -2.15141998567556e+01
10 2.63456946650961e+01 4.96291600471174e+00 7.10984839588891e+00 4.10508921163732e+00 2.80000000000000e+01 -2.36647967921307e+01
11 2.63457572996944e+01 4.96272810091666e+00 1.79304379628549e+02 4.10477836727131e+00 2.80000000000000e+01 -2.58153123025279e+01
12 2.63458102315154e+01 4.96256930545368e+00 7.10954396489181e+00 4.10451568523850e+00 2.80000000000000e+01 -2.79657590015579e+01

The value of 7.1 for the angle is correct, based on the positions of the particles, but at random times the value jumps to ~ 180 as it does at steps # 6 and 11. This produces warning messages:
colvars: Warning: one molecular orientation has changed by more than 0.01: discontinuous rotation ?

It seems this could be because I’ve done something incorrectly, but then the correct values confuse me. Is this a bug or have I done something wrong?
The problem seems consistent between LAMMPS versions 9 Dec 2014 and 14 Jun 2014.

Thanks,
Mike

mike,

do you mind updating your sources using the colvars code from colvars.github.io?
there has been a bugfix commit in relative to the very latest released
version just yesterday that seems related.

if you have a compatible OS, you may save the effort to compile by
downloading a precompiled (serial) binary rpm from rpm.lammps.org
(just updated them) and then extracting the executable with rpm2cpio
lammps-latest.x86_64.rpm | cpio -ivd

if the issue persists, i suggest you better report the issue on the
github issue tracker and attach example inputs to reproduce it.

axel.

Hey Axel, luckily the fix you mentioned it is not related.

The problem is that with only two atoms it is difficult to calculate a superposition matrix, which is the basis of orientationAngle. Use at least 4-5 atoms whose structure doesn’t change significantly, and it should work.

Giacomo

Thank you both for your rapid responses. This is consistent with what I see, since the colvars update doesn’t fix the problem. Is there a simple way to do what I want with two atoms that I am overlooking?

Thanks,
Mike

Thank you both for your rapid responses. This is consistent with what I
see, since the colvars update doesn't fix the problem. Is there a simple
way to do what I want with two atoms that I am overlooking?

if you don't need any biasing force information, you could try using
fix aveforce on the in-plane force components for the two atoms (in
addition to the harmonic restraint orthogonal to it) to achieve the
effect you desire.

axel.