Colvars Manual
Colvars Manual
Alejandro Bernardin, Jeffrey R. Comer, Giacomo Fiorin, Haohao Fu, Jérôme Hénin, Axel
Kohlmeyer, Fabrizio Marinelli, Joshua V. Vermaas, Andrew D. White
Contents
1 Overview 3
2 A crash course 4
3 General parameters 5
3.1 LAMMPS keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Configuration syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3 Global keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.4 Output files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1
4.8 Trajectory output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.9 Extended Lagrangian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.10 Backward-compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.11 Statistical analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5 Selecting atoms 36
5.1 Atom selection keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.2 Moving frame of reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.3 Treatment of periodic boundary conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4 Performance of a Colvars calculation based on group size. . . . . . . . . . . . . . . . . . . 40
2
1 Overview
In molecular dynamics simulations, it is often useful to reduce the large number of degrees of freedom of a
physical system into few parameters whose statistical distributions can be analyzed individually, or used to
define biasing potentials to alter the dynamics of the system in a controlled manner. These have been called
‘order parameters’, ‘collective variables’, ‘(surrogate) reaction coordinates’, and many other terms.
Here we use primarily the term ‘collective variable’, often shortened to colvar, to indicate any differen-
tiable function of atomic Cartesian coordinates, xi , with i between 1 and N, the total number of atoms:
This manual documents the collective variables module (Colvars), a software that provides an implemen-
tation for the functions ξ (X) with a focus on flexibility, robustness and high performance. The module is
designed to perform multiple tasks concurrently during or after a simulation, the most common of which
are:
• apply restraints or biasing potentials to multiple variables, tailored on the system by choosing from a
wide set of basis functions, without limitations on their number or on the number of atoms involved;
• calculate potentials of mean force (PMFs) along any set of variables, using different enhanced sam-
pling methods, such as Adaptive Biasing Force (ABF), metadynamics, steered MD and umbrella
sampling; variants of these methods that make use of an ensemble of replicas are supported as well;
• calculate statistical properties of the variables, such as running averages and standard deviations,
correlation functions of pairs of variables, and multidimensional histograms: this can be done either
at run-time without the need to save very large trajectory files, or after a simulation has been completed
using VMD and the cv command.
Detailed explanations of the design of the Colvars module are provided in reference [1]. Please cite this
reference whenever publishing work that makes use of this module.
3
2 A crash course
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.1.1), and the other the moving harmonic restraint (6.4).
colvar {
name dist
distance {
group1 { atomNumbersRange 42-55 }
group2 {
psfSegID PR
atomNameResidueRange CA 15-30 }
}
}
}
harmonic {
colvars dist
forceConstant 20.0
centers 4. # initial distance
targetCenters 15. # 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 alpha carbon atoms (CA) of residues 15 to 30
in the protein (segment name PR). The atom selection syntax is detailed in section 5.
To the “dist” variable, we apply a harmonic potential of force constant 20 energy units/Å2 , initially
centered around a value of 4 Å, which will increase to 15 Å over 500,000 simulation steps.
4
3 General parameters
Here, we document the syntax of the commands and parameters used to set up and use the Colvars module
in LAMMPS. One of these parameters is the configuration file or the configuration text for the module itself,
whose syntax is described in 3.2 and in the following sections.
where ID is a string that uniquely identifies this fix command inside a LAMMPS script, configfile is the
name of the configuration file for the Colvars module, followed by one or more of the following optional
keywords with their corresponding arguments:
5
Description: If defined, the value of this keyword is provided as seed to the random number genera-
tor. This is only meaningful when the extendedLangevinDamping keyword is used (see 4.9).
• a long value or a list of multiple values can be distributed across multiple lines by using curly braces,
“{” and “}”: the opening brace “{” must occur on the same line as the keyword, following a space
character or other white space; the closing brace “}” can be at any position after that;
• many keywords are nested, and are only meaningful within a specific context: for every keyword
documented in the following, the “parent” keyword that defines such context is also indicated;
• the hash character # indicates a comment: all text in the same line following this character will be
ignored.
6
• colvarsRestartFrequency h Colvar module restart frequency i
Context: global
Acceptable values: positive integer
Default value: restartFreq
Description: Allows to choose a different restart frequency for the Colvars module. Redefining it
may be useful to trace the time evolution of those few properties which are not written to the trajectory
file for reasons of disk space.
To illustrate the flexibility of the Colvars module, a non-trivial setup is represented in Figure 1. The
corresponding configuration is given below. The options within the colvar blocks are described in 4, those
within the harmonic and histogram blocks in 6. Note: except colvar, none of the keywords shown is
mandatory.
colvar {
# difference of two distances
name d
width 0.2 # 0.2 Å of 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 {
7
Figure 1: Graphical representation of a Colvars configuration (note: currently, the α-helical content colvar
is unavailable in LAMMPS). The colvar called “d” is defined as the difference between two distances: 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. The difference d = d1 − d2 is obtained
by multiplying the two by a coefficient C = +1 or C = −1, respectively. The colvar called “c” is the
coordination number calculated between atoms 1 to 10 and atoms 11 to 20. A harmonic restraint 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 . The values of “c” are also recorded throughout the simulation as a joint
2-dimensional histogram.
name c
coordNum {
cutoff 6.0
group1 { atomNumbersRange 1-10 }
group2 { atomNumbersRange 11-20 }
}
}
harmonic {
colvars d c
centers 3.0 4.0
forceConstant 5.0
}
histogram {
colvars c
}
8
Section 4 explains how to define a colvar and its behavior, regardless of its specific functional form. To
define colvars that are appropriate to a specific physical system, Section 5 documents how to select atoms,
and section 4 lists all of the available functional forms, which we call “colvar components”. Finally, section
6 lists the available methods and algorithms to perform biased simulations and multidimensional analysis of
colvars.
• A state file, named output.colvars.state; this file is in ASCII (plain text) format. This file is written
at the end of the specified run.
This is the only Colvars output file needed to continue a simulation.
• If the parameter colvarsRestartFrequency is larger than zero, a restart file is written every that
many steps: this file is fully equivalent to the final state file. The name of this file is restart.colvars.state.
• If the parameter colvarsTrajFrequency is greater than 0 (default: 100), a trajectory file is written
during the simulation: its name is output.colvars.traj; unlike the state file, it is not needed to
restart a simulation, but can be used later for post-processing and analysis.
Other output files may also be written by specific methods, e.g. the ABF or metadynamics methods (6.1,
6.3). Like the trajectory file, they are needed only for analyzing, not continuing a simulation. All such files’
names also begin with the prefix output.
9
4 Defining collective variables
A collective variable is defined by the keyword colvar followed by its configuration options contained
within curly braces:
colvar {
name xi
<other options>
function name {
<parameters>
<atom selection>
}
}
• The simplest and most common way way is using one of the precompiled functions (here called “com-
ponents”), which are listed in section 4.1. For example, using the keyword rmsd (section 4.1.17)
defines the variable as the root mean squared deviation (RMSD) of the selected atoms.
• A new variable may also be constructed as a linear or polynomial combination of the components
listed in section 4.1 (see 4.5 for details).
• A user-defined mathematical function of the existing components (see list in section 4.1), or of the
atomic coordinates directly (see the cartesian keyword in 4.1.8). The function is defined through
the keyword customFunction (see 4.6 for details).
Choosing a component (function) is the only parameter strictly required to define a collective variable. It is
also highly recommended to specify a name for the variable:
10
• distance: distance between two groups;
• distanceInv: mean distance between two groups of atoms (e.g. NOE-based distance);
• rmsd: root mean square deviation (RMSD) from a set of reference coordinates;
• spinAngle: projection orthogonal to an axis of the best-fit rotation from a set of reference coordinates;
• tilt: projection on an axis of the best-fit rotation from a set of reference coordinates;
• cartesian: vector of atomic Cartesian coordinates (length: N times the number of Cartesian compo-
nents requested, X, Y or Z);
11
The types of components used in a colvar (scalar or not) determine the properties of that colvar, and
particularly which biasing or analysis methods can be applied.
What if “X” is not listed? If a function type is not available on this list, it may be possible to define it
as a polynomial superposition of existing ones (see 4.5), a custom function (see 4.6).
In the rest of this section, all available component types are listed, along with their physical units and the
ranges of values, if limited. Such limiting values can be used to define lowerBoundary and upperBoundary
in the parent colvar.
For each type of component, the available configurations keywords are listed: when two components
share certain keywords, the second component references to the documentation of the first one that uses
that keyword. The very few keywords that are available for all types of components are listed in a separate
section 4.2.
The value returned is a positive number (in Å), ranging from 0 to the largest possible interatomic distance
within the chosen boundary conditions (with PBCs, the minimum image convention is used unless the
forceNoPBC option is set).
12
4.1.2 distanceZ: projection of a distance vector on an axis.
The distanceZ {...} block defines a distance projection component, which can be seen as measuring the
distance between two groups projected onto an axis, or the position of a group along such an axis. The
axis can be defined using either one reference group and a constant vector, or dynamically based on two
reference groups. One of the groups can be set to a dummy atom to allow the use of an absolute Cartesian
coordinate.
List of keywords (see also 4.5 for additional options):
This component returns a number (in Å) whose range is determined by the chosen boundary conditions. For
instance, if the z axis is used in a simulation with periodic boundaries, the returned value ranges between
−bz /2 and bz /2, where bz is the box length along z (this behavior is disabled if forceNoPBC is set).
13
• main: see definition of main in sec. 4.1.2 (distanceZ component)
14
4.1.6 distanceInv: mean distance between two groups of atoms.
The distanceInv {...} block defines a generalized mean distance between two groups of atoms 1 and 2,
weighted with exponent 1/n:
n !−1/n
[n] 1 1
d1,2 = (2)
N1 N2 ∑i, j kdi j k
where kdi j k is the distance between atoms i and j in groups 1 and 2 respectively, and n is an even integer.
List of keywords (see also 4.5 for additional options):
This component returns a number in Å, ranging from 0 to the largest possible distance within the chosen
boundary conditions.
This component returns a N1 ×N2 -dimensional vector of numbers, each ranging from 0 to the largest possible
distance within the chosen boundary conditions.
15
• atoms h Group of atoms i
Context: cartesian
Acceptable values: Block atoms {...}
Description: Defines the atoms whose coordinates make up the value of the component. If rotateReference
or centerReference are defined, coordinates are evaluated within the moving frame of reference.
4.1.10 dipoleAngle: angle between two groups and dipole of a third group.
The dipoleAngle {...} block defines an angle, and contains the three blocks group1, group2 and group3,
defining the three groups, being group1 the group where dipole is calculated. It returns an angle (in degrees)
within the interval [0 : 180].
List of keywords (see also 4.5 for additional options):
16
• group2: analogous to group1
17
control its long range behavior and stiffness [2]. This function is summed over all pairs of atoms in group1
and group2:
1 − (|xi − x j |/d0 )n
C(group1, group2) = ∑ ∑ m
(3)
i∈group1 j∈group2 1 − (|xi − x j |/d0 )
18
Description: This controls the pairlist feature, dictating the minimum value for each summation
element in Eq. 3 such that the pair that contributed the summation element is included in subsequent
simulation timesteps until the next pairlist recalculation. For most applications, this value should be
small (eg. 0.001) to avoid missing important contributions to the overall sum. Higher values will
improve performance by reducing the number of pairs that contribute to the sum. Values above 1
will exclude all possible pair interactions. Similarly, values below 0 will never exclude a pair from
consideration. To ensure continuous forces, Eq. 3 is further modified by subtracting the tolerance and
then rescaling so that each pair covers the range [0, 1].
• pairListFrequency h Pairlist regeneration frequency i
Context: coordNum
Acceptable values: positive integer
Default value: 100
Description: This controls the pairlist feature, dictating how many steps are taken between regener-
ating pairlists if the tolerance is greater than 0.
This component returns a dimensionless number, which ranges from approximately 0 (all interatomic
distances are much larger than the cutoff) to Ngroup1 × Ngroup2 (all distances are less than the cutoff), or
Ngroup1 if group2CenterOnly is used. For performance reasons, at least one of group1 and group2 should
be of limited size or group2CenterOnly should be used: the cost of the loop over all pairs grows as
Ngroup1 × Ngroup2 . Setting tolerance > 0 ameliorates this to some degree, although every pair is still
checked to regenerate the pairlist.
The keywords accepted by selfCoordNum are a subset of those accepted by coordNum, namely group1 (here
defining all of the atoms to be considered), cutoff, expNumer, and expDenom.
List of keywords (see also 4.5 for additional options):
• group1: see definition of group1 in sec. 4.1.14 (coordNum component)
• cutoff: see definition of cutoff in sec. 4.1.14 (coordNum component)
• cutoff3: see definition of cutoff3 in sec. 4.1.14 (coordNum component)
• expNumer: see definition of expNumer in sec. 4.1.14 (coordNum component)
• expDenom: see definition of expDenom in sec. 4.1.14 (coordNum component)
• tolerance: see definition of tolerance in sec. 4.1.14 (coordNum component)
• pairListFrequency: see definition of pairListFrequency in sec. 4.1.14 (coordNum component)
This component returns a dimensionless number, which ranges from approximately 0 (all interatomic
distances much larger than the cutoff) to Ngroup1 × (Ngroup1 − 1)/2 (all distances within the cutoff). For
performance reasons, group1 should be of limited size, because the cost of the loop over all pairs grows as
2
Ngroup1 .
19
4.1.16 hBond: hydrogen bond between two atoms.
The hBond {...} block defines a hydrogen bond, implemented as a coordination number (eq. 3) between
the donor and the acceptor atoms. Therefore, it accepts the same options cutoff (with a different default
value of 3.3 Å), expNumer (with a default value of 6) and expDenom (with a default value of 8). Unlike
coordNum, it requires two atom numbers, acceptor and donor, to be defined. It returns an adimensional
number, with values between 0 (acceptor and donor far outside the cutoff distance) and 1 (acceptor and
donor much closer than the cutoff).
List of keywords (see also 4.5 for additional options):
4.1.17 rmsd: root mean square displacement (RMSD) from reference positions.
The block rmsd {...} defines the root mean square replacement (RMSD) of a group of atoms with respect
to a reference structure. For each set of coordinates {x1 (t), x2 (t), . . . xN (t)}, the colvar component rmsd
(ref)
calculates the optimal rotation U {xi (t)}→{xi } that best superimposes the coordinates {xi (t)} onto a set of
(ref)
reference coordinates {xi }. Both the current and the reference coordinates are centered on their centers
(ref)
of geometry, xcog (t) and xcog . The root mean square displacement is then defined as:
s
(ref) 1 N (ref) (ref) 2
RMSD({xi (t)}, {xi }) = ∑ U xi (t) − xcog (t) − xi − xcog (5)
N i=1
(ref)
The optimal rotation U {xi (t)}→{xi } is calculated within the formalism developed in reference [3], which
(ref)
guarantees a continuous dependence of U {xi (t)}→{xi } with respect to {xi (t)}.
List of keywords (see also 4.5 for additional options):
20
• refPositions h Reference coordinates i
Context: rmsd
Acceptable values: space-separated list of (x, y, z) triplets
Description: This option (mutually exclusive with refPositionsFile) sets the reference coordi-
nates for RMSD calculation, and uses these to compute the roto-translational fit. It is functionally
equivalent to the option refPositions in the atom group definition, which also supports more ad-
vanced fitting options.
1. applying the optimal translation, but no rotation (rotateReference off), to bias or restrain the shape
and orientation, but not the position of the atom group;
2. applying the optimal rotation, but no translation (translateReference off), to bias or restrain the
shape and position, but not the orientation of the atom group;
3. disabling the application of optimal roto-translations, which lets the RMSD component decribe the
deviation of atoms from fixed positions in the laboratory frame: this allows for custom positional
restraints within the Colvars module;
4. fitting the atomic positions to different reference coordinates than those used in the RMSD calculation
itself;
5. applying the optimal rotation and/or translation from a separate atom group, defined through fittingGroup:
the RMSD then reflects the deviation from reference coordinates in a separate, moving reference
frame.
21
4.1.19 eigenvector: projection of the atomic coordinates on a vector.
The block eigenvector {...} defines the projection of the coordinates of a group of atoms (or more
precisely, their deviations from the reference coordinates) onto a vector in R3n , where n is the number of
atoms in the group. The computed quantity is the total projection:
n
(ref) (ref) (ref)
p({xi (t)}, {xi }) = ∑ vi · U(xi (t) − xcog (t)) − (xi − xcog ) , (6)
i=1
(ref)
where, as in the rmsd component, U is the optimal rotation matrix, xcog (t) and xcog are the centers of
geometry of the current and reference positions respectively, and vi are the components of the vector for
each atom. Example choices for (vi ) are an eigenvector of the covariance matrix (essential mode), or a
normal mode of the system. It is assumed that ∑i vi = 0: otherwise, the Colvars module centers the vi
automatically when reading them from the configuration.
List of keywords (see also 4.5 for additional options):
• differenceVector h The 3n-dimensional vector is the difference between vector and refPositions i
Context: eigenvector
Acceptable values: boolean
Default value: off
Description: If this option is on, the numbers provided
by vector
are interpreted as another set of
0 0 (ref)
positions, xi : the vector vi is then defined as vi = xi − xi . This allows to conveniently define a
colvar ξ as a projection on the linear transformation between two sets of positions, “A” and “B”. For
convenience, the vector is also normalized so that ξ = 0 when the atoms are at the set of positions “A”
and ξ = 1 at the set of positions “B”.
This component returns a number (in Å), whose value ranges between the smallest and largest absolute
positions in the unit cell during the simulations (see also distanceZ). Due to the normalization in eq. 6, this
range does not depend on the number of atoms involved.
22
4.1.20 gyration: radius of gyration of a group of atoms.
The block gyration {...} defines the parameters for calculating the radius of gyration of a group of atomic
positions {x1 (t), x2 (t), . . . xN (t)} with respect to their center of geometry, xcog (t):
s
1 N 2
Rgyr = ∑ xi (t) − xcog (t) (7)
N i=1
This component must contain one atoms {...} block to define the atom group, and returns a positive
number, expressed in Å.
List of keywords (see also 4.5 for additional options):
• atoms: see definition of atoms in sec. 4.1.17 (rmsd component)
Note that all atomic masses are set to 1 for simplicity. This component must contain one atoms {...}
block to define the atom group, and returns a positive number, expressed in Å2 .
List of keywords (see also 4.5 for additional options):
• atoms: see definition of atoms in sec. 4.1.17 (rmsd component)
4.1.22 inertiaZ: total moment of inertia of a group of atoms around a chosen axis.
The block inertiaZ {...} defines the parameters for calculating the component along the axis e of the
moment of inertia of a group of atomic positions {x1 (t), x2 (t), . . . xN (t)} with respect to their center of
geometry, xcog (t):
N 2
Ie = ∑ xi (t) − xcog (t) · e (9)
i=1
Note that all atomic masses are set to 1 for simplicity. This component must contain one atoms {...}
block to define the atom group, and returns a positive number, expressed in Å2 .
List of keywords (see also 4.5 for additional options):
• atoms: see definition of atoms in sec. 4.1.17 (rmsd component)
23
4.1.23 orientation: orientation from reference coordinates.
The block orientation {...} returns the same optimal rotation used in the rmsd component to super-
(ref)
impose the coordinates {xi (t)} onto a set of reference coordinates {xi }. Such component returns a
four dimensional vector q = (q0 , q1 , q2 , q3 ), with ∑i q2i = 1; this quaternion expresses the optimal rota-
(ref)
tion {xi (t)} → {xi } according to the formalism in reference [3]. The quaternion (q0 , q1 , q2 , q3 ) can also
be written as (cos(θ /2), sin(θ /2)u), where θ is the angle and u the normalized axis of rotation; for ex-
ample, a rotation of 90◦ around the z axis is expressed as “(0.707, 0.0, 0.0, 0.707)”. The script
quaternion2rmatrix.tcl provides Tcl functions for converting to and from a 4 × 4 rotation matrix in a
format suitable for usage in VMD.
As for the component rmsd, the available options are atoms, refPositionsFile and refPositions.
Note: refPositionsand refPositionsFile define the set of positions from which the optimal rotation
is calculated, but this rotation is not applied to the coordinates of the atoms involved: it is used instead to
define the variable itself.
List of keywords (see also 4.5 for additional options):
• atoms: see definition of atoms in sec. 4.1.17 (rmsd component)
• refPositions: see definition of refPositions in sec. 4.1.17 (rmsd component)
• refPositionsFile: see definition of refPositionsFile in sec. 4.1.17 (rmsd component)
• closestToQuaternion h Reference rotation i
Context: orientation
Acceptable values: “(q0, q1, q2, q3)” quadruplet
Default value: (1.0, 0.0, 0.0, 0.0) (“null” rotation)
Description: Between the two equivalent quaternions (q0 , q1 , q2 , q3 ) and (−q0 , −q1 , −q2 , −q3 ), the
closer to (1.0, 0.0, 0.0, 0.0) is chosen. This simplifies the visualization of the colvar trajectory
when sampled values are a smaller subset of all possible rotations. Note: this only affects the output,
never the dynamics.
Tip: stopping the rotation of a protein. To stop the rotation of an elongated macromolecule in solution
(and use an anisotropic box to save water molecules), it is possible to define a colvar with an orientation
component, and restrain it throuh the harmonic bias around the identity rotation, (1.0, 0.0, 0.0, 0.0).
Only the overall orientation of the macromolecule is affected, and not its internal degrees of freedom. The
user should also take care that the macromolecule is composed by a single chain, or disable wrapAll other-
wise.
24
4.1.25 orientationProj: cosine of the angle of rotation from reference coordinates.
The block orientationProj {...} accepts the same base options as the component orientation: atoms,
refPositions, refPositionsFile. The returned value is the cosine of the angle of rotation θ between the
current and the reference positions. The range of values is [-1:1].
List of keywords (see also 4.5 for additional options):
The component spinAngle returns an angle (in degrees) within the periodic interval [−180 : 180].
Note: the value of spinAngle is a continuous function almost everywhere, with the exception of con-
figurations with the corresponding “tilt” angle equal to 180◦ (i.e. the tilt component is equal to −1): in
those cases, spinAngle is undefined. If such configurations are expected, consider defining a tilt colvar
using the same axis e, and restraining it with a lower wall away from −1.
25
• atoms: see definition of atoms in sec. 4.1.17 (rmsd component)
• spinAngle: angle of rotation around a predefined axis in the best-fit from a set of reference coordi-
nates.
In certain conditions, distanceZ can also be periodic, namely when periodic boundary conditions (PBCs)
are defined in the simulation and distanceZ’s axis is parallel to a unit cell vector.
In addition, a custom scalar colvar may be periodic depending on its user-defined expression. It will
only be treated as such by the Colvars module if the period is specified using the period keyword, while
wrapAround is optional.
The following keywords can be used within periodic components, or within custom variables (4.6)).
26
• period h Period of the component i
Context: distanceZ, custom colvars
Acceptable values: positive decimal
Default value: 0.0
Description: Setting this number enables the treatment of distanceZ as a periodic component:
by default, distanceZ is not considered periodic. The keyword is supported, but irrelevant within
dihedral or spinAngle, because their period is always 360 degrees.
• wrapAround h Center of the wrapping interval for periodic variables i
Context: distanceZ, dihedral, spinAngle, custom colvars
Acceptable values: decimal
Default value: 0.0
Description: By default, values of the periodic components are centered around zero, ranging from
−P/2 to P/2, where P is the period. Setting this number centers the interval around this value. This
can be useful for convenience of output, or to set the walls for a harmonicWalls in an order that
would not otherwise be allowed.
Internally, all differences between two values of a periodic colvar follow the minimum image conven-
tion: they are calculated based on the two periodic images that are closest to each other.
Note: linear or polynomial combinations of periodic components (see 4.5) may become meaningless
when components cross the periodic boundary. Use such combinations carefully: estimate the range of
possible values of each component in a given simulation, and make use of wrapAround to limit this problem
whenever possible.
27
4.4.1 Calculating total forces
In addition to the restrictions due to the type of value computed (scalar or non-scalar), a final restriction
can arise when calculating total force (outputTotalForce option or application of a abf bias). total forces
are available currently only for the following components: distance, distanceZ, distanceXY, angle,
dihedral, rmsd, eigenvector and gyration.
where each component appears with a unique coefficient ci (1.0 by default) the positive integer exponent ni
(1 by default).
Any set of components can be combined within a colvar, provided that they return the same type of
values (scalar, unit vector, vector, or quaternion). By default, the colvar is the sum of its components. Linear
or polynomial combinations (following equation (10)) can be obtained by setting the following parameters,
which are common to all components:
Example: To define the average of a colvar across different parts of the system, simply define within
the same colvar block a series of components of the same type (applied to different atom groups), and assign
to each component a componentCoeff of 1/N.
28
may be particularly useful. A scalar-valued custom variable may be manually defined as periodic by pro-
viding the keyword period, and the optional keyword wrapAround, with the same meaning as in periodic
components (see 4.3 for details). A vector variable may be defined by specifying the customFunction pa-
rameter several times: each expression defines one scalar element of the vector colvar. This is illustrated in
the example below.
colvar {
name custom
distance {
name x
group1 { atomNumbers 1 }
group2 { atomNumbers 50 }
}
distanceVec {
name r
group1 { atomNumbers 10 11 12 }
group2 { atomNumbers 20 21 22 }
}
}
29
• width h Unit of the variable, or grid spacing i
Context: colvar
Acceptable values: positive decimal
Default value: 1.0
Description: This number defines the effective unit of measurement for the collective variable, and
is used by the biasing methods for the following purposes. Harmonic (6.4), harmonic walls (6.6)
and linear restraints (6.7) use it to set the physical unit of the force constant, which is useful for
multidimensional restraints involving multiple variables with very different units (for examples, Å or
degrees ◦ ) with a single, scaled force constant. The values of the scaled force constant in the units of
each variable are printed at initialization time. Histograms (6.9), ABF (6.1) and metadynamics (6.3)
all use this number as the initial choice for the grid spacing along this variable: for this reason, width
should generally be no larger than the standard deviation of the colvar in an unbiased simulation.
Unless it is required to control the spacing, it is usually simplest to keep the default value of 1, so that
restraint force constants are provided with their full physical unit.
• lowerBoundary h Lower boundary of the colvar i
Context: colvar
Acceptable values: decimal
Description: Defines the lowest end of the interval of “relevant” values for the colvar. This number
can be either a true physical boundary, or a user-defined number. Together with upperBoundary and
width, it is used to define a grid of values along the variable (not available for variables with vector
values, 4.4). This option does not affect dynamics: to confine a colvar within a certain interval, use a
harmonicWalls bias.
• upperBoundary h Upper boundary of the colvar i
Context: colvar
Acceptable values: decimal
Description: Similarly to lowerBoundary, defines the highest possible or allowed value.
• hardLowerBoundary h Whether the lower boundary is the physical lower limit i
Context: colvar
Acceptable values: boolean
Default value: off
Description: This option does not affect simulation results, but enables some internal optimizations.
Depending on its mathematical definition, a colvar may have “natural” boundaries: for example, a
distance colvar has a “natural” lower boundary at 0. Setting this option instructs the Colvars module
that the user-defined lower boundary is “natural”. See Section 4.1 for the physical ranges of values of
each component.
• hardUpperBoundary h Whether the upper boundary is the physical upper limit of the colvar’s
values i
Context: colvar
Acceptable values: boolean
Default value: off
Description: Analogous to hardLowerBoundary.
• expandBoundaries h Allow to expand the two boundaries if needed i
Context: colvar
Acceptable values: boolean
Default value: off
30
Description: If defined, biasing and analysis methods may keep their own copies of lowerBoundary
and upperBoundary, and expand them to accommodate values that do not fit in the initial range.
Currently, this option is used by the metadynamics bias (6.3) to keep all of its hills fully within the
grid. This option cannot be used when the initial boundaries already span the full period of a periodic
colvar.
31
this force is actually applied to the extended degree of freedom rather than the geometric colvar itself.
The physical unit for this force is the unit of energy specified by units divided by the colvar unit.
• extendedFluctuation h Standard deviation between the colvar and the fictitious particle (colvar
unit) i
Context: colvar
Acceptable values: positive decimal
Description: Defines the spring stiffness for the extendedLagrangian mode, by setting the typi-
cal deviation between the colvar and the extended degree of freedom due to thermal fluctuation. The
spring force constant is calculated internally as kB T /σ 2 , where σ is the value of extendedFluctuation.
32
• extendedLangevinDamping h Damping factor for extended Langevin dynamics (ps−1 ) i
Context: colvar
Acceptable values: positive decimal
Default value: 1.0
Description: If this is non-zero, the extended degree of freedom undergoes Langevin dynamics
at temperature extendedTemp. The friction force is minus extendedLangevinDamping times the
velocity. This is useful because the extended dynamics coordinate may heat up in the transient non-
equilibrium regime of ABF. Use moderate damping values, to limit viscous friction (potentially slow-
ing down diffusive sampling) and stochastic noise (increasing the variance of statistical measure-
ments). In doubt, use the default value.
4.10 Backward-compatibility
• subtractAppliedForce h Do not include biasing forces in the total force for this colvar i
Context: colvar
Acceptable values: boolean
Default value: off
Description: If the colvar supports total force calculation (see 4.4.1), all forces applied to this
colvar by biases will be removed from the total force. This keyword allows to recover some of the
“system force” calculation available in the Colvars module before version 2016-08-10. Please note
that removal of all other external forces (including biasing forces applied to a different colvar) is
no longer supported, due to changes in the underlying simulation engines (primarily NAMD). This
option may be useful when continuing a previous simulation where the removal of external/applied
forces is essential. For all new simulations, the use of this option is not recommended.
33
• corrFuncType h Type of the correlation function i
Context: colvar
Acceptable values: velocity, coordinate or coordinate p2
Default value: velocity
Description: With coordinate or velocity, the correlation function Ci, j (t) = Π (ξi (t0 ), ξ j (t0 + t))
is calculated between the variables ξi and ξ j , or their velocities. Π(ξi , ξ j ) is the scalar product
when calculated between scalar or vector values, whereas for quaternions it is the cosine between
the two corresponding rotation axes. With coordinate p2, the second order Legendre polynomial,
(3 cos(θ )2 − 1)/2, is used instead of the cosine.
• corrFuncNormalize h Normalize the time correlation function? i
Context: colvar
Acceptable values: boolean
Default value: on
Description:
If enabled, the value of the correlation function at t = 0 is normalized to 1; otherwise,
it equals to O (ξi , ξ j ) .
• corrFuncLength h Length of the time correlation function i
Context: colvar
Acceptable values: positive integer
Default value: 1000
Description: Length (in number of points) of the time correlation function.
• corrFuncStride h Stride of the time correlation function i
Context: colvar
Acceptable values: positive integer
Default value: 1
Description: Number of steps between two values of the time correlation function.
• corrFuncOffset h Offset of the time correlation function i
Context: colvar
Acceptable values: positive integer
Default value: 0
Description: The starting time (in number of steps) of the time correlation function (default: t = 0).
Note: the value at t = 0 is always used for the normalization.
• corrFuncOutputFile h Output file for the time correlation function i
Context: colvar
Acceptable values: UNIX filename
Default value: output.<name>.corrfunc.dat
Description: The time correlation function is saved in this file.
• runAve h Calculate the running average and standard deviation i
Context: colvar
Acceptable values: boolean
Default value: off
Description: Whether or not the running average and standard deviation should be calculated for
this colvar.
• runAveLength h Length of the running average window i
Context: colvar
34
Acceptable values: positive integer
Default value: 1000
Description: Length (in number of points) of the running average window.
• runAveOutputFile h Output file for the running average and standard deviation i
Context: colvar
Acceptable values: UNIX filename
Default value: output.<name>.runave.traj
Description: The running average and standard deviation are saved in this file.
35
5 Selecting atoms
To define collective variables, atoms are usually selected as groups. Each group is defined using an iden-
tifier that is unique in the context of the specific colvar component (e.g. for a distance component, the two
groups are group1 and group2). The identifier is followed by a brace-delimited block containing selection
keywords and other parameters, including an optional name:
atoms {
# add atoms 1 and 3 to this group (note: the first atom in the system is 1)
atomNumbers {
1 3
}
The resulting selection includes atoms 1 and 3, those between 20 and 50, and those in the index group
called “Water”. The indices of this group are read from the file provided by the global keyword indexFile.
The complete list of selection keywords available in LAMMPS is:
36
Description: This option adds to the group all the atoms whose numbers are in the list. The number
of the first atom in the system is 1: to convert from a VMD selection, use “atomselect get serial”.
Warning on rotating frames of reference and periodic boundary conditions. rotateReference af-
fects coordinates that depend on minimum-image distances in periodic boundary conditions (PBC). After
37
rotation of the coordinates, the periodic cell vectors become irrelevant: the rotated system is effectively
non-periodic. A safe way to handle this is to ensure that the relevant inter-group distance vectors remain
smaller than the half-size of the periodic cell. If this is not desirable, one should avoid the rotating frame of
reference, and apply orientational restraints to the reference group instead, in order to keep the orientation
of the reference group consistent with the orientation of the periodic cell.
Warning on rotating frames of reference and ABF. Note that centerReference and rotateReference
may affect the Jacobian derivative of colvar components in a way that is not taken into account by default.
Be careful when using these options in ABF simulations or when using total force values.
38
• fittingGroup h Use an alternate set of atoms to define the roto-translation i
Context: atom group
Acceptable values: Block fittingGroup { ... }
Default value: This group itself
Description: If either centerReference or rotateReference is defined, this keyword defines an
alternate atom group to calculate the optimal roto-translation. Use this option to define a continuous
rotation if the structure of the group involved changes significantly (a typical symptom would be the
message “Warning: discontinuous rotation!”).
# Example: defining a group "atoms", with its coordinates expressed
# on a roto-translated frame of reference defined by a second group
atoms {
psfSegID PROT
atomNameResidueRange CA 41-48
centerReference yes
rotateReference yes
fittingGroup {
# define the frame by fitting the rest of the protein
psfSegID PROT PROT
atomNameResidueRange CA 1-40
atomNameResidueRange CA 49-100
}
refPositionsFile all.pdb # can be the entire system
}
The following two options have default values appropriate for the vast majority of applications, and are
only provided to support rare, special cases.
39
5.3 Treatment of periodic boundary conditions.
In simulations with periodic boundary conditions, many of the implemented colvar components rely on the
fact that each position within a group of atoms is at the nearest periodic image from the center of geometry
of the group itself. However, due to the internal wrapping of individual atomic positions done by LAMMPS,
this assumption is broken if the group straddles one of the unit cell’s boundaries. For this reason, within the
Colvars module all coordinates are unwrapped by default to avoid discontinuities (see unwrap keyword in
3.1).
The user should determine whether maintaining the default value of unwrap, depending on the specifics
of each system. In general, internal coordinate wrapping by LAMMPS does not affect the calculation of
colvars if each atom group satisfies one or more of the following:
ii) it is used by a colvar component which does not make use of its center of geometry, but only of
pairwise distances (distanceInv, coordNum, hBond, alpha, dihedralPC);
iii) it is used by a colvar component that ignores the ill-defined Cartesian components of its center of
mass (such as the x and y components of a membrane’s center of mass modeled with distanceZ).
• The calculation of variables, components and biases can be distributed over the processor cores of the
node where the Colvars module is executed. Currently, an equal weight is assigned to each colvar,
or to each component of those colvars that include more than one component. The performance of
simulations that use many colvars or components is improved automatically. For simulations that use
a single large colvar, it may be advisable to partition it in multiple components, which will be then
distributed across the available cores. In LAMMPS, this feature is supported automatically when
LAMMPS is compiled with OpenMP support. If printed, the message “SMP parallelism is available.”
indicates the availability of the option. If available, the option is turned on by default, but may be
disabled using the keyword smp if required for debugging.
• As a general rule, the size of atom groups should be kept relatively small (up to a few thousands
of atoms, depending on the size of the entire system in comparison). To gain an estimate of the
computational cost of a large colvar, one can use a test calculation of the same colvar in VMD (hint:
use the time Tcl command to measure the cost of running cv update).
40
6 Biasing and analysis methods
All of the biasing and analysis methods implemented recognize the following options:
In addition, restraint biases (6.4, 6.6, 6.7, ...) and metadynamics biases (6.3) offer the following optional
keywords, which allow the use of thermodynamic integration (TI) to compute potentials of mean force
(PMFs). In adaptive biasing force (ABF) biases (6.1) the same keywords are not recognized because their
functionality is always included.
41
writeTIPMF is on, but can be enabled separately if the bias is applied to more than one variable,
making not possible the direct integration of the PMF at runtime. If any bias applies time-dependent
forces besides the one using this option, an error is raised.
1
A(ξ ) = − ln P(ξ ) + A0 (11)
β
In the TI formalism, the free energy is obtained from its gradient, which is generally calculated in the
form of the average of a force F ξ exerted on ξ , taken over an iso-ξ surface:
∇ξ A(ξ ) = −F ξ ξ (12)
Several formulae that take the form of (12) have been proposed. This implementation relies partly on
the classic formulation [7], and partly on a more versatile scheme originating in a work by Ruiz-Montero
et al. [8], generalized by den Otter [9] and extended to multiple variables by Ciccotti et al. [10]. Consider
a system subject to constraints of the form σk (x) = 0. Let (vi )i∈[1,n] be arbitrarily chosen vector fields
(R3N → R3N ) verifying, for all i, j, and k:
vi · ∇x ξ j = δi j (13)
vi · ∇x σk = 0 (14)
∂A
= hvi · ∇x V − kB T ∇x · vi iξ (15)
∂ ξi
where V is the potential energy function. vi can be interpreted as the direction along which the force
acting on variable ξi is measured, whereas the second term in the average corresponds to the geometric
entropy contribution that appears as a Jacobian correction in the classic formalism [7]. Condition (13) states
that the direction along which the total force on ξi is measured is orthogonal to the gradient of ξ j , which
means that the force measured on ξi does not act on ξ j .
Equation (14) implies that constraint forces are orthogonal to the directions along which the free en-
ergy gradient is measured, so that the measurement is effectively performed on unconstrained degrees of
freedom.
42
In the framework of ABF, Fξ is accumulated in bins of finite size δ ξ , thereby providing an estimate of
the free energy gradient according to equation (12). The biasing force applied along the collective variables
to overcome free energy barriers is calculated as:
where ∇x Ae denotes the current estimate of the free energy gradient at the current point ξ in the collective
variable subspace, and α(Nξ ) is a scaling factor that is ramped from 0 to 1 as the local number of samples Nξ
increases to prevent nonequilibrium effects in the early phase of the simulation, when the gradient estimate
has a large variance. See the fullSamples parameter below for details.
As sampling of the phase space proceeds, the estimate ∇x A e is progressively refined. The biasing force
introduced in the equations of motion guarantees that in the bin centered around ξ , the forces acting along
the selected collective variables average to zero over time. Eventually, as the undelying free energy surface
is canceled by the adaptive bias, evolution of the system along ξ is governed mainly by diffusion. Although
this implementation of ABF can in principle be used in arbitrary dimension, a higher-dimension collective
variable space is likely to result in sampling difficulties. Most commonly, the number of variables is one or
two.
2. Availability of total forces is necessary. The following colvar components can be used in ABF calcu-
lations: distance, distance xy, distance z, angle, dihedral, gyration, rmsd and eigenvector.
Atom groups may not be replaced by dummy atoms, unless they are excluded from the force mea-
surement by specifying oneSiteTotalForce, if available.
3. Mutual orthogonality of colvars. In a multidimensional ABF calculation, equation (13) must be satis-
fied for any two colvars ξi and ξ j . Various cases fulfill this orthogonality condition:
4. Mutual orthogonality of components: when several components are combined into a colvar, it is
assumed that their vectors vi (equation (15)) are mutually orthogonal. The cases described for colvars
in the previous paragraph apply.
5. Orthogonality of colvars and constraints: equation 14 can be satisfied in two simple ways, if either no
constrained atoms are involved in the force measurement (see point 3 above) or pairs of atoms joined
by a constrained bond are part of an atom group which only intervenes through its center (center of
mass or geometric center) in the force measurement. In the latter case, the contributions of the two
43
atoms to the left-hand side of equation 14 cancel out. For example, all atoms of a rigid TIP3P water
molecule can safely be included in an atom group used in a distance component.
• hideJacobian h Remove geometric entropy term from calculated free energy gradient? i
Context: abf
Acceptable values: boolean
Default value: no
Description: In a few special cases, most notably distance-based variables, an alternate definition
of the potential of mean force is traditionally used, which excludes the Jacobian term describing the
effect of geometric entropy on the distribution of the variable. This results, for example, in particle-
particle potentials of mean force being flat at large separations. Setting this parameter to yes causes
the output data to follow that convention, by removing this contribution from the output gradients
while applying internally the corresponding correction to ensure uniform sampling. It is not allowed
for colvars with multiple components.
44
• outputFreq h Frequency (in timesteps) at which ABF data files are refreshed i
Context: abf
Acceptable values: positive integer
Default value: Colvars module restart frequency
Description: The files containing the free energy gradient estimate and sampling histogram (and the
PMF in one-dimensional calculations) are written on disk at the given time interval.
• historyFreq h Frequency (in timesteps) at which ABF history files are accumulated i
Context: abf
Acceptable values: positive integer
Default value: 0
Description: If this number is non-zero, the free energy gradient estimate and sampling histogram
(and the PMF in one-dimensional calculations) are appended to files on disk at the given time interval.
History file names use the same prefix as output files, with “.hist” appended.
45
6.1.3 Output files
The ABF bias produces the following files, all in multicolumn text format:
• output.pmf: only for one-dimensional calculations, integrated free energy profile or PMF.
If several ABF biases are defined concurrently, their name is inserted to produce unique filenames for
output, as in output.abf1.grad. This should not be done routinely and could lead to meaningless results:
only do it if you know what you are doing!
If the colvar space has been partitioned into sections (windows) in which independent ABF simulations
have been run, the resulting data can be merged using the inputPrefix option described above (a run of 0
steps is enough).
• -n: number of M-C steps to be performed; by default, a minimal number of steps is chosen based on
the size of the grid, and the integration runs until a convergence criterion is satisfied (based on the
RMSD between the target gradient and the real PMF gradient)
• -t: temperature for M-C sampling (unrelated to the simulation temperature) [500 K]
• -m: use metadynamics-like biased sampling? (0 = false) [1]
• -h: increment for the history-dependent bias (“hill height”) [0.01 kcal/mol]
• -f: if non-zero, this factor is used to scale the increment stepwise in the second half of the M-C
sampling to refine the free energy estimate [0.5]
Using the default values of all parameters should give reasonable results in most cases.
46
• <gradient file>.histo: histogram of M-C sampling (not usable in a straightforward way if the
history-dependent bias has been applied)
• <gradient file>.est: estimated gradient of the calculated free energy surface (from finite differ-
ences)
• <gradient file>.dev: deviation between the user-provided numerical gradient and the actual gradi-
ent of the calculated free energy surface. The RMS norm of this vector field is used as a convergence
criteria and displayed periodically during the integration.
Note: Typically, the “deviation” vector field does not vanish as the integration converges. This happens
because the numerical estimate of the gradient does not exactly derive from a potential, due to numerical
approximations used to obtain it (finite sampling and discretization on a grid).
47
where z = ξ (q) is the colvar, λ is the extended variable harmonically coupled to z with a force constant k,
and ρ̃(z) is the observed distribution (histogram) of z, affected by the eABF bias.
Parameters for the CZAR estimator are:
Similar to ABF, the CZAR estimator produces two output files in multicolumn text format:
• output.czar.pmf: only for one-dimensional calculations, integrated free energy profile or PMF.
The sampling histogram associated with the CZAR estimator is the z-histogram, which is written in the file
output.zcount.
6.3 Metadynamics
The metadynamics method uses a history-dependent potential [12] that generalizes to any type of colvars
the conformational flooding [13] and local elevation [14] methods, originally formulated to use as colvars
the principal components of a covariance matrix or a set of dihedral angles, respectively. The metadynamics
potential on the colvars ξ = (ξ1 , ξ2 , . . . , ξNcv ) is defined as:
!
t 0 <t Ncv
(ξi (t) − ξi (t 0 ))2
Vmeta (ξ (t)) = ∑ W ∏ exp − 2σξ2i
, (19)
t 0 =δt,2δt,... i=1
where Vmeta is the history-dependent potential acting on the current values of the colvars ξ , and depends
only parametrically on the previous values of the colvars. Vmeta is constructed as a sum of Ncv -dimensional
repulsive Gaussian “hills”, whose height is a chosen energy constant W , and whose centers are the previously
explored configurations (ξ (δt), ξ (2δt), . . .).
During the simulation, the system evolves towards the nearest minimum of the “effective” potential of
mean force Ã(ξ ), which is the sum of the “real” underlying potential of mean force A(ξ ) and the the meta-
dynamics potential, Vmeta (ξ ). Therefore, at any given time the probability of observing the configuration ξ ∗
is proportional to exp −Ã(ξ ∗ )/κB T : this is also the probability that a new Gaussian “hill” is added at that
48
configuration. If the simulation is run for a sufficiently long time, each local minimum is canceled out by
the sum of the Gaussian “hills”. At that stage the “effective” potential of mean force Ã(ξ ) is constant, and
−Vmeta (ξ ) is an accurate estimator of the “real” potential of mean force A(ξ ), save for an additive constant:
Assuming that the set of collective variables includes all relevant degrees of freedom, the predicted
error of the estimate is a simple function of the correlation times of the colvars τξi , and of the user-defined
parameters W , σξi and δt [15]. In typical applications, a good rule of thumb can be to choose the ratio
W /δt much smaller than κB T /τξ , where τξ is the longest among ξ ’s correlation times: σξi then dictates
the resolution of the calculated PMF.
49
the metadynamics potential. The product of this number and the integration time-step defines the
parameter δt in eq. 19. Higher values provide more accurate statistical sampling, at the price of
longer simulation times to complete a PMF calculation.
Note: when Gaussian hills are deposited near the lowerBoundary or upperBoundary and interpolating
grids are used (default behavior), their truncation can give rise to accumulating errors. In these cases, as a
measure of fault-tolerance all Gaussian hills near the boundaries are included in the output state file, and are
recalculated analytically whenever the variable falls outside the grid’s boundaries. (Such measure protects
the accuracy of the calculation, and can only be disabled by hardLowerBoundary or hardUpperBoundary.)
To avoid gradual loss of performance and growth of the state file, either one of the following solutions is
recommended:
• enabling the option expandBoundaries, so that the grid’s boundaries are automatically recalculated
whenever necessary; the resulting .pmf will have its abscissas expanded accordingly;
• applying a harmonicWalls bias with the wall locations well within the interval delimited by lowerBoundary
and upperBoundary.
50
Acceptable values: boolean
Default value: on
Description: This option discretizes all hills for improved performance, accumulating their en-
ergy and their gradients on two separate grids of equal spacing. Grids are defined by the values
of lowerBoundary, upperBoundary and width for each colvar. Currently, this option is imple-
mented for all types of variables except the non-scalar types (distanceDir or orientation). If
expandBoundaries is defined in one of the colvars, grids are automatically expanded along the di-
rection of that colvar.
51
Acceptable values: boolean
Default value: off
Description: If this option is on, multiple (independent) replica of the same system can be run at the
same time, and their hills will be combined to obtain a single PMF [17]. Replicas are identified by
the value of replicaID. Communication is done by files: each replica must be able to read the files
created by the others, whose paths are communicated through the file replicasRegistry. This file,
and the files listed in it, are read every replicaUpdateFrequency steps. Every time the colvars state
file is written (colvarsRestartFrequency), the file:
“output.colvars.name.replicaID.state” is also written, containing the state of the metadynamics
bias for replicaID. In the time steps between colvarsRestartFrequency, new hills are temporarily
written to the file:
“output.colvars.name.replicaID.hills”, which serves as communication buffer. These files are
only required for communication, and may be deleted after a new MD run is started with a different
outputName.
• dumpPartialFreeEnergyFile h Periodically write the contribution to the PMF from this replica i
Context: metadynamics
Acceptable values: boolean
Default value: on
Description: When multipleReplicas is on, the file output.pmf contains the combined PMF from
all replicas, provided that useGrids is on (default). Enabling this option produces an additional file
output.partial.pmf, which can be useful to quickly monitor the contribution of each replica to the
PMF.
52
6.3.6 Compatibility and post-processing
The following options may be useful only for applications that go beyond the calculation of a PMF by
metadynamics:
• name h Name of this metadynamics instance i
Context: metadynamics
Acceptable values: string
Default value: “meta” + rank number
Description: This option sets the name for this metadynamics instance. While it is not advisable to
use more than one metadynamics instance within the same simulation, this allows to distinguish each
instance from the others. If there is more than one metadynamics instance, the name of this bias is
included in the metadynamics output file names, such as e.g. the .pmf file.
• keepHills h Write each individual hill to the state file i
Context: metadynamics
Acceptable values: boolean
Default value: off
Description: When useGrids and this option are on, all hills are saved to the state file in their
analytic form, alongside their grids. This makes it possible to later use exact analytic Gaussians
for rebinGrids. To only keep track of the history of the added hills, writeHillsTrajectory is
preferable.
• writeHillsTrajectory h Write a log of new hills i
Context: metadynamics
Acceptable values: boolean
Default value: off
Description: If this option is on, a logfile is written by the metadynamics bias, with the name
“output.colvars.<name>.hills.traj”, which can be useful to follow the time series of the hills.
When multipleReplicas is on, its name changes to
“output.colvars.<name>.<replicaID>.hills.traj”. This file can be used to quickly visualize
the positions of all added hills, in case newHillFrequency does not coincide with colvarsRestartFrequency.
53
If one-dimensional or homogeneous multi-dimensional restraints are defined, and there are no other uses
for the parameter wξ , the parameter width can be left at its default value of 1.
A harmonic restraint is set up by a harmonic {...} block, which may contain (in addition to the
standard option colvars) the following keywords:
Tip: A complex set of restraints can be applied to a system, by defining several colvars, and applying
one or more harmonic restraints to different groups of colvars. In some cases, dozens of colvars can be
defined, but their value may not be relevant: to limit the size of the colvars trajectory file, it may be wise to
disable outputValue for such “ancillary” variables, and leave it enabled only for “relevant” ones.
54
simulation. By default, the centers are moved over a total of targetNumSteps steps by a linear inter-
polation, in the spirit of Steered MD. If targetNumStages is set to a nonzero value, the change is per-
formed in discrete stages, lasting targetNumSteps steps each. This second mode may be used to sam-
ple successive windows in the context of an Umbrella Sampling simulation. When continuing a simu-
lation run, the centers specified in the configuration file <colvarsConfig> are overridden by those
saved in the restart file <colvarsInput>. To perform Steered MD in an arbitrary space of colvars,
it is sufficient to use this option and enable outputAccumulatedWork and/or outputAppliedForce
within each of the colvars involved.
• targetNumSteps h Number of steps for steering i
Context: harmonic
Acceptable values: positive integer
Description: In single-stage (continuous) transformations, defines the number of MD steps required
to move the restraint centers (or force constant) towards the values specified with targetCenters or
targetForceConstant. After the target values have been reached, the centers (resp. force constant)
are kept fixed. In multi-stage transformations, this sets the number of MD steps per stage.
• outputCenters h Write the current centers to the trajectory file i
Context: harmonic
Acceptable values: boolean
Default value: off
Description: If this option is chosen and colvarsTrajFrequency is not zero, the positions of the
restraint centers will be written to the trajectory file during the simulation. This option allows to
conveniently extract the PMF from the colvars trajectory files in a steered MD calculation.
Note on restarting moving restraint simulations: Information about the current step and stage of a
simulation with moving restraints is stored in the restart file (state file). Thus, such simulations can be run
in several chunks, and restarted directly using the same colvars configuration file. In case of a restart, the
values of parameters such as targetCenters, targetNumSteps, etc. should not be changed manually.
55
6.4.3 Changing force constant
The force constant of the harmonic restraint may also be changed to equilibrate [18].
56
6.5 Computing the work of a changing restraint
If the restraint centers or force constant are changed continuosly (targetNumStages undefined) it is possible
to record the net work performed by the changing restraint:
• outputAccumulatedWork h Write the accumulated work of the changing restraint to the Colvars
trajectory file i
Context: harmonic
Acceptable values: boolean
Default value: off
Description: If targetCenters or targetForceConstant are defined and this option is enabled,
the accumulated work from the beginning of the simulation will be written to the trajectory file
(colvarsTrajFrequency must be non-zero). When the simulation is continued from a state file, the
previously accumulated work is included in the integral. This option allows to conveniently extract
the estimated PMF of a steered MD calculation (when targetCenters is used), or of other simulation
protocols.
ξ −ξupper 2
1
2
k wξ if ξ > ξupper
V (ξ ) = 0 if ξlower ≤ ξ ≥ ξupper (23)
2
1 k ξ −ξlower
if ξ < ξ
2 wξ lower
where ξlower and ξupper are the lower and upper wall thresholds, respectively; (ii) because an interval between
two walls is defined, only scalar variables can be used (but any number of variables can be defined, and the
wall bias is intrinsically multi-dimensional).
Note: this bias replaces the keywords lowerWall, lowerWallConstant, upperWall and upperWallConstant
defined in the colvar context (see 4). These keywords are still supported, but are deprecated for future uses.
The harmonicWalls bias implements the following options:
57
• upperWalls h Position of the lower wall i
Context: colvar
Acceptable values: Space-separated list of decimals
Description: Defines the values ξupper above which a confining restraint on the colvar is applied to
each colvar ξ .
58
• name: see definition of name in sec. 6 (biasing and analysis methods)
59
• name: see definition of name in sec. 6 (biasing and analysis methods)
60
6.9 Multidimensional histograms
The histogram feature is used to record the distribution of a set of collective variables in the form of a
N-dimensional histogram.
As with any other biasing and analysis method, when a histogram is applied to an extended-system
colvar (4.9), it accesses the value of the fictitious coordinate rather than that of the “true” colvar. A joint
histogram of the “true” colvar and the fictitious coordinate may be obtained by specifying the colvar name
twice in a row in the colvars parameter: the first instance will be understood as the “true” colvar, and the
second, as the fictitious coordinate.
A histogram block may define the following parameters:
• outputFreq h Frequency (in timesteps) at which the histogram files are refreshed i
Context: histogram
Acceptable values: positive integer
Default value: colvarsRestartFrequency
Description: The histogram data are written to files at the given time interval. A value of 0 disables
the creation of these files (note: all data to continue a simulation are still included in the state file).
61
Acceptable values: list of space-separated decimals
Default value: all weights equal to 1
Description: When gatherVectorColvars is on, the components of each multi-dimensional colvar
are accumulated with a different weight. For example, if x and y are two distinct cartesian variables
defined on the same group of atoms, the corresponding 2D histogram can be weighted on a per-atom
basis in the definition of histogram.
1
Z
V (ξ1 , . . . , ξM ) = k (h(ξ ) − h0 (ξ ))2 dξ (24)
2
M
(ξ − ξi )2
1
h(ξ ) = √ ∑ exp − 2σ 2 (25)
M 2πσ 2 i=1
When used in combination with a distancePairs multi-dimensional variable, this bias implements the
refinement algorithm against ESR/DEER experiments published by Shen et al [21].
This bias behaves similarly to the histogram bias with the gatherVectorColvars option, with the im-
portant difference that all variables are gathered, resulting in a one-dimensional histogram. Future versions
will include support for multi-dimensional histograms.
The list of options is as follows:
62
• colvars: see definition of colvars in sec. 6 (biasing and analysis methods)
• outputEnergy: see definition of outputEnergy in sec. 6 (biasing and analysis methods)
• lowerBoundary h Lower boundary of the colvar grid i
Context: histogramRestraint
Acceptable values: decimal
Description: Defines the lowest end of the interval where the reference distribution h0 (ξ ) is defined.
Exactly one value must be provided, because only one-dimensional histograms are supported by the
current version.
• upperBoundary: analogous to lowerBoundary
• width h Width of the colvar grid i
Context: histogramRestraint
Acceptable values: positive decimal
Description: Defines the spacing of the grid where the reference distribution h0 (ξ ) is defined.
• gaussianSigma h Standard deviation of the approximating Gaussian i
Context: histogramRestraint
Acceptable values: positive decimal
Default value: 2 × width
Description: Defines the parameter σ in eq. 25.
• forceConstant h Force constant (unit of energy specified by units) i
Context: histogramRestraint
Acceptable values: positive decimal
Default value: 1.0
Description: Defines the parameter k in eq. 24.
• refHistogram h Reference histogram h0 (ξ ) i
Context: histogramRestraint
Acceptable values: space-separated list of M positive decimals
Description: Provides the values of h0 (ξ ) consecutively. The mid-point convention is used, i.e. the
first point that should be included is for ξ = lowerBoundary+width/2. If the integral of h0 (ξ ) is not
normalized to 1, h0 (ξ ) is rescaled automatically before use.
• refHistogramFile h Reference histogram h0 (ξ ) i
Context: histogramRestraint
Acceptable values: UNIX file name
Description: Provides the values of h0 (ξ ) as contents of the corresponding file (mutually exclusive
with refHistogram). The format is that of a text file, with each line containing the space-separated
values of ξ and h0 (ξ ). The same numerical conventions as refHistogram are used.
• writeHistogram h Periodically write the instantaneous histogram h(ξ ) i
Context: metadynamics
Acceptable values: boolean
Default value: off
Description: If on, the histogram h(ξ ) is written every colvarsRestartFrequency steps to a file
with the name output.<name>.hist.dat This is useful to diagnose the convergence of h(ξ ) against
h0 (ξ ).
63
7 Syntax changes from older versions
The following is a list of syntax changes in Colvars since its first release. Many of the older keywords are
still recognized by the current code, thanks to specific compatibility code. This is not a list of new features:
its primary purpose is to make you aware of those improvements that affect the use of old configuration files
with new versions of the code.
Note: if you are using any of the NAMD and VMD tutorials:
https://www.ks.uiuc.edu/Training/Tutorials/
please be aware that several of these tutorials are not actively maintained: for those cases, this list will help
you reconcile any inconsistencies.
64
Index
abf extendedTemp, 31
CZARestimator, 47 extendedTimeConstant, 31
applyBias, 44 hardLowerBoundary, 29
colvars, 43 hardUpperBoundary, 29
fullSamples, 43 lowerBoundary, 29
hideJacobian, 43 lowerWalls, 56
historyFreq, 44 name, 9
inputPrefix, 44 outputAppliedForce, 30
maxForce, 43 outputEnergy, 30
name, 43 outputTotalForce, 30
outputFreq, 44 outputValue, 30
updateBias, 44 outputVelocity, 30
writeCZARwindowFile, 47 runAveLength, 33
alb runAveOutputFile, 34
centers, 59 runAveStride, 34
colvars, 59 runAve, 33
forceRange, 59 subtractAppliedForce, 32
name, 59 upperBoundary, 29
rateMax, 59 upperWalls, 57
updateFrequency, 59 width, 29
angle coordNum
forceNoPBC, 15 cutoff3, 17
group1, 15 cutoff, 17
group2, 15 expDenom, 17
group3, 15 expNumer, 17
oneSiteTotalForce, 15 group1, 17
angle, dipoleAngle, dihedral group2CenterOnly, 17
oneSiteTotalForce, 11 group2, 17
cartesian pairListFrequency, 18
atoms, 15 tolerance, 17
colvar dihedral
corrFuncLength, 33 forceNoPBC, 16
corrFuncNormalize, 33 group1, 15
corrFuncOffset, 33 group2, 16
corrFuncOutputFile, 33 group3, 16
corrFuncStride, 33 group4, 16
corrFuncType, 33 oneSiteTotalForce, 16
corrFuncWithColvar, 32 dipoleAngle
corrFunc, 32 forceNoPBC, 15
customFunctionType, 28 group1, 15
customFunction, 28 group2, 15
expandBoundaries, 29 group3, 15
extendedFluctuation, 31 oneSiteTotalForce, 15
extendedLagrangian, 31 distanceDir
extendedLangevinDamping, 32 forceNoPBC, 13
65
group1, 13 acceptor, 19
group2, 13 cutoff, 19
oneSiteTotalForce, 13 donor, 19
distanceInv expDenom, 19
exponent, 14 expNumer, 19
group1, 14 harmonicWalls
group2, 14 colvars, 56
oneSiteTotalForce, 14 forceConstant, 57
distancePairs lambdaSchedule, 57
forceNoPBC, 14 lowerWallConstant, 57
group1, 14 name, 56
group2, 14 outputAccumulatedWork, 57
distanceVec outputEnergy, 56
forceNoPBC, 13 targetEquilSteps, 57
group1, 13 targetForceConstant, 57
group2, 13 targetForceExponent, 57
oneSiteTotalForce, 13 targetNumStages, 57
distanceXY targetNumSteps, 57
axis, 13 upperWallConstant, 57
forceNoPBC, 13 writeTIPMF, 56
main, 13 writeTISamples, 56
ref2, 13 harmonic
ref, 13 centers, 53
distanceZ colvars, 53
axis, 12 forceConstant, 53
forceNoPBC, 12 lambdaSchedule, 55
main, 12 name, 53
oneSiteTotalForce, 12, 13 outputAccumulatedWork, 56
ref2, 12 outputCenters, 54
ref, 12 outputEnergy, 53
distanceZ, dihedral, spinAngle, custom colvars targetCenters, 53
wrapAround, 26 targetEquilSteps, 55
distanceZ, custom colvars targetForceConstant, 55
period, 26 targetForceExponent, 55
distance targetNumStages, 54
forceNoPBC, 11 targetNumSteps, 54
group1, 11 writeTIPMF, 53
group2, 11 writeTISamples, 53
eigenvector histogramGrid
atoms, 21 lowerBoundaries, 61
differenceVector, 21 upperBoundaries, 61
refPositionsFile, 21 widths, 61
refPositions, 21 histogramRestraint
vectorFile, 21 colvars, 62
vector, 21 forceConstant, 62
gyration gaussianSigma, 62
atoms, 22 lowerBoundary, 62
hBond name, 61
66
outputEnergy, 62 replicasRegistry, 51
refHistogramFile, 62 useGrids, 49
refHistogram, 62 wellTempered, 50
upperBoundary, 62 writeFreeEnergyFile, 49
width, 62 writeHillsTrajectory, 52
histogram writeHistogram, 62
colvars, 60 writeTIPMF, 48
gatherVectorColvars, 60 writeTISamples, 48
name, 60 orientationAngle
outputFileDX, 60 atoms, 23
outputFile, 60 refPositionsFile, 23
outputFreq, 60 refPositions, 23
weights, 60 orientationProj
inertiaZ atoms, 24
atoms, 22 refPositionsFile, 24
axis, 22 refPositions, 24
inertia orientation
atoms, 22 atoms, 23
linear closestToQuaternion, 23
centers, 58 refPositionsFile, 23
colvars, 58 refPositions, 23
forceConstant, 58 polarPhi
lambdaSchedule, 58 atoms, 16
name, 58 rmsd
outputAccumulatedWork, 58 atoms, 19
outputEnergy, 58 refPositionsFile, 20
targetEquilSteps, 58 refPositions, 20
targetForceConstant, 58 selfCoordNum
targetForceExponent, 58 cutoff3, 18
targetNumStages, 58 cutoff, 18
targetNumSteps, 58 expDenom, 18
writeTIPMF, 58 expNumer, 18
writeTISamples, 58 group1, 18
metadynamics pairListFrequency, 18
biasTemperature, 50 tolerance, 18
colvars, 48 spinAngle
dumpPartialFreeEnergyFile, 51 atoms, 24
hillWeight, 48 refPositionsFile, 24
hillWidth, 48 refPositions, 24
keepFreeEnergyFiles, 49 tilt
keepHills, 52 atoms, 25
multipleReplicas, 50 axis, 24, 25
name, 48, 52 refPositionsFile, 25
newHillFrequency, 48 refPositions, 25
outputEnergy, 48
rebinGrids, 50 any component
replicaID, 51 componentCoeff, 27
replicaUpdateFrequency, 51 componentExp, 27
67
name, 25
scalable, 25
atom group
atomNumbersRange, 36
atomNumbers, 35
atomsOfGroup, 36
centerReference, 37
dummyAtom, 36
enableFitGradients, 38
enableForces, 38
fittingGroup, 38
indexGroup, 36
name, 35
refPositionsFile, 37
refPositions, 37
rotateReference, 37
colvar bias
colvars, 40
name, 40
outputEnergy, 40
writeTIPMF, 40
writeTISamples, 40
global
colvarsRestartFrequency, 6
colvarsTrajFrequency, 5
indexFile, 6
smp, 6
68
References
[1] G. Fiorin, M. L. Klein, and J. Hénin. Using collective variables to drive molecular dynamics simula-
tions. Mol. Phys., 111(22-23):3345–3362, 2013. 3, 49
[2] M. Iannuzzi, A. Laio, and M. Parrinello. Efficient exploration of reactive potential energy surfaces
using car-parrinello molecular dynamics. Phys. Rev. Lett., 90(23):238302, 2003. 18, 32
[3] E A Coutsias, C Seok, and K A Dill. Using quaternions to calculate RMSD. J. Comput. Chem.,
25(15):1849–1857, 2004. 20, 24, 38
[4] Eric Darve, David Rodrı́guez-Gómez, and Andrew Pohorille. Adaptive biasing force method for scalar
and vector free energy calculations. J. Chem. Phys., 128(14):144120, 2008. 42
[5] J. Hénin and C. Chipot. Overcoming free energy barriers using unconstrained molecular dynamics
simulations. J. Chem. Phys., 121:2904–2914, 2004. 42
[6] J. Hénin, G. Fiorin, C. Chipot, and M. L. Klein. Exploring multidimensional free energy landscapes
using time-dependent biases on collective variables. J. Chem. Theory Comput., 6(1):35–47, 2010. 42
[7] A. Carter, E, G. Ciccotti, J. T. Hynes, and R. Kapral. Constrained reaction coordinate dynamics for the
simulation of rare events. Chem. Phys. Lett., 156:472–477, 1989. 42
[8] M. J. Ruiz-Montero, D. Frenkel, and J. J. Brey. Efficient schemes to compute diffusive barrier crossing
rates. Mol. Phys., 90:925–941, 1997. 42
[9] W. K. den Otter. Thermodynamic integration of the free energy along a reaction coordinate in cartesian
coordinates. J. Chem. Phys., 112:7283–7292, 2000. 42
[10] Giovanni Ciccotti, Raymond Kapral, and Eric Vanden-Eijnden. Blue moon sampling, vectorial reaction
coordinates, and unbiased constrained dynamics. ChemPhysChem, 6(9):1809–1814, 2005. 42
[11] Adrien Lesage, Tony Lelièvre, Gabriel Stoltz, and Jérôme Hénin. Smoothed biasing forces yield
unbiased free energies with the extended-system adaptive biasing force method. J. Phys. Chem. B,
121(15):3676–3685, 2017. 47
[12] A. Laio and M. Parrinello. Escaping free-energy minima. Proc. Natl. Acad. Sci. USA, 99(20):12562–
12566, 2002. 48
[13] Helmut Grubmüller. Predicting slow structural transitions in macromolecular systems: Conformational
flooding. Phys. Rev. E, 52(3):2893–2906, Sep 1995. 48
[14] T. Huber, A. E. Torda, and W.F. van Gunsteren. Local elevation - A method for improving the
searching properties of molecular-dynamics simulation. Journal of Computer-Aided Molecular De-
sign, 8(6):695–708, DEC 1994. 48
[15] G. Bussi, A. Laio, and M. Parrinello. Equilibrium free energies from nonequilibrium metadynamics.
Phys. Rev. Lett., 96(9):090601, 2006. 49
[16] Alessandro Barducci, Giovanni Bussi, and Michele Parrinello. Well-tempered metadynamics: A
smoothly converging and tunable free-energy method. Phys. Rev. Lett., 100:020603, 2008. 51
69
[17] P. Raiteri, A. Laio, F. L. Gervasio, C. Micheletti, and M. Parrinello. Efficient reconstruction of complex
free energy landscapes by multiple walkers metadynamics. J. Phys. Chem. B, 110(8):3533–9, 2005.
52
[18] Yuqing Deng and Benoı̂t Roux. Computations of standard binding free energies with molecular dy-
namics simulations. J. Phys. Chem. B, 113(8):2234–2246, 2009. 56
[19] Jed W. Pitera and John D. Chodera. On the use of experimental observations to bias simulated ensem-
bles. J. Chem. Theory Comput., 8:3445–3451, 2012. 58
[20] A. D. White and G. A. Voth. Efficient and minimal method to bias molecular simulations with experi-
mental data. J. Chem. Theory Comput., ASAP, 2014. 59
[21] Rong Shen, Wei Han, Giacomo Fiorin, Shahidul M Islam, Klaus Schulten, and Benoı̂t Roux. Structural
refinement of proteins by restrained molecular dynamics simulations with non-interacting molecular
fragments. PLoS Comput. Biol., 11(10):e1004368, 2015. 62
70