2 Writing a Colvars configuration: a crash course

The Colvars configuration is a plain text file or string that defines collective variables, biases, and general parameters of the Colvars module. It is passed to the module using back-end-specific commands documented in section 3.

Example: steering two groups of atoms away from each other.

Now let us look at a complete, non-trivial configuration. Suppose that we want to run a steered MD experiment where a small molecule is pulled away from a protein binding site. In Colvars terms, this is done by applying a moving restraint to the distance between the two objects. The configuration will contain two blocks, one defining the distance variable (see section 4 and 4.3.1), and the other the moving harmonic restraint (6.8).

colvar {
  name dist
  distance {
    group1 { atomNumbersRange 42-55 }
    group2 { indexGroup C-alpha_15-30 }
  }
}

harmonic {
  colvars dist
  forceConstant 20.0
  centers 4.0         # initial distance
  targetCenters 15.0  # final distance
  targetNumSteps 500000
}

Reading this input in plain English: the variable here named dist consists in a distance function between the centers of two groups: the ligand (atoms 42 to 55) and the α-carbon atoms of residues 15 to 30 in the protein (segment name PR). To the “dist” variable, we apply a harmonic potential of force constant 20 kcal/mol/Å2, initially centered around a value of 4 Å, which will increase to 15 Å over 500,000 simulation steps.

The atom selection keywords are detailed in section 5.

Example: using multiple variables and multiple biasing/analysis methods together.

A more complex example configuration is included below, showing how a variable may be constructed by combining multiple existing functions, and how multiple variables or multiple biases may be used concurrently. The colvar indicated below as “d” is defined as the difference between two distances (see 4.3): the first distance (d1) is taken between the center of mass of atoms 1 and 2 and that of atoms 3 to 5, the second (d2) between atom 7 and the center of mass of atoms 8 to 10 (see 5). The difference d=d1−d2 is obtained by multiplying the two by a coefficient C=+1 or C=−1, respectively (see 4.19). The colvar called “c” is the coordination number calculated between atoms 1 to 10 and atoms 11 to 20. A harmonic restraint (see 6.8) is applied to both d and c: to allow using the same force constant K, both d and c are scaled by their respective fluctuation widths wd and wc. A third colvar “alpha” is defined as the α-helical content of residues 1 to 10 (see 4.8.1). The values of “c” and “alpha” are also recorded throughout the simulation as a joint 2-dimensional histogram (see 6.13).

colvar {
  # difference of two distances
  name d 
  width 0.2  # estimated fluctuation width 
  distance {
    componentCoeff  1.0
    group1 { atomNumbers 1 2 }
    group2 { atomNumbers 3 4 5 }
  }
  distance {
    componentCoeff -1.0
    group1 { atomNumbers 7 }
    group2 { atomNumbers 8 9 10 }
  }
}

colvar {
  name c
  coordNum {
    cutoff 6.0
    group1 { atomNumbersRange  1-10 }
    group2 { atomNumbersRange 11-20 }
    tolerance 1.0e-6
    pairListFrequency 1000
  }
}
colvar {
  name alpha
  alpha {
    psfSegID PROT
    residueRange 1-10
  }
}

harmonic {
  colvars d c
  centers 3.0 4.0
  forceConstant 5.0
}

histogram {
  colvars c alpha
}