Re: Restraining angle between bond vector and coordinate vector

From: Jeff Comer (
Date: Mon Mar 23 2015 - 18:17:18 CDT


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

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


   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 <> 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
> having trouble figuring out the best way to go about this from the
> documentation and user-defined forces examples, and I'd appreciate any
> suggestions.
> Thanks!

This archive was generated by hypermail 2.1.6 : Tue Dec 27 2016 - 23:21:01 CST