# Re: Restraining angle between bond vector and coordinate vector

From: Seth Axen (seth.axen_at_gmail.com)
Date: Wed Mar 25 2015 - 19:01:40 CDT

Hi Jeff and Jerome,

did almost exactly what I wanted to do, but I'm currently getting an error
when I try to run NAMD with it.

The code:
#Collective variables config file

colvarsTrajFrequency 1

colvar {
name theta

outputValue
outputAppliedForce

angle {
group1 {
atomNumbers 1120
centerReference on
refPositionsGroup { atomNumbers 1117 }
refPositions (0,0,0)
}
group2 {
atomNumbers 1117
centerReference on
refPositions (0,0,0)
}
group3 {
dummyAtom (0,1,0)
}
}
}

harmonic {
colvars theta
centers 132.5
forceConstant 10
}

The error:
ERROR: Constraint failure in RATTLE algorithm for atom 1120!

ERROR: Constraint failure; simulation has become unstable.

ERROR: Exiting prematurely; see error messages above.

There are no other errors in the log. I found that if I decreased the force
constant and the centers, I no longer received this error. The starting
theta value is 28.5, so I assume this is because the resulting force is
insanely large. However, I do need to restrain the angle at 132.5. What's
the proper way to handle this? Should I slowly increase centers from 28.5
to 132.5, and if so, how could I do that at set intervals?

Seth

On Mon, Mar 23, 2015 at 4:17 PM Jeff Comer <jeffcomer_at_gmail.com> wrote:

> Hi,
>
> Another solution, which is also due to Jérôme, is to use the
> "centerReference" keyword to shift the positions so that the second
> atom or group is at (0,0,0). Then you can calculate the angle
> group1–group2–arbitrary_fixed_axis.
>
> In the example below, I have two groups (atoms 1–10 and atoms 11–20)
> and want to keep the vector from the center of mass of atoms 11–20 to
> the center of mass of atoms 1–10 along the z-axis (defined by
> dummyAtom (0,0,1)). I think this solution may also have problems in
> NAMD 2.10, so you'll need the nightly build of NAMD or compile NAMD
> with the current version of Colvars as indicated by Jérôme.
>
> colvar {
> name colatitude
>
> outputValue
> outputAppliedForce
>
> angle {
> group1 {
> atomNumbersRange 1-10
> centerReference on
> refPositionsGroup { atomNumbersRange 11-20 }
> refPositions (0,0,0)
> }
> group2 {
> atomNumbersRange 11-20
> centerReference on
> refPositions (0,0,0)
> }
> group3 {
> dummyAtom (0,0,1)
> }
> }
> }
>
> harmonic {
> colvars colatitude
> centers 0
> forceConstant 10
> }
>
> –––––––––––––––––––––––––––––––––––———————
> Jeffrey Comer, PhD
> Assistant Professor
> Institute of Computational Comparative Medicine
> Nanotechnology Innovation Center of Kansas State
> Kansas State University
> Office: P-213 Mosier Hall
> Phone: 785-532-6311
>
>
> On Mon, Mar 23, 2015 at 3:26 PM, Seth Axen <seth.axen_at_gmail.com> wrote:
> > I would like to add a harmonic restraint for an angle between a specific
> > bond vector and a target vector in 3D space, defined by 3 coordinates.
> The
> > resulting force should be updated at every step of the simulation. I'm