$\phantom{\rule{0.17em}{0ex}}$

COLLECTIVE VARIABLES MODULE

Reference manual for VMD

Code version: 2024-03-12

Updated versions of this manual: [GROMACS] [LAMMPS] [NAMD] [Tinker-HP] [VMD]

Alejandro Bernardin, Haochuan Chen, Jeffrey R. Comer, Giacomo Fiorin, Haohao Fu, Jérôme Hénin, Axel Kohlmeyer, Fabrizio Marinelli, Hubert Santuz, Joshua V. Vermaas, Andrew D. White

### 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 differentiable function of atomic Cartesian coordinates, ${\text{}x\text{}}_{i}$, with $i$ between $1$ and $N$, the total number of atoms:

 $\xi \left(t\right)\phantom{\rule{0.28em}{0ex}}=\xi \left(\text{}X\text{}\left(t\right)\right)\phantom{\rule{0.28em}{0ex}}=\xi \left({\text{}x\text{}}_{i}\left(t\right),{\text{}x\text{}}_{j}\left(t\right),{\text{}x\text{}}_{k}\left(t\right),\dots ⁡\right)\phantom{\rule{0.28em}{0ex}},\phantom{\rule{0.28em}{0ex}}\phantom{\rule{0.28em}{0ex}}1\le i,j,k\dots ⁡\le N$ (1)

This manual documents the collective variables module (Colvars), a software that provides an implementation for the functions $\xi \left(\text{}X\text{}\right)$ 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 sampling 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 (post-processing).

Note: although restraints and PMF algorithms are primarily used during simulations, they are also available in VMD to test a new input for a simulation, or to evaluate the relative free energy of a new structure based on data from a previous calculation. Options that only have an effect during a simulation are also included for compatibility purposes.

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, alongside any other publications for specific features being, according to the usage summary printed when running a Colvars-enabled MD simulation or analysis.

Using the Colvars module in VMD Within VMD [2], the Colvars module can be accessed in two ways:

• Using the Colvars Dashboard, an intuitive interface to the Colvars module, to easily define and analyze collective variables, but not biases (section 3).
• Using the full-featured Tcl scripting interface as documented in section 4.2; see in particular the example in section 4.2.5.

### 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 4. Writing the configuration fora collective variable in VMD is made much easier using the Dashboard and its configuration editor (section 3). However, note that the Dashboard does not handle biases: if necessary, they should be managed separately using the scripting interface.

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 5 and 5.3.1), and the other the moving harmonic restraint (7.5). Note that in VMD, no biasing forces are applied, but biases may be useful in the context of an analysis script, e.g. to collect histograms or to compute bias energies.

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 $\alpha$-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 energy unit/length unit${}^{2}$, initially centered around a value of 4 length unit, which will increase to 15 length unit over 500,000 simulation steps.

The atom selection keywords are detailed in section 6.

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 5.3): the first distance (${d}_{1}$) is taken between the center of mass of atoms 1 and 2 and that of atoms 3 to 5, the second (${d}_{2}$) between atom 7 and the center of mass of atoms 8 to 10 (see 6). The difference $d={d}_{1}-{d}_{2}$ is obtained by multiplying the two by a coefficient $C=+1$ or $C=-1$, respectively (see 5.17). The colvar called “$c$" is the coordination number calculated between atoms 1 to 10 and atoms 11 to 20. A harmonic restraint (see 7.5) 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 ${w}_{d}$ and ${w}_{c}$. A third colvar “alpha" is defined as the $\alpha$-helical content of residues 1 to 10 (see 5.8.1). The values of “$c$" and “alpha" are also recorded throughout the simulation as a joint 2-dimensional histogram (see 7.10).

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}

### 3 The Colvars dashboard

The Colvars Dashboard is a graphical interface for interactive visualization and refinement of collective variables aided by molecular structures and trajectories. It is accessible in VMD's Main Menu under “Extensions/Analysis/Colvars Dashboard". Throughout the interface, keyboard shortcuts for common operations are indicated in square brackets. Context menus in the colvar and bias tables can be accessed using either right click or Control-click.

#### 3.1 A mini-tutorial

Here are the steps for a quick first tour of the Dashboard:

1. load an MD trajectory into VMD;
2. open the Dashboard;
3. click “New" to create a new collective variable;
4. in the Editor window, click “Apply" to accept the default template;
5. in the Dashboard window, click “Show atoms" to display the two atom groups involved in this distance coordinate;
6. click “Timeline plot";
7. click anywhere in the timeline plot to navigate in the trajectory.

Alternately, use the Automatic colvars features in the Actions tab.

Now, clicking “Edit" in the Dashboard window (or right-clicking on a colvar in the list view), you can modify the collective variable to reflect interesting geometric properties of the system. The power of the collective variables approach lies in the variety of geometric functions (“components") and their combinations. The editor window provides a number of helpers to make it easy and quick to define the most relevant variables. See section 3.5 for details.

#### 3.2 The Dashboard window

The Dashboard window displays a table listing currently defined variables, and their values for the current frame indicated at the bottom of the window. By default the frame is updated to track VMD's currently displayed frame, but that can be changed by toggling the “Track frame" checkbox, e.g. to animate the trajectory without recomputing expensive variables. Vector-values variables can be expanded to list their scalar elements. This is necessary when individual scalar quantities have to be selected for plotting. Other operations act on variables as a whole and ignore specific selected scalar elements. Right-clicking in the table brings up a context menu with specific actions for the selected variables.

Buttons above the table allow for general operations on the state of the Colvars module. Below the table, the Actions tab allows operations on selected variables, while the Settings tab offers advanced settings for the various visualizations.

If variables are modified, added or deleted by an external script, hit “Refresh" or press F5 to update the displayed variables and values. Starting the Dashboard also enables trajectory animation using the left/right arrow keys within VMD's graphical window. Atomic coordinates can be modified using VMD's “Mouse/Move" functions, and the Colvars module can then be updated by pressing F5 directly from the graphical window.

A dropdown list allows for changing the current unit system if no variables are defined (see section 4.1). When changing units, it is strongly recommended to check the configuration for all colvars to ensure that all quantities are expressed in the desired set of units.

The Colvars Module interacts with one VMD Molecule at a time. At the bottom of the Actions tab, a dropdown lets the user change which VMD molecule is associated with the Colvars module. Internally, changing it means recording the configuration of currently defined colvars, deleting the current instance of the Colvars module, creating a new one linked to the target molecule, and applying the saved configuration. Beware of incompatible colvar definitions, such as atom groups listing atom IDs that exist in one molecule, but not the other. Auto-updating selections (see below) can be used to adapt the colvar definitions to a different system using VMD selection texts.

This saves the current configuration of the colvars Module to a file. This includes comments found in the input, general parameters of the Colvars Module, the collective variables themselves, and collective variable biases. The resulting configuration file can be read by Colvars, either back in VMD, or within a supported MD engine.

#### 3.4 Automatic colvar generators

The Actions tab offers two buttons to generate sets of colvars from the current VMD session:

• "protein auto-colvars" creates variables describing classic quantities used to describe protein structures;
• "colvars from VMD labels" creates variables based on visible labels (Bonds, Angles, Dihedrals) for the current molecule (see Molecule selector in the same tab). Such labels can be created by setting the label mode with the key 2, 3, or 4, and picking atoms with the mouse.

These automatically generated colvars can be used as-is, or customized using the configuration editor (Edit in the context menu, or in the Actions tab).

#### 3.5 The configuration editor

The configuration editor can be started with the “Edit" or “New" buttons. Using the “Edit" button, the configuration of selected variables is loaded, and those variables will be replaced when applying the new configuration.

The editor window offers links to online documentation, as well as helpers to write correct configuration files.

As a first step, the most useful helper is the collection of template files. Some parameters that must be supplied are indicated by the symbol @. Colvar templates can be inserted at the beginning of the configuration, whereas “component" templates define basis functions that belong inside a colvar block. Templates are indented using 4 spaces per level to indicate their position in the nested structure of the configuration: general options, colvars and biases at level 0, bias and colvar parameters like components at level 1, component parameters such as atom groups at level 2, and atom group parameters at level 3.

The next helper buttons allow importing atom selections from VMD, either typing a VMD atom selection text, by copying the selection of an existing graphical representation, or by inserting the list of atoms currently labeled in VMD using the “Pick atom" feature. Atom selections should be inserted within an atom group block, within a component block (such as distance). By default atom selections are preceded with a comment line marking them as auto-updating. This instructs the Dashboard to update the list of atoms whenever the configuration is applied, that is, when it is edited, when the file is loaded by the Dashboard, or when changing the VMD molecule linked to Colvars. This is useful when working across systems with different atom numberings, but topologies that make the relevant atom groups identifiable using VMD selection texts. Special fields (O, B, and user) may be used, as well as atom positions (e.g. z > 0). If the selection text is modified manually, the atom list will be updated when applying the new configuration. This auto-updating behavior can be disabled by removing the special comment line or altering the keywords “auto-updating selection".

Note that atom lists are not auto-updated:

1. when changing frame within the same molecule (animating a trajectory);
2. when the configuration is read by the Colvars module outside of VMD (eg. within an MD engine).

The “Insert labeled..." button combined with the selection box allows for inserting components matching VMD's geometry measurements: Bonds (distances), angles, and dihedrals. Hidden labels are not used for inserting components.

#### 3.6 Plotting and visualizing collective variables

Timeline plots show the selected variables as a function of time. A vertical bar indicates the current frame, which can be changed either using VMD's trajectory animation controls, or directly in the plot window by clicking the mouse inside the graph, or using the keyboard left/right arrows. Shift+arrow steps by 10 frames for faster animation, and Ctrl+arrow steps over 50 frames. The Home/End keys jump to the first and last frames, respectively. The up/down arrows operate a zoom/unzoom along the time axis. Visible data can be fitted vertically using the h key. All data can be fitted horizontally using the h key.

Pairwise scatterplots are useful to identify correlation between variables. To create a pairwise plot, select exactly two scalar variables (or scalar components of vector variables), and click “Pairwise plot". Frames are represented by circles, and lines connect consecutive frames. The blue dot tracks the current frame: clicking a circle jumps to the corresponding frame. Arrow keys and Home/End animate the trajectory as in the timeline plot.

Histogram displays a histogram of the selected scalar variable over the trajectory, using approximately the number of bins specified in the Settings tab (adjusted after selecting a round number for the bin width). The current value of the colvar is indicated by a vertical bar. Clicking anywhere in the plot jumps to the frame with the nearest value of the colvar. Keyboard navigation of the trajectory is similar to the other plots, except that the trajectory is traversed according to colvar values rather than frame numbers. This enables exploration of frames corresponding to a neighborhood of colvar values, even when they are not contiguous in time.

“Show atoms" creates representations of the atoms involved in the definition of the selected colvars. Each atom group is shown in a different color. “Show gradient" is available for scalar variables only. It creates a graphical representation of the atomic gradients of the selected variables, visualizing how the value of the collective variable would vary in response to a change in atomic coordinates. The graphical representation of the gradients is controlled by parameters in the Settings tab. Vectors representing the gradient are rescaled as indicated by the radio buttons Max. vector norm and Scaling factor. Max. vector norm rescales gradients so that the largest vector component of each colvar's gradient is represented by an arrow of the specified length, in Å. Scaling factor rescales gradients by the specified factor, divided by the colvar's width parameter (1 by default, see 5.20). This use of width makes it easier to compare the gradients of collective variables that are not commensurate. The scaling factor has the unit $\ast L∕\left(cv∕width\right)$, where $L$ is the current length unit, and $cv$ represents the natural unit of the collective variable. By default $width$ is unity, but $\left(cv∕width\right)$ may be seen as dimensionless if $width$ is expressed in cv units.

The Dashboard offers visualizations for specific types of variables:

• Variables that represent rotation operations (as unit quaternions), such as those based on an orientation component, can be displayed by right-clicking on them in the colvar table. This creates a representation of the rotation as an arrow representing its axis, and two arms separated by the angle of the rotation, between 0 and 180 degrees.
• For variables that are computed based on volumetric maps, representations of the related maps can be created using the "Show volmap" button, or again through a specific entry in the context menu available via right-click.

Parameters for fine-tuning these visualizations can be set in the Settings tab.

#### 3.7 Monitoring colvar biases in the Dashboard

The main Dashboard window features a "Biases" tab that contains a list of currently defined biases, their current energy, and the colvars that they depend upon. A new harmonic bias acting on a given set of colvars can be created by selecting the colvars and opening the context menu in the colvar table (right click or control-click). A button enables creating a Timeline plot with the energies of currently selected biases, similar to the colvar Timeline plot. Only one plot can be active at a time. Another button creates a visualization of the biasing forces computed by the selected biases, similar to the gradient display for colvars. The graphical representation of forces is controlled by the same parameters as the gradients, shown in the Settings tab. The difference is the scaling factor unit, which is Ångström per Colvars force unit (that is, Ångström times Colvars length unit per Colvars energy unit).

Note that the energy of history-dependent biases such as ABF or metadynamics may not be updated in VMD. However, values of the bias energy from a previous simulation can be displayed if a state file has been loaded with cv load (section 4.2), or in the case of ABF, if inputPrefix was specified.

Hitting the Save button will save the configuration of any bias listed in this tab, except the harmonic wall biases that are created automatically from a colvar for which the lower or upper wall options are specified.

#### 3.8 Plotting custom time-dependent quantities as colvars

Sometimes, important time-dependent quantities are available for a trajectory, but must be computed by an external tool (e.g. energies from a simulation). These can be visualized alongside colvars by taking advantage of the scripted colvar feature.

Such a custom variable can either be computed on the fly (by calling an external tool or a VMD feature) or pre-computed and cached. For example, we can use VMD to compute the protein solvent-accessible surface area (SASA) on the fly:

set sasa_sel [atomselect top "protein and noh"]proc calc_user_colvar { x } {  # Follow current Colvars frame  $::sasa_sel frame [cv frame] return [measure sasa 1$::sasa_sel]}

The Tcl script above should be entered into VMD's text console, or sourced from a file. Then we can define a colvar that will be calculated by the scripted procedure above, by entering the following configuration as a new colvar in the Dashboad Editor Window:

colvar {    name user    scriptedFunction user_colvar    distance {        # The distance component is just a placeholder        group1 {            dummyatom (0, 0, 0)        }        group2 {            dummyatom (0, 0, 0)        }    }}

If the SASA computation is slow, it can be cached to make subsequent interaction responsive. To that effect, we source the following script to pre-compute the SASA for every frame and store it in VMD's User field for atom 0.

##### 4.2.6 Managing collective variables

After one or more collective variables are defined, they can be accessed with the following syntax.

cv colvar "$<$name$>$" $<$method$>$ arg1 arg2 ...


where “$<$name$>$" is the name of the variable.

For example, to recompute the collective variable “xi" after a change in its parameters, the following command can be used:

cv colvar "xi" update

This ordinarily is not needed during a simulation run, where all variables are recomputed at every step (along with biasing forces acting on them). However, when analyzing an existing trajectory, e.g. in VMD, a call to update is generally required.

While in all typical cases all configuration of the variables is done with the “config" or “configfile" methods, a limited set of changes can be enacted at runtime using:

cv colvar "$<$name$>$" modifycvcs arg1 arg2 ...


where each argument is a string passed to the function or functions that are used to compute the variable, and are called colvar components, or CVCs (5.1). For example, a variable “DeltaZ" made of a single “distanceZ" component can be made periodic with a period equal to the unit cell dimension along the $Z$-axis:

##### 4.7.3 XYZ coordinate files

XYZ coordinate files are text files with the extension “.xyz". They are read by the Colvars module using an internal reader, and expect the following format:

 $N$ Comment line ${E}_{1}$ ${x}_{1}$ ${y}_{1}$ ${z}_{1}$ ${E}_{2}$ ${x}_{2}$ ${y}_{2}$ ${z}_{2}$ … ${E}_{N}$ ${x}_{N}$ ${y}_{N}$ ${z}_{N}$

where $N$ is the number of atomic coordinates in the file and ${E}_{i}$ is the chemical element of the $i$-th atom. Because ${E}_{i}$ is not used in Colvars, any string that does not contain tabs or spaces is acceptable.

Note: all XYZ coordinates are assumed to be expressed in Å units.

An XYZ file may contain either one of the following scenarios:

1. The file contains as many coordinates as the atoms that they are being read for: all coordinates will be read from the file following the same order as the atoms appear in the selection generated using the keywords listed in section 6. (Note that the order is guaranteed only if a single type of selection keyword is used one or more times, and not guaranteed when different types of selection keywords are used.)
2. The file contains more coordinates than needed, and it is assumed to contain coordinates for the entire system: only coordinates that match the numeric indices of the selected atoms are read, in order of increasing number.

XYZ-file coordinates are read directly by Colvars and stored internally as double-precision floating point numbers (unlike VMD's reader, which uses single precision).

##### 4.7.4 PDB coordinate files

PDB coordinate files are read by the Colvars module using existing functionality in VMD, and therefore follow the same format. The values of the atomic coordinates and other fields, such as occupancy or temperature factors, are then communicated to Colvars by VMD.

PDB files may be used either as one of the available mechanisms to select atoms (see the atomsFile keyword), or more frequently to read reference coordinates for least-squares fit alignment (see the refPositionsFile keyword).

To select atoms via the atomsFile keyword, the option atomsFile is required, and atoms are selected based on either one of the following cases.

1. All atoms with a non-zero value of the corresponding column are selected.
2. If and only if atomsColValue is provided, only atoms with a value of atomsCol equaling atomsColValue are selected. This can be useful to reuse the same PDB file for generating multiple selections.

To read coordinates via the refPositionsFile keyword, there are four possible scenarios.

1. The file contains as many coordinates as the atoms that they are being read for: all coordinates will be read from the file following the same order as the atoms appear in the selection generated using the keywords listed in section 6. (Note that the order is guaranteed only if a single type of selection keyword is used one or more times, and not guaranteed when different types of selection keywords are used.)
2. The file contains more coordinates than needed, and it is assumed to contain coordinates for the entire system: only coordinates that match the numeric indices of the selected atoms are read, in order of increasing number.
3. If the corresponding refPositionsCol keyword is specified, only positions with a non-zero value of the column refPositionsCol are read. This is particularly useful when all atoms were selected via atomsFile and atomsCol, which can then be the same as refPositionsCol for loading coordinates.
4. This is a special case of the previous point: if both refPositionsCol and refPositionsColValue are specified, only atoms for which the refPositionsCol column as the value refPositionsColValue are read.

Due to the fixed-precision PDB format, it is not recommended to use PDB files to read coordinates when precision is a concern, and the XYZ format (see 4.7.2) is recommended instead.

##### 4.7.5 Grid files: multicolumn text format

Many simulation methods and analysis tools write files that contain functions of the collective variables tabulated on a grid (e.g. potentials of mean force or multidimensional histograms) for the purpose of analyzing results. Such files are produced by ABF (7.2), metadynamics (7.4), multidimensional histograms (7.10), as well as any restraint with optional thermodynamic integration support (7.1).

In some cases, these files may also be read as input of a new simulation. Suitable input files for this purpose are typically generated as output files of previous simulations, or directly by the user in the specific case of ensemble-biased metadynamics (7.4.5). This section explains the “multicolumn" format used by these files. For a multidimensional function $f\left({\xi }_{1}$, ${\xi }_{2}$, …$\right)$ the multicolumn grid format is defined as follows:

 # ${N}_{cv}$ # $min\left({\xi }_{1}\right)$ $width\left({\xi }_{1}\right)$ $npoints\left({\xi }_{1}\right)$ $periodic\left({\xi }_{1}\right)$ # $min\left({\xi }_{2}\right)$ $width\left({\xi }_{2}\right)$ $npoints\left({\xi }_{2}\right)$ $periodic\left({\xi }_{2}\right)$ # … … … … # $min\left({\xi }_{{N}_{cv}}\right)$ $width\left({\xi }_{{N}_{cv}}\right)$ $npoints\left({\xi }_{{N}_{cv}}\right)$ $periodic\left({\xi }_{{N}_{cv}}\right)$ ${\xi }_{1}^{1}$ ${\xi }_{2}^{1}$ … ${\xi }_{{N}_{cv}}^{1}$ f(${\xi }_{1}^{1}$, ${\xi }_{2}^{1}$, …, ${\xi }_{{N}_{cv}}^{1}$) ${\xi }_{1}^{1}$ ${\xi }_{2}^{1}$ … ${\xi }_{{N}_{cv}}^{2}$ f(${\xi }_{1}^{1}$, ${\xi }_{2}^{1}$, …, ${\xi }_{{N}_{cv}}^{2}$) … … … … …

Lines beginning with the character “#" are the header of the file. ${N}_{cv}$ is the number of collective variables sampled by the grid. For each variable ${\xi }_{i}$, $min\left({\xi }_{i}\right)$ is the lowest value sampled by the grid (i.e. the left-most boundary of the grid along ${\xi }_{i}$), $width\left({\xi }_{i}\right)$ is the width of each grid step along ${\xi }_{i}$, $npoints\left({\xi }_{i}\right)$ is the number of points and $periodic\left({\xi }_{i}\right)$ is a flag whose value is 1 or 0 depending on whether the grid is periodic along ${\xi }_{i}$. In most situations:

• $min\left({\xi }_{i}\right)$ is given by the lowerBoundary keyword of the variable ${\xi }_{i}$;
• $width\left({\xi }_{i}\right)$ is given by the width keyword;
• $npoints\left({\xi }_{i}\right)$ is calculated from the two above numbers and the upperBoundary keyword;
• $periodic\left({\xi }_{i}\right)$ is set to 1 if and only if ${\xi }_{i}$ is periodic and the grids' boundaries cover its period.

How the grid's boundaries affect the sequence of points depends on how the contents of the file were computed. In many cases, such as histograms and PMFs computed by metadynamics (7.4.5), the values of ${\xi }_{i}$ in the first few columns correspond to the midpoints of the corresponding bins, i.e. ${\xi }_{1}^{1}=min\left({\xi }_{i}\right)+width\left({\xi }_{i}\right)∕2$. However, there is a slightly different format in PMF files computed by ABF (7.2) or other biases that use thermodynamic integration (7.1). In these cases, it is free-energy gradients that are accumulated on an (npoints)-long grid along each variable $\xi$: after these gradients are integrated, the resulting PMF is discretized on a slightly larger grid with (npoints+1) points along $\xi$ (unless the interval is periodic). Therefore, the grid's outer edges extend by $width\left({\xi }_{i}\right)∕2$ above and below the specified boundaries, so that for instance $min\left({\xi }_{i}\right)$ in the header appears to be shifted back by $width\left({\xi }_{i}\right)∕2$ compared to what would be expected. Please keep this difference in mind when comparing PMFs computed by different methods.

After the header, the rest of the file contains values of the tabulated function $f\left({\xi }_{1}$, ${\xi }_{2}$, …${\xi }_{{N}_{cv}}\right)$, one for each line. The first ${N}_{cv}$ columns contain values of ${\xi }_{1}$, ${\xi }_{2}$, …${\xi }_{{N}_{cv}}$ and the last column contains the value of the function $f$. Points are sorted in ascending order with the fastest-changing values at the right (“C-style" order). Each sweep of the right-most variable ${\xi }_{{N}_{cv}}$ is terminated by an empty line. For two dimensional grid files, this allows quick visualization by programs such as GNUplot.

Example 1: multicolumn text file for a one-dimensional histogram with lowerBoundary = 15, upperBoundary = 48 and width = 0.1.

 # 1 # 15 0.1 330 0 15.05 6.14012e-07 15.15 7.47644e-07 … … 47.85 1.65944e-06 47.95 1.46712e-06

Example 2: multicolumn text file for a two-dimensional histogram of two dihedral angles (periodic interval with 6${}^{\circ }$ bins):

 # 2 # -180.0 6.0 30 1 # -180.0 6.0 30 1 -177.0 -177.0 8.97117e-06 -177.0 -171.0 1.53525e-06 … … … -177.0 177.0 2.442956-06 -171.0 -177.0 2.04702e-05 … … …

##### 4.7.6 Output trajectory files

The Colvars trajectory file (with a suffix .colvars.traj) is a plain text file (scientific notation with 14-digit precision) whose columns represent quantities such as colvar values, applied forces, or individual restraints' energies. Under most scenarios, plotting or analyzing this file is straightforward: for example, the following contains a variable “$A$" and the energy of a restraint “$rA$":

#       step   A                     E_rA           0    1.42467449615693e+01  6.30982865292123e+02         100    1.42282559728026e+01  6.20640585041317e+02…

Occasionally, if the Colvars configuration is changed mid-run certain quantities may be added or removed, changing the column layout. Labels in comment lines can assist in such cases: for example, consider the trajectory above with the addition of a second variable, “$B$", after 10,000 steps:

#       step   A                     E_rA           0    1.42467449615693e+01  6.30982865292123e+02         100    1.42282559728026e+01  6.20640585041317e+02…#       step   A                     B                     E_rA                     10000    1.38136915830229e+01  9.99574098859265e-01  4.11184644791030e+02       10100    1.36437184346326e+01  9.99574091957314e-01  3.37726286543895e+02


Analyzing the above file with standard tools is possible, but laborious: a convenience script is provided for this and related purposes. It may be used either as a command-line tool or as a Python module:

>>> from plot_colvars_traj import Colvars_traj>>> traj = Colvars_traj('test.colvars.traj')>>> print(traj['A'].steps, traj['A'].values)[    0   100  ...  10000 10100] [14.246745 14.228256 ... 13.813692 13.643718]>>> print(traj['B'].steps, traj['B'].values)[10000 10100] [0.999574  0.9995741]

### 5 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$>$  }}

There are multiple ways of defining a variable:

• The simplest and most common way way is using one of the precompiled functions (here called “components"), which are listed in section 5.1. For example, using the keyword rmsd (section 5.6.1) 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 5.1 (see 5.17 for details).
• A user-defined mathematical function of the existing components (see list in section 5.1), or of the atomic coordinates directly (see the cartesian keyword in 5.9.1). The function is defined through the keyword customFunction (see 5.18 for details).
• A user-defined Tcl function of the existing components (see list in section 5.1), or of the atomic coordinates directly (see the cartesian keyword in 5.9.1). The function is provided by a separate Tcl script, and referenced through the keyword scriptedFunction (see 5.19 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:

• nameName of this colvar
Default: “colvar" + numeric id $\left[$ string, context: colvar $\right]$
The name is an unique case-sensitive string which allows the Colvars module to identify this colvar unambiguously; it is also used in the trajectory file to label to the columns corresponding to this colvar.

#### 5.1 Choosing a function

In this context, the function that computes a colvar is called a component. A component's choice and definition consists of including in the variable's configuration a keyword indicating the type of function (e.g. rmsd), followed by a definition block specifying the atoms involved (see 6) and any additional parameters (cutoffs, “reference" values, …). At least one component must be chosen to define a variable: if none of the keywords listed below is found, an error is raised.

The following components implement functions with a scalar value (i.e. a real number):

• distance: distance between two groups;
• distanceZ: projection of a distance vector on an axis;
• distanceXY: projection of a distance vector on a plane;
• distanceInv: mean distance between two groups of atoms (e.g. NOE-based distance);
• angle: angle between three groups;
• dihedral: torsional (dihedral) angle between four groups;
• dipoleAngle: angle between two groups and dipole of a third group;
• dipoleMagnitude: magnitude of the dipole of a group of atoms;
• polarTheta: polar angle of a group in spherical coordinates;
• polarPhi: azimuthal angle of a group in spherical coordinates;
• eulerPhi: Roll angle of rotation from references coordinates;
• eulerTheta: Pitch angle of rotation from references coordinates;
• eulerPsi: Yaw angle of rotation from references coordinates;
• coordNum: coordination number between two groups;
• selfCoordNum: coordination number of atoms within a group;
• hBond: hydrogen bond between two atoms;
• rmsd: root mean square deviation (RMSD) from a set of reference coordinates;
• eigenvector: projection of the atomic coordinates on a vector;
• mapTotal: total value of a volumetric map;
• orientationAngle: angle of the best-fit rotation from a set of reference coordinates;
• orientationProj: cosine of orientationProj;
• 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;
• gyration: radius of gyration of a group of atoms;
• inertia: moment of inertia of a group of atoms;
• inertiaZ: moment of inertia of a group of atoms around a chosen axis;
• alpha: $\alpha$-helix content of a protein segment.
• dihedralPC: projection of protein backbone dihedrals onto a dihedral principal component.

Some components do not return scalar, but vector values:

• distanceVec: distance vector between two groups (length: 3);
• distanceDir: unit vector parallel to distanceVec (length: 3);
• cartesian: vector of atomic Cartesian coordinates (length: $N$ times the number of Cartesian components requested, X, Y or Z);
• distancePairs: vector of mutual distances (length: ${N}_{1}×{N}_{2}$);
• orientation: best-fit rotation, expressed as a unit quaternion (length: 4).

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 5.17), a custom function (see 5.18), or a scripted function (see 5.19).

In the rest of this section, all available component types are listed, along with their physical units and their ranges of values, if limited. Such ranges are often used to define automatically default sampling intervals, for example by setting the parameters 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 5.14.

#### 5.2 Treatment of periodic boundary conditions

In all colvar components described below, the following rules apply concerning periodic boundary conditions (PBCs):

1. Distance vectors between two coordinates ${d}_{i,j}=\left({x}_{1}-{x}_{2}\right)$, are calculated following the minimum-image convention by default, unless forceNoPBC is enabled. (${x}_{1}$ and ${x}_{2}$ may be either individual atomic coordinates, or centers of mass of two groups.)
2. For all other functions of individual atomic coordinates, $f\left({x}_{1},{x}_{2},\dots ⁡\right)$, it is assumed that all atoms that are part of the same group are in the same periodic unit cell (see 6.3).
• forceNoPBCUse absolute rather than minimum-image distances?
Default: no $\left[$ boolean, context: any component $\right]$
If this keyword is set to yes, PBCs will be ignored when calculating this component. This is only useful in a limited number of special cases, e.g. to describe the distance between remote points of a single macromolecule, which cannot be split across periodic cell boundaries, and for which the minimum-image distance might give the wrong result because of a relatively small periodic cell.

#### 5.3 Distances

##### 5.3.1 distance: center-of-mass distance between two groups.

The distance {...} block defines a distance component between the two atom groups, group1 and group2.

• group1First group of atoms
$\left[$ Atom group, context: distance $\right]$
First group of atoms.
• group2 — analogous to group1
• oneSiteTotalForceMeasure total force on group 1 only?
Default: no $\left[$ boolean, context: angle, dipoleAngle, dihedral $\right]$
If this is set to yes, the total force is measured along a vector field (see equation (28) in section 7.2) that only involves atoms of group1. This option is only useful for ABF, or custom biases that compute total forces. See section 7.2 for details.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

The value returned is a positive number (in length unit), 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).

##### 5.3.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.

• mainMain group of atoms
$\left[$ Atom group, context: distanceZ $\right]$
Group of atoms whose position $\text{}r\text{}$ is measured.
• refReference group of atoms
$\left[$ Atom group, context: distanceZ $\right]$
Reference group of atoms. The position of its center of mass is noted ${\text{}r\text{}}_{1}$ below.
• ref2Secondary reference group
Default: none $\left[$ Atom group, context: distanceZ $\right]$
Optional group of reference atoms, whose position ${\text{}r\text{}}_{2}$ can be used to define a dynamic projection axis: $\text{}e\text{}={\left(\parallel {\text{}r\text{}}_{2}-{\text{}r\text{}}_{1}\parallel \right)}^{-1}×\left({\text{}r\text{}}_{2}-{\text{}r\text{}}_{1}\right)$. In this case, the origin is ${\text{}r\text{}}_{m}=1∕2\left({\text{}r\text{}}_{1}+{\text{}r\text{}}_{2}\right)$, and the value of the component is $\text{}e\text{}\cdot \left(\text{}r\text{}-{\text{}r\text{}}_{m}\right)$.
• axisProjection axis
Default: (0.0, 0.0, 1.0) $\left[$ (x, y, z) triplet, context: distanceZ $\right]$
This vector will be normalized to define a projection axis $\text{}e\text{}$ for the distance vector $\text{}r\text{}-{\text{}r\text{}}_{1}$ joining the centers of groups ref and main. The value of the component is then $\text{}e\text{}\cdot \left(\text{}r\text{}-{\text{}r\text{}}_{1}\right)$. The vector should be written as three components separated by commas and enclosed in parentheses.
• oneSiteTotalForce — same definition as oneSiteTotalForce (distance component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

This component returns a number (in length unit) 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 $-{b}_{z}∕2$ and ${b}_{z}∕2$, where ${b}_{z}$ is the box length along $z$ (this behavior is disabled if forceNoPBC is set).

##### 5.3.3 distanceXY: modulus of the projection of a distance vector on a plane.

The distanceXY {...} block defines a distance projected on a plane, and accepts the same keywords as the component distanceZ, i.e. main, ref, either ref2 or axis, and oneSiteTotalForce. It returns the norm of the projection of the distance vector between main and ref onto the plane orthogonal to the axis. The axis is defined using the axis parameter or as the vector joining ref and ref2 (see distanceZ above).

• main — same definition as main (distanceZ component)
• ref — same definition as ref (distanceZ component)
• ref2 — same definition as ref2 (distanceZ component)
• axis — same definition as axis (distanceZ component)
• oneSiteTotalForce — same definition as oneSiteTotalForce (distance component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.3.4 distanceVec: distance vector between two groups.

The distanceVec component computes the 3-dimensional vector joining the centers of mass of group1 and group2. Its values are therefore multi-dimensional and are subject to the restrictions listed in 5.16. Moreover, when computing differences between two different values of a distanceVec variable the minimum-image convention is assumed (unless forceNoPBC is enabled).

• group1 — same definition as group1 (distance component)
• group2 — analogous to group1
• oneSiteTotalForce — same definition as oneSiteTotalForce (distance component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.3.5 distanceDir: distance unit vector between two groups.

The distanceDir {...} block defines a distance unit vector component, which accepts the same keywords as the component distance: group1, group2, and forceNoPBC. It returns a 3-dimensional unit vector $d=\left({d}_{x},{d}_{y},{d}_{z}\right)$, with $|d|=1$.

• group1 — same definition as group1 (distance component)
• group2 — analogous to group1
• oneSiteTotalForce — same definition as oneSiteTotalForce (distance component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.3.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, where each distance is taken to the power $-n$:

 ${d}_{1,2}^{\left[n\right]}\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}{\left(\frac{1}{{N}_{1}{N}_{2}}\sum _{i,j}{d}_{ij}^{-n}\right)}^{-1∕n}$ (2)

where ${d}_{ij}$ is the distance between atoms $i$ and $j$ in groups 1 and 2 respectively, and $n$ is an even integer.

• group1 — same definition as group1 (distance component)
• group2 — analogous to group1
• oneSiteTotalForce — same definition as oneSiteTotalForce (distance component)
• exponentExponent $n$ in equation 2
Default: 6 $\left[$ positive even integer, context: distanceInv $\right]$
Defines the exponent to which the individual distances are elevated before averaging. The default value of 6 is useful for example to applying restraints based on NOE-measured distances.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

This component returns a number ranging from $0$ to the largest possible distance within the chosen boundary conditions.

#### 5.4 Angles

##### 5.4.1 angle: angle between three groups.

The angle {...} block defines an angle, and contains the three blocks group1, group2 and group3, defining the three groups. It returns an angle (in degrees) within the interval $\left[0:180\right]$.

• group1 — same definition as group1 (distance component)
• group2 — analogous to group1
• group3 — analogous to group1
• oneSiteTotalForce — same definition as oneSiteTotalForce (distance component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.4.2 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 $\left[0:180\right]$.

• group1 — same definition as group1 (distance component)
• group2 — analogous to group1
• group3 — analogous to group1
• oneSiteTotalForce — same definition as oneSiteTotalForce (distance component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.4.3 dihedral: torsional angle between four groups.

The dihedral {...} block defines a torsional angle, and contains the blocks group1, group2, group3 and group4, defining the four groups. It returns an angle (in degrees) within the interval $\left[-180:180\right]$. The Colvars module calculates all the distances between two angles taking into account periodicity. For instance, reference values for restraints or range boundaries can be defined by using any real number of choice.

• group1 — same definition as group1 (distance component)
• group2 — analogous to group1
• group3 — analogous to group1
• group4 — analogous to group1
• oneSiteTotalForce — same definition as oneSiteTotalForce (distance component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.4.4 polarTheta: polar angle in spherical coordinates.

The polarTheta {...} block defines the polar angle in spherical coordinates, for the center of mass of a group of atoms described by the block atoms. It returns an angle (in degrees) within the interval $\left[0:180\right]$. To obtain spherical coordinates in a frame of reference tied to another group of atoms, use the fittingGroup (6.2) option within the atoms block. An example is provided in file examples/11_polar_angles.in of the Colvars public repository.

• atomsGroup of atoms defining this function
$\left[$ Atom group, context: polarPhi $\right]$
Defines the group of atoms for the COM of which the angle should be calculated.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.4.5 polarPhi: azimuthal angle in spherical coordinates.

The polarPhi {...} block defines the azimuthal angle in spherical coordinates, for the center of mass of a group of atoms described by the block atoms. It returns an angle (in degrees) within the interval $\left[-180:180\right]$. The Colvars module calculates all the distances between two angles taking into account periodicity. For instance, reference values for restraints or range boundaries can be defined by using any real number of choice. To obtain spherical coordinates in a frame of reference tied to another group of atoms, use the fittingGroup (6.2) option within the atoms block. An example is provided in file examples/11_polar_angles.in of the Colvars public repository.

• atomsGroup of atoms defining this function
$\left[$ Atom group, context: polarPhi $\right]$
Defines the group of atoms for the COM of which the angle should be calculated.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

#### 5.5 Contacts

##### 5.5.1 coordNum: coordination number between two groups.

The coordNum {...} block defines a coordination number (or number of contacts), which calculates the function $\left(1-{\left(d∕{d}_{0}\right)}^{n}\right)∕\left(1-{\left(d∕{d}_{0}\right)}^{m}\right)$, where ${d}_{0}$ is the “cutoff" distance, and $n$ and $m$ are exponents that can control its long range behavior and stiffness [3]. This function is summed over all pairs of atoms in group1 and group2:

 $C\left(group1,group2\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sum _{i\in group1}\sum _{j\in group2}\frac{1-{\left(|{x}_{i}-{x}_{j}|∕{d}_{0}\right)}^{n}}{1-{\left(|{x}_{i}-{x}_{j}|∕{d}_{0}\right)}^{m}}$ (3)

• group1 — same definition as group1 (distance component)
• group2 — analogous to group1
• cutoff“Interaction" distance (length unit)
Default: 4.0 Å $\left[$ positive decimal, context: coordNum $\right]$
This number defines the switching distance to define an interatomic contact: for $d\ll {d}_{0}$, the switching function $\left(1-{\left(d∕{d}_{0}\right)}^{n}\right)∕\left(1-{\left(d∕{d}_{0}\right)}^{m}\right)$ is close to 1, at $d={d}_{0}$ it has a value of $n∕m$ ($1∕2$ with the default $n$ and $m$), and at $d\gg {d}_{0}$ it goes to zero approximately like ${d}^{m-n}$. Hence, for a proper behavior, $m$ must be larger than $n$.
• cutoff3Reference distance vector (length unit)
Default: (4.0, 4.0, 4.0) Å $\left[$ “(x, y, z)" triplet of positive decimals, context: coordNum $\right]$
The three components of this vector define three different cutoffs ${d}_{0}$ for each direction. This option is mutually exclusive with cutoff.
• expNumerNumerator exponent
Default: 6 $\left[$ positive even integer, context: coordNum $\right]$
This number defines the $n$ exponent for the switching function.
• expDenomDenominator exponent
Default: 12 $\left[$ positive even integer, context: coordNum $\right]$
This number defines the $m$ exponent for the switching function.
• group2CenterOnlyUse only group2's center of mass
Default: off $\left[$ boolean, context: coordNum $\right]$
If this option is on, only contacts between each atoms in group1 and the center of mass of group2 are calculated (by default, the sum extends over all pairs of atoms in group1 and group2). If group2 is a dummyAtom, this option is set to yes by default.
• tolerancePairlist control
Default: 0.0 $\left[$ decimal, context: coordNum $\right]$
This controls the pair list 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 pai r list 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 $\left[0,1\right]$.
• pairListFrequencyPairlist regeneration frequency
Default: 100 $\left[$ positive integer, context: coordNum $\right]$
This controls the pairlist feature, dictating how many steps are taken between regenerating pair lists if the tolerance is greater than 0.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

This component returns a dimensionless number, which ranges from approximately 0 (all interatomic distances are much larger than the cutoff) to ${N}_{group1}×{N}_{group2}$ (all distances are less than the cutoff), or ${N}_{group1}$ 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 ${N}_{group1}×{N}_{group2}$. Setting $tolerance>0$ ameliorates this to some degree, although every pair is still checked to regenerate the pair list.

##### 5.5.2 selfCoordNum: coordination number between atoms within a group.

The selfCoordNum {...} block defines a coordination number similarly to the component coordNum, but the function is summed over atom pairs within group1:

 $C\left(group1\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sum _{i\in group1}\sum _{j>i}\frac{1-{\left(|{x}_{i}-{x}_{j}|∕{d}_{0}\right)}^{n}}{1-{\left(|{x}_{i}-{x}_{j}|∕{d}_{0}\right)}^{m}}$ (4)

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.

• group1 — same definition as group1 (coordNum component)
• cutoff — same definition as cutoff (coordNum component)
• cutoff3 — same definition as cutoff3 (coordNum component)
• expNumer — same definition as expNumer (coordNum component)
• expDenom — same definition as expDenom (coordNum component)
• tolerance — same definition as tolerance (coordNum component)
• pairListFrequency — same definition as pairListFrequency (coordNum component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

This component returns a dimensionless number, which ranges from approximately 0 (all interatomic distances much larger than the cutoff) to ${N}_{group1}×\left({N}_{group1}-1\right)∕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 ${N}_{group1}^{2}$.

##### 5.5.3 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 a dimensionless number, with values between 0 (acceptor and donor far outside the cutoff distance) and 1 (acceptor and donor much closer than the cutoff).

• acceptorNumber of the acceptor atom
$\left[$ positive integer, context: hBond $\right]$
Number that uses the same convention as atomNumbers.
• donor — analogous to acceptor
• cutoff — same definition as cutoff (coordNum component)
Note: default value is 3.3 Å.
• expNumer — same definition as expNumer (coordNum component)
Note: default value is 6.
• expDenom — same definition as expDenom (coordNum component)
Note: default value is 8.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

#### 5.6 Collective metrics

##### 5.6.1 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 $\left\{{x}_{1}\left(t\right),{x}_{2}\left(t\right),\dots ⁡{x}_{N}\left(t\right)\right\}$, the colvar component rmsd calculates the optimal rotation ${U}^{\left\{{x}_{i}\left(t\right)\right\}\to \left\{{x}_{i}^{\left(ref\right)}\right\}}$ that best superimposes the coordinates $\left\{{x}_{i}\left(t\right)\right\}$ onto a set of reference coordinates $\left\{{x}_{i}^{\left(ref\right)}\right\}$. Both the current and the reference coordinates are centered on their centers of geometry, ${x}_{cog}\left(t\right)$ and ${x}_{cog}^{\left(ref\right)}$. The root mean square displacement is then defined as:

 $RMSD\left(\left\{{x}_{i}\left(t\right)\right\},\left\{{x}_{i}^{\left(ref\right)}\right\}\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sqrt{\frac{1}{N}\sum _{i=1}^{N}{|U\left({x}_{i}\left(t\right)-{x}_{cog}\left(t\right)\right)-\left({x}_{i}^{\left(ref\right)}-{x}_{cog}^{\left(ref\right)}\right)|}^{2}}$ (5)

The optimal rotation ${U}^{\left\{{x}_{i}\left(t\right)\right\}\to \left\{{x}_{i}^{\left(ref\right)}\right\}}$ is calculated within the formalism developed in reference [4], which guarantees a continuous dependence of ${U}^{\left\{{x}_{i}\left(t\right)\right\}\to \left\{{x}_{i}^{\left(ref\right)}\right\}}$ with respect to $\left\{{x}_{i}\left(t\right)\right\}$.

• atomsGroup of atoms defining this function
$\left[$ Atom group, context: rmsd $\right]$
Defines the group of atoms of which the RMSD should be calculated. Optimal fit options (such as refPositions and rotateToReference) should typically NOT be set within this block. Exceptions to this rule are the special cases discussed in the Advanced usage paragraph below.
• refPositionsReference coordinates
$\left[$ space-separated list of (x, y, z) triplets, context: rmsd $\right]$
This option (mutually exclusive with refPositionsFile) sets the reference coordinates for RMSD calculation, and uses these to compute the roto-translational fit. See the equivalent option refPositions within the atom group definition for details on acceptable formats and other features.
• refPositionsFileReference coordinates file
$\left[$ UNIX filename, context: rmsd $\right]$
This option (mutually exclusive with refPositions) sets the reference coordinates for RMSD calculation, and uses these to compute the roto-translational fit. See the equivalent option refPositionsFile within the atom group definition for details on acceptable file formats and other features.
• refPositionsColPDB column containing atom flags
$\left[$ O, B, X, Y, or Z, context: rmsd $\right]$
If refPositionsFile is a PDB file that contains all the atoms in the topology, this option may be provided to set which PDB field is used to flag the reference coordinates for atoms.
• refPositionsColValueAtom selection flag in the PDB column
$\left[$ positive decimal, context: rmsd $\right]$
If defined, this value identifies in the PDB column refPositionsCol of the file refPositionsFile which atom positions are to be read. Otherwise, all positions with a non-zero value are read.
• atomPermutationAlternate ordering of atoms for RMSD computation
$\left[$ List of atom numbers, context: rmsd $\right]$
If defined, this parameter defines a re-ordering (permutation) of the 1-based atom numbers that can be used to compute the RMSD, typically due to molecular symmetry. This parameter can be specified multiple times, each one defining a new permutation: the returned RMSD value is the minimum over the set of permutations. For example, if the atoms making up the group are 6, 7, 8, 9, and atoms 7, 8, and 9 are invariant by circular permutation (as the hydrogens in a CH3 group), a symmetry-adapted RMSD would be obtained by adding:
atomPermutation 6 8 9 7
atomPermutation 6 9 7 8
This will result in these 2 atom orders being considered in addition to the order used when defining the atom group. Note that this does not affect the least-squares roto-translational fit. Therefore, this feature is mostly useful when using custom fitting parameters within the atom group, such as fittingGroup, or when fitting is disabled altogether. For details, see reference [5].
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

This component returns a positive real number (in length unit).

##### 5.6.2 Advanced usage of the rmsd component.

In the standard usage as described above, the rmsd component calculates a minimum RMSD, that is, current coordinates are optimally fitted onto the same reference coordinates that are used to compute the RMSD value. The fit itself is handled by the atom group object, whose parameters are automatically set by the rmsd component. For very specific applications, however, it may be useful to control the fitting process separately from the definition of the reference coordinates, to evaluate various types of non-minimal RMSD values. This can be achieved by setting the related options (refPositions, etc.) explicitly in the atom group block. This allows for the following non-standard cases:

1. applying the optimal translation, but no rotation (rotateToReference 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 (centerToReference 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 describe 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 (by specifying refPositions or refPositionsFile within the atom group as well as within the rmsd block);
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 (see example in the section on fittingGroup).

##### 5.6.3 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 ${ℝ}^{3n}$, where $n$ is the number of atoms in the group. The computed quantity is the total projection:

 $p\left(\left\{{x}_{i}\left(t\right)\right\},\left\{{x}_{i}^{\left(ref\right)}\right\}\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sum _{i=1}^{n}{v}_{i}\cdot \left(U\left({x}_{i}\left(t\right)-{x}_{cog}\left(t\right)\right)-\left({x}_{i}^{\left(ref\right)}-{x}_{cog}^{\left(ref\right)}\right)\right),$ (6)

where, as in the rmsd component, $U$ is the optimal rotation matrix, ${x}_{cog}\left(t\right)$ and ${x}_{cog}^{\left(ref\right)}$ are the centers of geometry of the current and reference positions respectively, and ${v}_{i}$ are the components of the vector for each atom. Example choices for $\left({v}_{i}\right)$ are an eigenvector of the covariance matrix (essential mode), or a normal mode of the system. It is assumed that ${\sum ⁡}_{i}{v}_{i}=0$: otherwise, the Colvars module centers the ${v}_{i}$ automatically when reading them from the configuration.

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol — same definition as refPositionsCol (rmsd component)
• refPositionsColValue — same definition as refPositionsColValue (rmsd component)
• vectorVector components
$\left[$ space-separated list of (x, y, z) triplets, context: eigenvector $\right]$
This option (mutually exclusive with vectorFile) sets the values of the vector components.
• vectorFilefile containing vector components
$\left[$ UNIX filename, context: eigenvector $\right]$
This option (mutually exclusive with vector) sets the name of an XYZ (4.7.3) or PDB coordinate file containing the vector components. For a PDB file specifically, the components are read from the X, Y and Z fields. Note: The PDB file has limited precision and fixed-point numbers: in some cases, the vector components may not be accurately represented; a XYZ file should be used instead, containing floating-point numbers. Note: Reading data from a coordinate file may entail an automatic unit conversion if the length unit currently used by the MD engine is not Å. If this is not the desired behavior, this can be remedied using the normalizeVector option described below.
• vectorColPDB column used to flag participating atoms
$\left[$ O or B, context: eigenvector $\right]$
Analogous to atomsCol.
• vectorColValueValue used to flag participating atoms in the PDB file
$\left[$ positive decimal, context: eigenvector $\right]$
Analogous to atomsColValue.
• normalizeVectorNormalize the vector components when reading them?
Default: off $\left[$ boolean, context: eigenvector $\right]$
If this flag is activated, the norm of the vector $|v|=\sqrt{{\sum ⁡}_{i}{|{v}_{i}|}^{2}}$ is set equal to 1 by automatically rescaling all the components ${v}_{i}$; alternatively, the value of $|v|$ is printed.
• differenceVectorThe $3n$-dimensional vector is the difference between vector and refPositions
Default: off $\left[$ boolean, context: eigenvector $\right]$
If this option is on, the numbers provided by vector or vectorFile are interpreted as another set of positions, ${x}_{i}^{\prime }$: the vector ${v}_{i}$ is then defined as ${v}_{i}=\left({x}_{i}^{\prime }-{x}_{i}^{\left(ref\right)}\right)$. This allows to conveniently define a colvar $\xi$ as a projection on the linear transformation between two sets of positions, “A" and “B". If this flag is on, the vector is normalized so that $\xi =0$ when the atoms are at the set of positions “A" and $\xi =1$ at the set of positions “B". Setting normalizeVector on overrides this behavior.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.6.4 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 $\left\{{x}_{1}\left(t\right),{x}_{2}\left(t\right),\dots ⁡{x}_{N}\left(t\right)\right\}$ with respect to their center of geometry, ${x}_{cog}\left(t\right)$:

 ${R}_{gyr}\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sqrt{\frac{1}{N}\sum _{i=1}^{N}{|{x}_{i}\left(t\right)-{x}_{cog}\left(t\right)|}^{2}}$ (7)

This component must contain one atoms {...} block to define the atom group, and returns a positive number, expressed in length unit.

• atoms — same definition as atoms (rmsd component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.6.5 inertia: total moment of inertia of a group of atoms.

The block inertia {...} defines the parameters for calculating the total moment of inertia of a group of atomic positions $\left\{{x}_{1}\left(t\right),{x}_{2}\left(t\right),\dots ⁡{x}_{N}\left(t\right)\right\}$ with respect to their center of geometry, ${x}_{cog}\left(t\right)$:

 $I\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sum _{i=1}^{N}{|{x}_{i}\left(t\right)-{x}_{cog}\left(t\right)|}^{2}$ (8)

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 length unit${}^{2}$.

• atoms — same definition as atoms (rmsd component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.6.6 dipoleMagnitude: dipole magnitude of a group of atoms.

The dipoleMagnitude {...} block defines the dipole magnitude of a group of atoms (norm of the dipole moment's vector), being atoms the group where dipole magnitude is calculated. It returns the magnitude in elementary charge $e$ times length unit.

• atoms — same definition as atoms (rmsd component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.6.7 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 $\left\{{x}_{1}\left(t\right),{x}_{2}\left(t\right),\dots ⁡{x}_{N}\left(t\right)\right\}$ with respect to their center of geometry, ${x}_{cog}\left(t\right)$:

 ${I}_{e}\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sum _{i=1}^{N}{\left(\left({x}_{i}\left(t\right)-{x}_{cog}\left(t\right)\right)\cdot e\right)}^{2}$ (9)

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 length unit${}^{2}$.

• atoms — same definition as atoms (rmsd component)
• axisProjection axis
Default: (0.0, 0.0, 1.0) $\left[$ (x, y, z) triplet, context: inertiaZ $\right]$
The three components of this vector define (when normalized) the projection axis $e$.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

#### 5.7 Rotations

The variables discussed in this section quantify the rotations of macromolecules (or other quasi-rigid objects) from a given set of reference coordinates to the current coordinates. Such rotations are computed following the same method used for best-fit RMSDs (see rmsd and fittingGroup). The underlying mathematical formalism is described in reference [4], and the implementation in reference [1].

The first of the functions described is the orientation, which describes the full rotation as a unit quaternion $q=\left({q}_{0},{q}_{1},{q}_{2},{q}_{3}\right)$, i.e. 4 numbers with one constraint (3 degrees of freedom). The quaternion $q$ is one of only two representations that are both complete and accurate, the other being a $3×3$ unit matrix with 3 independent parameters. Although $q$ is used internally in the Colvars module for features such as the rmsd function and the fittingGroup option, its direct use as a collective variable is more difficult, and mostly limited to fixed or moving restraints.

The two functions orientationAngle and orientationProj, with the latter being the cosine of the former, represent the amplitude of the full rotation described by $q$, regardless of the direction of its axis. As one-dimensional scalar variables, both orientationAngle and orientationProj are a much reduced simplification of the full rotation. However, they can be used in a variety of methods including both restraints and PMF computations.

A slightly more complete parametrization is achieved by decomposing the full rotation into the two parameters, tilt and spinAngle. These quantify the amplitudes of two independent sub-rotations away from a certain axis $e$, and around the same axis $e$, respectively. The axis $e$ is chosen by the user, and is by default the Z axis: under that choice, tilt is equivalent to the sine of the Euler “pitch" angle $𝜃$, and spinAngle to the sum of the other two angles, $\left(\varphi +\psi \right)$. This parameterization is mathematically well defined for almost all full rotations, including small ones when the current coordinates are almost completely aligned with the reference ones. However, a mathematical singularity prevents using the spinAngle function near configurations where the value of tilt tilt is -1 (i.e. a -180${}^{\circ }$ rotation around an axis orthogonal to $e$). For these reasons, tilt and spinAngle are useful when the allowed rotations are known to have approximately the same axis, and differ only in the magnitude of the corresponding angle. In this use case, spinAngle measures the angle of the sub-rotation around the chosen axis $e$, whereas tilt measures the dot product between $e$ and the actual axis of the full rotation.

Lastly, the traditional Euler angles are also available as the functions eulerPhi, eulerTheta and eulerPsi. Altogether, these are sufficient to represent all three degrees of freedom of a full rotation. However, they also suffer from the potential “gimbal lock" problem, which emerges whenever $𝜃\simeq ±9{0}^{\circ }$, which includes also the case where the full rotation is small. Under such conditions, the angles $\varphi$ and $\psi$ are both ill-defined and cannot be used as collective variables. For these reasons, it is highly recommended that Euler angles are used only in simulations where their range of applicability is known ahead of time, and excludes configurations where $𝜃\simeq ±9{0}^{\circ }$ altogether.

##### 5.7.1 orientation: orientation from reference coordinates.

The block orientation {...} returns the same optimal rotation used in the rmsd component to superimpose the coordinates $\left\{{x}_{i}\left(t\right)\right\}$ onto a set of reference coordinates $\left\{{x}_{i}^{\left(ref\right)}\right\}$. Such component returns a four dimensional vector $q=\left({q}_{0},{q}_{1},{q}_{2},{q}_{3}\right)$, with ${\sum ⁡}_{i}{q}_{i}^{2}=1$; this quaternion expresses the optimal rotation $\left\{{x}_{i}\left(t\right)\right\}\to \left\{{x}_{i}^{\left(ref\right)}\right\}$ according to the formalism in reference [4]. The quaternion $\left({q}_{0},{q}_{1},{q}_{2},{q}_{3}\right)$ can also be written as $\left(\mathrm{cos}⁡\left(𝜃∕2\right),\phantom{\rule{0.17em}{0ex}}\mathrm{sin}⁡\left(𝜃∕2\right)u\right)$, where $𝜃$ is the angle and $u$ the normalized axis of rotation; for example, a rotation of 90${}^{\circ }$ 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, refPositionsCol and refPositionsColValue, and refPositions.

Note: refPositions and 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.

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol — same definition as refPositionsCol (rmsd component)
• refPositionsColValue — same definition as refPositionsColValue (rmsd component)
• closestToQuaternionReference rotation
Default: (1.0, 0.0, 0.0, 0.0) (“null" rotation) $\left[$ “(q0, q1, q2, q3)" quadruplet, context: orientation $\right]$
Between the two equivalent quaternions $\left({q}_{0},{q}_{1},{q}_{2},{q}_{3}\right)$ and $\left(-{q}_{0},-{q}_{1},-{q}_{2},-{q}_{3}\right)$, 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.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

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 through 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 otherwise.

##### 5.7.2 orientationAngle: angle of rotation from reference coordinates.

The block orientationAngle {...} accepts the same base options as the component orientation: atoms, refPositions, refPositionsFile, refPositionsCol and refPositionsColValue. The returned value is the angle of rotation $𝜃$ between the current and the reference positions. This angle is expressed in degrees within the range [0${}^{\circ }$:180${}^{\circ }$].

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol — same definition as refPositionsCol (rmsd component)
• refPositionsColValue — same definition as refPositionsColValue (rmsd component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.7.3 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, refPositionsCol and refPositionsColValue. 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].

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol — same definition as refPositionsCol (rmsd component)
• refPositionsColValue — same definition as refPositionsColValue (rmsd component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.7.4 spinAngle: angle of rotation around a given axis.

The complete rotation described by orientation can optionally be decomposed into two sub-rotations: one is a “spin" rotation around e, and the other a “tilt" rotation around an axis orthogonal to e. The component spinAngle measures the angle of the “spin" sub-rotation around e.

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol — same definition as refPositionsCol (rmsd component)
• refPositionsColValue — same definition as refPositionsColValue (rmsd component)
• axisSpecial rotation axis
Default: (0.0, 0.0, 1.0) $\left[$ (x, y, z) triplet, context: tilt $\right]$
The three components of this vector define (when normalized) the special rotation axis used to calculate the tilt and spinAngle components.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

The component spinAngle returns an angle (in degrees) within the periodic interval $\left[-180:180\right]$.

Note: the value of spinAngle is a continuous function almost everywhere, with the exception of configurations with the corresponding “tilt" angle equal to 180${}^{\circ }$ (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$.

##### 5.7.5 tilt: cosine of the rotation orthogonal to a given axis.

The component tilt measures the cosine of the angle of the “tilt" sub-rotation, which combined with the “spin" sub-rotation provides the complete rotation of a group of atoms. The cosine of the tilt angle rather than the tilt angle itself is implemented, because the latter is unevenly distributed even for an isotropic system: consider as an analogy the angle $𝜃$ in the spherical coordinate system. The component tilt relies on the same options as spinAngle, including the definition of the axis e. The values of tilt are real numbers in the interval $\left[-1:1\right]$: the value $1$ represents an orientation fully parallel to e (tilt angle = 0${}^{\circ }$), and the value $-1$ represents an anti-parallel orientation.

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol — same definition as refPositionsCol (rmsd component)
• refPositionsColValue — same definition as refPositionsColValue (rmsd component)
• axis — same definition as axis (spinAngle component)
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.7.6 eulerPhi: Roll angle from references coordinates.

Assuming the axes of the original frame are denoted as x, y, z and the axes of the rotated frame as X, Y, Z, the line of nodes, N, can be defined as the intersection of the plane xy and XY. The axis perpendicular to N and z is defined as P. In this case, as illustrated in the figure below, the complete rotation described by orientation can optionally be decomposed into three Euler angles:

• the “roll" angle $\varphi$, i.e. the rotation angle from the x axis to the N axis;
• the “pitch" angle $𝜃$, i.e. the rotation angle from the P axis to the Z axis, and
• the “yaw" angle $\psi$, i.e. the rotation angle from the N axis to the X axis.

Although Euler angles are more straightforward to use than quaternions, they are also potentially subject to the “gimbal lock" problem:
https://en.wikipedia.org/wiki/Gimbal_lock
which arises whenever $𝜃\simeq ±9{0}^{\circ }$, including the common case when the simulated coordinates are near the reference coordinates. Therefore, a safe use of Euler angles as collective variables requires the use of restraints to avoid such singularities, such as done in reference [6] and in the protein-ligand binding NAMD tutorial.

The eulerPhi component accepts exactly the same options as orientation, and measures the rotation angle from the x axis to the N axis. This angle is expressed in degrees within the periodic range $\left[-18{0}^{\circ }:18{0}^{\circ }\right]$.

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol

— same definition as refPositionsCol (rmsd component)

• refPositionsColValue

— same definition as refPositionsColValue (rmsd component)

• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.7.7 eulerTheta: Pitch angle from references coordinates.

This component accepts exactly the same options as orientation, and measures the rotation angle from the P axis to the Z axis. This angle is expressed in degrees within the range $\left[-9{0}^{\circ }:9{0}^{\circ }\right]$.

Warning: When this angle reaches $-9{0}^{\circ }$ or $9{0}^{\circ }$, the definition of orientation by euler angles suffers from the gimbal lock issue. You may need to apply a restraint to keep eulerTheta away from the singularities.

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol

— same definition as refPositionsCol (rmsd component)

• refPositionsColValue

— same definition as refPositionsColValue (rmsd component)

• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.7.8 eulerPsi: Yaw angle from references coordinates.

This component accepts exactly the same options as orientation, and measures the rotation angle from the N axis to the X axis. This angle is expressed in degrees within the periodic range $\left[-18{0}^{\circ }:18{0}^{\circ }\right]$.

• atoms — same definition as atoms (rmsd component)
• refPositions — same definition as refPositions (rmsd component)
• refPositionsFile — same definition as refPositionsFile (rmsd component)
• refPositionsCol

— same definition as refPositionsCol (rmsd component)

• refPositionsColValue

— same definition as refPositionsColValue (rmsd component)

• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

#### 5.8 Protein structure descriptors

##### 5.8.1 alpha: $\alpha$-helix content of a protein segment.

The block alpha {...} defines the parameters to calculate the helical content of a segment of protein residues. The $\alpha$-helical content across the $N+1$ residues ${N}_{0}$ to ${N}_{0}+N$ is calculated by the formula:

$\begin{array}{rcll}\alpha \left({C}_{\alpha }^{\left({N}_{0}\right)},{O}^{\left({N}_{0}\right)},{C}_{\alpha }^{\left({N}_{0}+1\right)},{O}^{\left({N}_{0}+1\right)},\dots ⁡{N}^{\left({N}_{0}+5\right)},{C}_{\alpha }^{\left({N}_{0}+5\right)},{O}^{\left({N}_{0}+5\right)},\dots ⁡{N}^{\left({N}_{0}+N\right)},{C}_{\alpha }^{\left({N}_{0}+N\right)}\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\phantom{\rule{0.28em}{0ex}}\phantom{\rule{0.28em}{0ex}}\phantom{\rule{0.28em}{0ex}}& & & \text{(10)}\text{}\text{}\\ \phantom{\rule{0.28em}{0ex}}\phantom{\rule{0.28em}{0ex}}\phantom{\rule{0.28em}{0ex}}\phantom{\rule{0.28em}{0ex}}\frac{\left(1-{C}_{\text{hb}}\right)}{N-1}\sum _{n={N}_{0}}^{{N}_{0}+N-2}angf\left({C}_{\alpha }^{\left(n\right)},{C}_{\alpha }^{\left(n+1\right)},{C}_{\alpha }^{\left(n+2\right)}\right)\phantom{\rule{0.28em}{0ex}}+\phantom{\rule{0.28em}{0ex}}\frac{{C}_{\text{hb}}}{N-3}\sum _{n={N}_{0}}^{{N}_{0}+N-4}hbf\left({O}^{\left(n\right)},{N}^{\left(n+4\right)}\right),& & & \text{}\\ & & & \text{(11)}\text{}\text{}\end{array}$

where ${C}_{\text{hb}}$ is defined by hBondCoeff, the score function $angf$ for the ${C}_{\alpha }-{C}_{\alpha }-{C}_{\alpha }$ angle is defined as:

 $angf\left({C}_{\alpha }^{\left(n\right)},{C}_{\alpha }^{\left(n+1\right)},{C}_{\alpha }^{\left(n+2\right)}\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\frac{1-{\left(𝜃\left({C}_{\alpha }^{\left(n\right)},{C}_{\alpha }^{\left(n+1\right)},{C}_{\alpha }^{\left(n+2\right)}\right)-{𝜃}_{0}\right)}^{2}∕{\left(\mathrm{\Delta }{𝜃}_{tol}\right)}^{2}}{1-{\left(𝜃\left({C}_{\alpha }^{\left(n\right)},{C}_{\alpha }^{\left(n+1\right)},{C}_{\alpha }^{\left(n+2\right)}\right)-{𝜃}_{0}\right)}^{4}∕{\left(\mathrm{\Delta }{𝜃}_{tol}\right)}^{4}},$ (12)

and the score function $hbf$ for the ${O}^{\left(n\right)}↔{N}^{\left(n+4\right)}$ hydrogen bond is defined through a hBond colvar component on the same atoms.

• residueRangePotential $\alpha$-helical residues
$\left[$ “$<$Initial residue number$>$-$<$Final residue number$>$", context: alpha $\right]$
This option specifies the range of residues on which this component should be defined. The Colvars module looks for the atoms within these residues named “CA", “N" and “O", and raises an error if any of those atoms is not found.
• psfSegIDPSF segment identifier
$\left[$ string (max 4 characters), context: alpha $\right]$
This option sets the PSF segment identifier for the residues specified in residueRange. This option is only required when PSF topologies are used.
• hBondCoeffCoefficient for the hydrogen bond term
Default: 0.5 $\left[$ positive between 0 and 1, context: alpha $\right]$
This number specifies the contribution to the total value from the hydrogen bond terms. 0 disables the hydrogen bond terms, 1 disables the angle terms.
• angleRefReference ${C}_{\alpha }-{C}_{\alpha }-{C}_{\alpha }$ angle
Default: 88${}^{\circ }$ $\left[$ positive decimal, context: alpha $\right]$
This option sets the reference angle used in the score function (12).
• angleTolTolerance in the ${C}_{\alpha }-{C}_{\alpha }-{C}_{\alpha }$ angle
Default: 15${}^{\circ }$ $\left[$ positive decimal, context: alpha $\right]$
This option sets the angle tolerance used in the score function (12).
• hBondCutoffHydrogen bond cutoff
Default: 3.3 Å $\left[$ positive decimal, context: alpha $\right]$
Equivalent to the cutoff option in the hBond component.
• hBondExpNumerHydrogen bond numerator exponent
Default: 6 $\left[$ positive integer, context: alpha $\right]$
Equivalent to the expNumer option in the hBond component.
• hBondExpDenomHydrogen bond denominator exponent
Default: 8 $\left[$ positive integer, context: alpha $\right]$
Equivalent to the expDenom option in the hBond component.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

This component returns positive values, always comprised between 0 (lowest $\alpha$-helical score) and 1 (highest $\alpha$-helical score).

##### 5.8.2 dihedralPC: protein dihedral principal component

The block dihedralPC {...} defines the parameters to calculate the projection of backbone dihedral angles within a protein segment onto a dihedral principal component, following the formalism of dihedral principal component analysis (dPCA) proposed by Mu et al.[7] and documented in detail by Altis et al.[8]. Given a peptide or protein segment of $N$ residues, each with Ramachandran angles ${\varphi }_{i}$ and ${\psi }_{i}$, dPCA rests on a variance/covariance analysis of the $4\left(N-1\right)$ variables $\mathrm{cos}⁡\left({\psi }_{1}\right),\mathrm{sin}⁡\left({\psi }_{1}\right),\mathrm{cos}⁡\left({\varphi }_{2}\right),\mathrm{sin}⁡\left({\varphi }_{2}\right)\cdots \mathrm{cos}⁡\left({\varphi }_{N}\right),\mathrm{sin}⁡\left({\varphi }_{N}\right)$. Note that angles ${\varphi }_{1}$ and ${\psi }_{N}$ have little impact on chain conformation, and are therefore discarded, following the implementation of dPCA in the analysis software Carma.[9]

For a given principal component (eigenvector) of coefficients ${\left({k}_{i}\right)}_{1\le i\le 4\left(N-1\right)}$, the projection of the current backbone conformation is:

 $\xi =\sum _{n=1}^{N-1}{k}_{4n-3}\mathrm{cos}⁡\left({\psi }_{n}\right)+{k}_{4n-2}\mathrm{sin}⁡\left({\psi }_{n}\right)+{k}_{4n-1}\mathrm{cos}⁡\left({\varphi }_{n+1}\right)+{k}_{4n}\mathrm{sin}⁡\left({\varphi }_{n+1}\right)$ (13)

dihedralPC expects the same parameters as the alpha component for defining the relevant residues (residueRange and psfSegID) in addition to the following:

• residueRange — same definition as residueRange (alpha component)
• psfSegID — same definition as psfSegID (alpha component)
• vectorFileFile containing dihedral PCA eigenvector(s)
$\left[$ file name, context: dihedralPC $\right]$
A text file containing the coefficients of dihedral PCA eigenvectors on the cosine and sine coordinates. The vectors should be arranged in columns, as in the files output by Carma.[9]
• vectorNumberFile containing dihedralPCA eigenvector(s)
$\left[$ positive integer, context: dihedralPC $\right]$
Number of the eigenvector to be used for this component.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

#### 5.9 Raw data: building blocks for custom functions

##### 5.9.1 cartesian: vector of atomic Cartesian coordinates.

The cartesian {...} block defines a component returning a flat vector containing the Cartesian coordinates of all participating atoms, in the order $\left({x}_{1},{y}_{1},{z}_{1},\cdots \phantom{\rule{0.17em}{0ex}},{x}_{n},{y}_{n},{z}_{n}\right)$.

• atomsGroup of atoms
$\left[$ Atom group, context: cartesian $\right]$
Defines the atoms whose coordinates make up the value of the component. If rotateToReference, centerToReference, or centerToOrigin are defined, coordinates are evaluated within the moving frame of reference.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.9.2 distancePairs: set of pairwise distances between two groups.

The distancePairs {...} block defines a ${N}_{1}×{N}_{2}$-dimensional variable that includes all mutual distances between the atoms of two groups. This can be useful, for example, to develop a new variable defined over two groups, by using the scriptedFunction feature.

• group1 — same definition as group1 (distance component)
• group2 — analogous to group1
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

This component returns a ${N}_{1}×{N}_{2}$-dimensional vector of numbers, each ranging from $0$ to the largest possible distance within the chosen boundary conditions.

#### 5.10 Geometric path collective variables

The geometric path collective variables define the progress along a path, $s$, and the distance from the path, $z$. These CVs are proposed by Leines and Ensing[10] , which differ from that[11] proposed by Branduardi et al., and utilize a set of geometric algorithms. The path is defined as a series of frames in the atomic Cartesian coordinate space or the CV space. $s$ and $z$ are computed as

 $s=\frac{m}{M}±\frac{1}{2M}\left(\frac{\sqrt{{\left({v}_{1}\cdot {v}_{3}\right)}^{2}-|{v}_{3}{|}^{2}\left(|{v}_{1}{|}^{2}-|{v}_{2}{|}^{2}\right)}-\left({v}_{1}\cdot {v}_{3}\right)}{|{v}_{3}{|}^{2}}-1\right)$ (14)
 $z=\sqrt{{\left({v}_{1}+\frac{1}{2}\left(\frac{\sqrt{{\left({v}_{1}\cdot {v}_{3}\right)}^{2}-|{v}_{3}{|}^{2}\left(|{v}_{1}{|}^{2}-|{v}_{2}{|}^{2}\right)}-\left({v}_{1}\cdot {v}_{3}\right)}{|{v}_{3}{|}^{2}}-1\right){v}_{4}\right)}^{2}}$ (15)

where ${v}_{1}={s}_{m}-z$ is the vector connecting the current position to the closest frame, ${v}_{2}=z-{s}_{m-1}$ is the vector connecting the second closest frame to the current position, ${v}_{3}={s}_{m+1}-{s}_{m}$ is the vector connecting the closest frame to the third closest frame, and ${v}_{4}={s}_{m}-{s}_{m-1}$ is the vector connecting the second closest frame to the closest frame. $m$ and $M$ are the current index of the closest frame and the total number of frames, respectively. If the current position is on the left of the closest reference frame, the $±$ in $s$ turns to the positive sign. Otherwise it turns to the negative sign.

The equations above assume: (i) the frames are equidistant and (ii) the second and the third closest frames are neighbouring to the closest frame. When these assumptions are not satisfied, this set of path CV should be used carefully.

##### 5.10.1 gspath: progress along a path defined in atomic Cartesian coordinate space.

In the gspath {...} and the gzpath {...} block all vectors, namely $z$ and ${s}_{k}$ are defined in atomic Cartesian coordinate space. More specifically, $z=\left[{r}_{1},\cdots \phantom{\rule{0.17em}{0ex}},{r}_{n}\right]$, where ${r}_{i}$ is the $i$-th atom specified in the atoms block. ${s}_{k}=\left[{r}_{k,1},\cdots \phantom{\rule{0.17em}{0ex}},{r}_{k,n}\right]$, where ${r}_{k,i}$ means the $i$-th atom of the $k$-th reference frame.

• atomsGroup of atoms
$\left[$ Atom group, context: gspath and gzpath $\right]$
Defines the atoms whose coordinates make up the value of the component.
• refPositionsColPDB column containing atom flags
$\left[$ O, B, X, Y, or Z, context: gspath and gzpath $\right]$
If refPositionsFileN is a PDB file that contains all the atoms in the topology, this option may be provided to set which PDB field is used to flag the reference coordinates for atoms.
• refPositionsFileNFile containing the reference positions for fitting
$\left[$ UNIX filename, context: gspath and gzpath $\right]$
The path is defined by multiple refPositionsFiles which are similiar to refPositionsFile in the rmsd CV. If your path consists of $10$ nodes, you can list the coordinate file (in PDB or XYZ format) from refPositionsFile1 to refPositionsFile10.
• useSecondClosestFrameDefine ${s}_{m-1}$ as the second closest frame?
Default: on $\left[$ boolean, context: gspath and gzpath $\right]$
The definition assumes the second closest frame is neighbouring to the closest frame. This is not always true especially when the path is crooked. If this option is set to on (default), ${s}_{m-1}$ is defined as the second closest frame. If this option is set to off, ${s}_{m-1}$ is defined as the left or right neighbouring frame of the closest frame.
• useThirdClosestFrameDefine ${s}_{m+1}$ as the third closest frame?
Default: off $\left[$ boolean, context: gspath and gzpath $\right]$
The definition assumes the third closest frame is neighbouring to the closest frame. This is not always true especially when the path is crooked. If this option is set to on, ${s}_{m+1}$ is defined as the third closest frame. If this option is set to off (default), ${s}_{m+1}$ is defined as the left or right neighbouring frame of the closest frame.
• fittingAtomsThe atoms that are used for alignment
$\left[$ Group of atoms, context: gspath and gzpath $\right]$
Before calculating ${v}_{1}$, ${v}_{2}$, ${v}_{3}$ and ${v}_{4}$, the current frame need to be aligned to the corresponding reference frames. This option specifies which atoms are used to do alignment.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.10.2 gzpath: distance from a path defined in atomic Cartesian coordinate space.

• useZsquareCompute ${z}^{2}$ instead of $z$
Default: off $\left[$ boolean, context: gzpath $\right]$
$z$ is not differentiable when it is zero. This implementation workarounds it by setting the derivative of $z$ to zero when $z=0$. Another workaround is set this option to on, which computes ${z}^{2}$ instead of $z$, and then ${z}^{2}$ is differentiable when it is zero.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

The usage of gzpath and gspath is illustrated below:

colvar {  # Progress along the path  name gs  # The path is defined by 5 reference frames (from string-00.pdb to string-04.pdb)  # Use atomic coordinate from atoms 1, 2 and 3 to compute the path  gspath {    atoms {atomnumbers { 1 2 3 }}    refPositionsFile1 string-00.pdb    refPositionsFile2 string-01.pdb    refPositionsFile3 string-02.pdb    refPositionsFile4 string-03.pdb    refPositionsFile5 string-04.pdb  }}colvar {  # Distance from the path  name gz  # The path is defined by 5 reference frames (from string-00.pdb to string-04.pdb)  # Use atomic coordinate from atoms 1, 2 and 3 to compute the path  gzpath {    atoms {atomnumbers { 1 2 3 }}    refPositionsFile1 string-00.pdb    refPositionsFile2 string-01.pdb    refPositionsFile3 string-02.pdb    refPositionsFile4 string-03.pdb    refPositionsFile5 string-04.pdb  }}

##### 5.10.3 linearCombination: Helper CV to define a linear combination of other CVs

This is a helper CV which can be defined as a linear combination of other CVs. It maybe useful when you want to define the gspathCV {...} and the gzpathCV {...} as combinations of other CVs. Total forces (required by ABF) of this CV are not available.

##### 5.10.4 customColvar: Helper CV to define a mathematical expression as CV from other CVs

This is a helper CV which can be defined as a mathematical expression (see 5.18) of other CVs by using customFunction. Currently only the scalar type of customFunction is supported. If customFunction is not provided, this component falls back to linearCombination. It maybe useful when you want to define the gspathCV {...}, the gzpathCV {...} and NeuralNetwork {...} as combinations of other CVs. Total forces (required by ABF) of this CV are not available.

##### 5.10.5 gspathCV: progress along a path defined in CV space.

In the gspathCV {...} and the gzpathCV {...} block all vectors, namely $z$ and ${s}_{k}$ are defined in CV space. More specifically, $z=\left[{\xi }_{1},\cdots \phantom{\rule{0.17em}{0ex}},{\xi }_{n}\right]$, where ${\xi }_{i}$ is the $i$-th CV. ${s}_{k}=\left[{\xi }_{k,1},\cdots \phantom{\rule{0.17em}{0ex}},{\xi }_{k,n}\right]$, where ${\xi }_{k,i}$ means the $i$-th CV of the $k$-th reference frame. It should be note that these two CVs requires the pathFile option, which specifies a path file. Each line in the path file contains a set of space-seperated CV value of the reference frame. The sequence of reference frames matches the sequence of the lines.

• useSecondClosestFrameDefine ${s}_{m-1}$ as the second closest frame?
Default: on $\left[$ boolean, context: gspathCV and gzpathCV $\right]$
The definition assumes the second closest frame is neighbouring to the closest frame. This is not always true especially when the path is crooked. If this option is set to on (default), ${s}_{m-1}$ is defined as the second closest frame. If this option is set to off, ${s}_{m-1}$ is defined as the left or right neighbouring frame of the closest frame.
• useThirdClosestFrameDefine ${s}_{m+1}$ as the third closest frame?
Default: off $\left[$ boolean, context: gspathCV and gzpathCV $\right]$
The definition assumes the third closest frame is neighbouring to the closest frame. This is not always true especially when the path is crooked. If this option is set to on, ${s}_{m+1}$ is defined as the third closest frame. If this option is set to off (default), ${s}_{m+1}$ is defined as the left or right neighbouring frame of the closest frame.
• pathFileThe file name of the path file.
$\left[$ UNIX filename, context: gspathCV and gzpathCV $\right]$
Defines the nodes or images that constitutes the path in CV space. The CVs of an image are listed in a line of pathFile using space-seperated format. Lines from top to button in pathFile corresponds images from initial to last.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.10.6 gzpathCV: distance from a path defined in CV space.

• useZsquareCompute ${z}^{2}$ instead of $z$
Default: off $\left[$ boolean, context: gzpathCV $\right]$
$z$ is not differentiable when it is zero. This implementation workarounds it by setting the derivative of $z$ to zero when $z=0$. Another workaround is set this option to on, which computes ${z}^{2}$ instead of $z$, and then ${z}^{2}$ is differentiable when it is zero.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

The usage of gzpathCV and gspathCV is illustrated below:

colvar {  # Progress along the path  name gs  # Path defined by the CV space of two dihedral angles  gspathCV {    pathFile ./path.txt    dihedral {      name 001      group1 {atomNumbers {5}}      group2 {atomNumbers {7}}      group3 {atomNumbers {9}}      group4 {atomNumbers {15}}    }    dihedral {      name 002      group1 {atomNumbers {7}}      group2 {atomNumbers {9}}      group3 {atomNumbers {15}}      group4 {atomNumbers {17}}    }  }}colvar {  # Distance from the path  name gz  gzpathCV {    pathFile ./path.txt    dihedral {      name 001      group1 {atomNumbers {5}}      group2 {atomNumbers {7}}      group3 {atomNumbers {9}}      group4 {atomNumbers {15}}    }    dihedral {      name 002      group1 {atomNumbers {7}}      group2 {atomNumbers {9}}      group3 {atomNumbers {15}}      group4 {atomNumbers {17}}    }  }}

#### 5.11 Arithmetic path collective variables

The arithmetic path collective variable in CV space uses a similar formula as the one proposed by Branduardi[11] et al., except that it computes $s$ and $z$ in CV space instead of RMSDs in Cartesian space. Moreover, this implementation allows different coefficients for each CV components as described in [12]. Assuming a path is composed of $N$ reference frames and defined in an $M$-dimensional CV space, then the equations of $s$ and $z$ of the path are

 $s=\frac{1}{N-1}\frac{\sum _{i=0}^{N-1}i\mathrm{exp}⁡\left(-\lambda \sum _{j=1}^{M}{c}_{j}^{2}{\left({x}_{j}-{x}_{i,j}\right)}^{2}\right)}{\sum _{i=0}^{N-1}\mathrm{exp}⁡\left(-\lambda \sum _{j=1}^{M}{c}_{j}^{2}{\left({x}_{j}-{x}_{i,j}\right)}^{2}\right)}$ (16)
 $z=-\frac{1}{\lambda }\mathrm{ln}⁡\left(\sum _{i=0}^{N-1}\mathrm{exp}⁡\left(-\lambda \sum _{j=1}^{M}{c}_{j}^{2}{\left({x}_{j}-{x}_{i,j}\right)}^{2}\right)\right)$ (17)

where ${c}_{j}$ is the coefficient(weight) of the $j$-th CV, ${x}_{i,j}$ is the value of $j$-th CV of $i$-th reference frame and ${x}_{j}$ is the value of $j$-th CV of current frame. $\lambda$ is a parameter to smooth the variation of $s$ and $z$. It should be noted that the index $i$ ranges from $0$ to $N-1$, and the definition of $s$ is normalized by $1∕\left(N-1\right)$. Consequently, the scope of $s$ is $\left[0:1\right]$.

##### 5.11.1 aspathCV: progress along a path defined in CV space.

This colvar component computes the $s$ variable.

• weightsCoefficients of the collective variables
Default: {1.0 ...} $\left[$ space-separated numbers in a {...} block, context: aspathCV and azpathCV $\right]$
Define the coefficients. The $j$-th value in the {...} block corresponds the ${c}_{j}$ in the equations.
• lambdaSmoothness of the variation of $s$ and $z$
Default: inverse of the mean square displacements of successive reference frames $\left[$ decimal, context: aspathCV and azpathCV $\right]$
The value of $\lambda$ in the equations.
• pathFileThe file name of the path file.
$\left[$ UNIX filename, context: aspathCV and azpathCV $\right]$
Defines the nodes or images that constitutes the path in CV space. The CVs of an image are listed in a line of pathFile using space-separated format. Lines from top to button in pathFile corresponds images from initial to last.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.11.2 azpathCV: distance from a path defined in CV space.

This colvar component computes the $z$ variable. Options are the same as in 5.11.1.

The usage of azpathCV and aspathCV is illustrated below:

colvar {  # Progress along the path  name as  # Path defined by the CV space of two dihedral angles  aspathCV {    pathFile ./path.txt    weights {1.0 1.0}    lambda 0.005    dihedral {      name 001      group1 {atomNumbers {5}}      group2 {atomNumbers {7}}      group3 {atomNumbers {9}}      group4 {atomNumbers {15}}    }    dihedral {      name 002      group1 {atomNumbers {7}}      group2 {atomNumbers {9}}      group3 {atomNumbers {15}}      group4 {atomNumbers {17}}    }  }}colvar {  # Distance from the path  name az  azpathCV {    pathFile ./path.txt    weights {1.0 1.0}    lambda 0.005    dihedral {      name 001      group1 {atomNumbers {5}}      group2 {atomNumbers {7}}      group3 {atomNumbers {9}}      group4 {atomNumbers {15}}    }    dihedral {      name 002      group1 {atomNumbers {7}}      group2 {atomNumbers {9}}      group3 {atomNumbers {15}}      group4 {atomNumbers {17}}    }  }}

##### 5.11.3 Path collective variables in Cartesian coordinates

The path collective variables defined by Branduardi et al. [11] are based on RMSDs in Cartesian coordinates. Noting ${d}_{i}$ the RMSD between the current set of Cartesian coordinates and those of image number $i$ of the path:

 $s=\frac{1}{N-1}\frac{\sum _{i=1}^{N}\left(i-1\right)\mathrm{exp}⁡\left(-\lambda {d}_{i}^{2}\right)}{\sum _{i=1}^{N}\mathrm{exp}⁡\left(-\lambda {d}_{i}^{2}\right)}$ (18)
 $z=-\frac{1}{\lambda }\mathrm{ln}⁡\left(\sum _{i=1}^{N}\mathrm{exp}⁡\left(-\lambda {d}_{i}^{2}\right)\right)$ (19)

where $\lambda$ is the smoothing parameter.

These coordinates are implemented as Tcl-scripted combinations of rmsd components. The implementation is available as file colvartools/pathCV.tcl, and an example is provided in file examples/10_pathCV.namd of the Colvars public repository. It implements an optimization procedure, whereby the distance to a given image is only calculated if its contribution to the sum is larger than a user-defined tolerance parameter. All distances are calculated every freq timesteps to update the list of nearby images.

##### 5.11.4 aspath: progress along a path defined in atomic Cartesian coordinate space.

This CV computes a special case of Eq. 16, where ${x}_{j}$ is the $j$-th atomic position, ${x}_{i,j}$ is the $j$-th atomic position of the $i$-th reference frame. The subtraction ${x}_{j}-{x}_{i,j}$ is actually calculated as ${x}_{j}-{R}_{i}{x}_{i,j}$, where ${R}_{i}$ is a 3x3 rotation matrix that minimizes the RMSD between the current atomic positions of simulation and the $i$-th reference frame. Bold ${x}_{j}$ is used since an atomic position is a vector.

For NAMD and VMD users, this component can be regarded as an improved C++ implementation of the PCV progress component of the Tcl-scripted version (see 5.11.3).

• atomsGroup of atoms
$\left[$ Atom group, context: aspath and azpath $\right]$
Defines the atoms whose coordinates make up the value of the component.
• refPositionsColPDB column containing atom flags
$\left[$ O, B, X, Y, or Z, context: aspath and azpath $\right]$
If refPositionsFileN is a PDB file that contains all the atoms in the topology, this option may be provided to set which PDB field is used to flag the reference coordinates for atoms.
• refPositionsFileNFile containing the reference positions for fitting
$\left[$ UNIX filename, context: aspath and azpath $\right]$
The path is defined by multiple refPositionsFiles which are similiar to refPositionsFile in the rmsd CV. If your path consists of $10$ nodes, you can list the coordinate file (in PDB or XYZ format) from refPositionsFile1 to refPositionsFile10.
• fittingAtomsThe atoms that are used for alignment
$\left[$ Group of atoms, context: aspath and azpath $\right]$
Before calculating ${v}_{1}$, ${v}_{2}$, ${v}_{3}$ and ${v}_{4}$, the current frame need to be aligned to the corresponding reference frames. This option specifies which atoms are used to do alignment.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.11.5 azpath: distance from a path defined in atomic Cartesian coordinate space.

Similar to aspath, this CV computes a special case of Eq. 17, and shares the same options as aspath.

The usage of azpath and aspath is illustrated below:

colvar {  # Progress along the path  name as  # The path is defined by 5 reference frames (from string-00.pdb to string-04.pdb)  # Use atomic coordinate from atoms 1, 2 and 3 to compute the path  aspath {    atoms {atomnumbers { 1 2 3 }}    refPositionsFile1 string-00.pdb    refPositionsFile2 string-01.pdb    refPositionsFile3 string-02.pdb    refPositionsFile4 string-03.pdb    refPositionsFile5 string-04.pdb  }}colvar {  # Distance from the path  name az  # The path is defined by 5 reference frames (from string-00.pdb to string-04.pdb)  # Use atomic coordinate from atoms 1, 2 and 3 to compute the path  azpath {    atoms {atomnumbers { 1 2 3 }}    refPositionsFile1 string-00.pdb    refPositionsFile2 string-01.pdb    refPositionsFile3 string-02.pdb    refPositionsFile4 string-03.pdb    refPositionsFile5 string-04.pdb  }}

#### 5.12 Dense neural network in CV space (MLCV)

This colvar component computes a non-linear combination of other scalar colvar components, where the transformation is defined by a dense neural network.[13] The network can be optimized using any framework, and its parameters are provided to Colvars in plain text files, as detailed below. An example Python script to export the parameters of a TensorFlow model is provided in colvartools/extract_weights_biases.py in the Colvars source tree.

The output of the $j$-th node of a $k$-th layer that has ${N}_{k}$ nodes is computed by

 ${y}_{k,j}={f}_{k}\left(\sum _{i=1}^{{N}_{k-1}}{w}_{\left(k,j\right),\left(k-1,i\right)}{y}_{k-1,i}+{b}_{k,j}\right),$ (20)

where ${f}_{k}$ is the activation function of the $k$-th layer, ${w}_{\left(k,j\right),\left(k-1,i\right)}$ is the weight of $j$-th node with respect to the $i$-th output of previous layer, and ${b}_{k,j}$ is the bias of $j$-th node of $k$-th layer.

• output_componentThe $j$-th node of the output or the last layer
$\left[$ integer starting from 0, context: NeuralNetwork $\right]$
The value of this option specifies the output node to be used as the value of this CV.
• layer$i$_WeightsFileThe weights from layer $i-1$ to layer $i$
$\left[$ UNIX filename, context: NeuralNetwork $\right]$
The letter $i$ in this option needs to be replaced with the indexing number starting from 1, for example, layer1_WeightsFile and layer2_WeightsFile. The value of this option specifies a plain text file containing the weights from layer $i-1$ to layer $i$. In the file, the number at $k$-th column and $l$-th row represents the weight from node $k$ at layer $i-1$ to node $l$ at layer $i$.
• layer$i$_BiasesFileThe biases from layer $i-1$ to layer $i$
$\left[$ UNIX filename, context: NeuralNetwork $\right]$
The letter $i$ in this option needs to be replaced with the indexing number starting from 1, for example, layer1_BiasesFile and layer2_BiasesFile. The value of this option specifies a plain text file containing the weights of layer $i$. The file should have only one column, where the number at $l$-th row represents the bias of node $l$ from layer $i-1$ to layer $i$.
• layer$i$_activationThe activation function from layer $i-1$ to layer $i$
$\left[$ tanh, sigmoid, linear, relu, lrelu100, elu , context: NeuralNetwork $\right]$
The letter $i$ in this option needs to be replaced with the indexing number starting from 1, for example, layer1_activation and layer2_activation. The activation function from layer $i-1$ to layer $i$. Available choices are tanh, sigmoid, linear (identity), relu, lrelu100 (a leaky rely with coefficients $1{0}^{-2}$ and 1), and elu (with coefficient 1).
• layer$i$_custom_activationAn alternative custom expression as the activation function from layer $i-1$ to layer $i$
$\left[$ string, context: NeuralNetwork $\right]$
Mathematical expression to define the activation function from layer $i-1$ to layer $i$. The input value must be written as x. For example, the ELU activation function can be expressed as select(step(x), alpha*(exp(x)-1), x). For details of the expression syntax, see customFunction. This option is mutually exclusive with colvar|NeuralNetwork|layeri_activation
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

An example of configuration using NeuralNetwork is shown below:

colvar {  # Define a neural network with 2 layers  # The inputs are two torsion angles  # and the first node at the output layer is used as the final CV  name nn_output_1  NeuralNetwork {    output_component 0    layer1_WeightsFile      dense_1_weights.txt    layer1_BiasesFile       dense_1_biases.txt    layer1_activation       tanh    layer2_WeightsFile      dense_2_weights.txt    layer2_BiasesFile       dense_2_biases.txt    layer2_activation       tanh    # The component coefficient is used for normalization    componentCoeff 180.0    dihedral {      name 001      # normalization factor 1.0/180.0      componentCoeff 0.00555555555555555556      group1 {atomNumbers {5}}      group2 {atomNumbers {7}}      group3 {atomNumbers {9}}      group4 {atomNumbers {15}}    }    dihedral {      name 002      # normalization factor 1.0/180.0      componentCoeff 0.00555555555555555556      group1 {atomNumbers {7}}      group2 {atomNumbers {9}}      group3 {atomNumbers {15}}      group4 {atomNumbers {17}}    }  }}

#### 5.13 Volumetric map-based variables

Volumetric maps of the Cartesian coordinates, typically defined as mesh grid along the three Cartesian axes, may be used to define collective variables. Please cite [14] when using this implementation of collective variables based on volumetric maps.

##### 5.13.1 mapTotal: total value of a volumetric map

Given a function of the Cartesian coordinates $\varphi \left(x\right)=\varphi \left(x,y,z\right)$, a mapTotal collective variable component $\Phi \left(X\right)$ is defined as the sum of the values of the function $\varphi \left(x\right)$ evaluated at the coordinates of each atom, ${x}_{i}$:

 $\Phi \left(X\right)=\sum _{i=1}^{N}{w}_{i}\varphi \left({x}_{i}\right)$ (21)

where ${w}_{i}$ are weights assigned to each variable (1 by default). This formulation allows, for example, to “count" the number of atoms within a region of space by using a positive-valued function $\varphi \left(x\right)$, such as for example the number of water molecules in a hydrophobic cavity [14].

Because the volumetric map itself and the atoms affected by it are defined externally to Colvars, this component has a very limited number of keywords.

• mapIDSpecify the numeric index of the volumetric map to use as a colvar
$\left[$ non-negative integer, context: mapTotal $\right]$
The value of this option specifies the numeric index of the volumetric map to use for this collective variable component. The map referred to must be already loaded before using this option.
• atomsGroup of atoms defining this function
$\left[$ Atom group, context: mapTotal $\right]$
If defined, this option allows defining the set of atoms to be aligned onto the volumetric map following the syntax described in section 6. This also allows, for instance, to express the volumetric map in a rotated frame of reference (see 6.2). In VMD, this definition is required, otherwise the mapTotal value is identically zero.
• atomsWeights to assign to each atom
Default: all weights equal to 1 $\left[$ list of space-separated decimals, context: mapTotal $\right]$
If defined, the value of this option assigns weights ${w}_{i}$ to the individual atoms in a mapTotal variable. This option requires defining atoms explicitly, and the number of weights must match the number of atoms.
• forceNoPBCUse absolute rather than minimum-image distances? (see description)
Default: no

##### 5.13.2 Multiple volumetric maps collective variables

To study processes that involve changes in shape of a macromolecular aggregate (for example, deformations of lipid membranes) it is useful to define collective variables based on more than one volumetric map at a time, measuring the relative similarity with each map while still achieving correct thermodynamic sampling of each state.

This is achieved by combining multiple mapTotal components, each based on a differently-shaped volumetric map, into a single collective variable $\xi$. To track transitions between states, the contribution of each map to $\xi$ should be discriminated from the others, for example by assigning to it a different weight. The “Multi-Map" progress variable [14] uses a weight sum of these components, using linearly-increasing weights:

 $\xi \left(X\right)=\sum _{k=1}^{K}k{\Phi }_{k}\left(X\right)=\sum _{k=1}^{K}k\sum _{i=1}^{N}{\varphi }_{k}\left({x}_{i}\right)$ (22)

where $K$ is the number of maps employed and each ${\Phi }_{k}$ is a mapTotal component.

Here is a link to the Multi-Map tutorial page: https://colvars.github.io/multi-map/multi-map.html
An example configuration for illustration purposes is also included below.

Example: transitions between macromolecular shapes using volumetric maps.
A series of map files, each representing a different shape, is loaded into NAMD:

mGridForce yesfor { set k 1 } { $k <=$K } { incr k } {  mGridForcePotFile Shape_$k map_$k.dx   # Density map of the k-th state  mGridForceFile Shape_$k atoms.pdb # PDB file used for atom selection mGridForceCol Shape_$k O   # Use the occupancy column of the PDB file atoms.pdb  mGridForceChargeCol Shape_$k B # Use beta as “charge" (default: electric charge) mGridForceScale Shape_$k 0.0 0.0 0.0  # Do not use GridForces for this map}

The GridForces maps thus loaded are then used to define the Multi-Map collective variable, with coefficients ${\xi }_{k}=k$ [14]:

# Collect the definition of all components into one stringset components "for { set k 1 } { $k <=$K } { incr k } {  set components "${components} mapTotal { mapName Shape_$k    componentCoeff $k }}"# Use this string to define the variablecv config "colvar { name shapes${components}}"

The above example illustrates a use case where a weighted sum (i.e. a linear combination) is used to define a single variable from multiple components. Depending on the problem under study, non-linear functions may be more appropriate. These may be defined a custom functions if implemented (see 5.18), or scripted functions (see 5.19).

#### 5.14 Shared keywords for all components

The following options can be used for any of the above colvar components in order to obtain a polynomial combination or any user-supplied function provided by scriptedFunction.

• nameName of this component
Default: type of component + numeric id $\left[$ string, context: any component $\right]$
The name is an unique case-sensitive string which allows the Colvars module to identify this component. This is useful, for example, when combining multiple components via a scriptedFunction.It also defines the variable name representing the component's value in a customFunction expression.
• scalableAttempt to calculate this component in parallel?
Default: on, if available $\left[$ boolean, context: any component $\right]$
If set to on (default), the Colvars module will attempt to calculate this component in parallel to reduce overhead. Whether this option is available depends on the type of component: currently supported are distance, distanceZ, distanceXY, distanceVec, distanceDir, angle and dihedral. This flag influences computational cost, but does not affect numerical results: therefore, it should only be turned off for debugging or testing purposes.

#### 5.15 Periodic components

Certain components, such as dihedral or dihedral, compute angles that lie in a periodic interval between $-18{0}^{\circ }$ and $18{0}^{\circ }$. When computing pairwise distances between values of those angles (e.g. for the sake of computing restraint potentials, or sampling PMFs), periodicity is taken into account by following the minimum-image convention.

Additionally, several other components, such as distanceZ, support optional periodicity if this is provided in the configuration.

The following keywords can be used within periodic components, or within custom variables (5.18), or wthin scripted variables 5.19).

• periodPeriod of the component
Default: 0.0, unless otherwise stated $\left[$ positive decimal, context: components with optional periodicity $\right]$
Setting this number enables the treatment of 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.
• wrapAroundCenter of the wrapping interval for periodic variables
Default: 0.0 $\left[$ decimal, context: periodic components $\right]$
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.

Note: using linear/polynomial combinations of periodic components (see 5.17), or other custom or scripted function may invalidate the periodicity. 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.

#### 5.16 Non-scalar components

When one of the following components are used, the defined colvar returns a value that is not a scalar number:

• distanceVec: 3-dimensional vector of the distance between two groups;
• distanceDir: 3-dimensional unit vector of the distance between two groups;
• orientation: 4-dimensional unit quaternion representing the best-fit rotation from a set of reference coordinates.

The distance between two 3-dimensional unit vectors is computed as the angle between them. The distance between two quaternions is computed as the angle between the two 4-dimensional unit vectors: because the orientation represented by $q$ is the same as the one represented by $-q$, distances between two quaternions are computed considering the closest of the two symmetric images.

Non-scalar components carry the following restrictions:

• Calculation of total forces (outputTotalForce option) is currently not implemented.
• Each colvar can only contain one non-scalar component.
• Binning on a grid (abf, histogram and metadynamics with useGrids enabled) is currently not implemented for colvars based on such components.

Note: while these restrictions apply to individual colvars based on non-scalar components, no limit is set to the number of scalar colvars. To compute multi-dimensional histograms and PMFs, use sets of scalar colvars of arbitrary size.

##### 5.16.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.

#### 5.17 Linear and polynomial combinations of components

To extend the set of possible definitions of colvars $\xi \left(r\right)$, multiple components ${q}_{i}\left(r\right)$ can be summed with the formula:

 $\xi \left(r\right)=\sum _{i}{c}_{i}{\left[{q}_{i}\left(r\right)\right]}^{{n}_{i}}$ (23)

where each component appears with a unique coefficient ${c}_{i}$ (1.0 by default) the positive integer exponent ${n}_{i}$ (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 (23)) can be obtained by setting the following parameters, which are common to all components:

• componentCoeffCoefficient of this component in the colvar
Default: 1.0 $\left[$ decimal, context: any component $\right]$
Defines the coefficient by which this component is multiplied (after being raised to componentExp) before being added to the sum.
• componentExpExponent of this component in the colvar
Default: 1 $\left[$ integer, context: any component $\right]$
Defines the power at which the value of this component is raised before being added to the sum. When this exponent is different than 1 (non-linear sum), total forces and the Jacobian force are not available, making the colvar unsuitable for ABF calculations (eABF remains possible).

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$.

#### 5.18 Custom functions

Collective variables may be defined by specifying a custom function of multiple components, i.e. an analytical expression that is more general than the linear combinations described in 5.17. Such expression is parsed and calculated by Lepton, the lightweight expression parser written by Peter Eastman (https://simtk.org/projects/lepton) that produces efficient evaluation routines for both the expression and its derivatives. Although Lepton is generally available in most applications and builds where Colvars is included, it is best to check section 10 to confirm.

• customFunctionCompute colvar as a custom function of its components
$\left[$ string, context: colvar $\right]$
Mathematical expression to define the colvar as a closed-form function of its colvar components. See below for the detailed syntax of Lepton expressions. Multiple mentions of this keyword can be used to define a vector variable (as in the example below).
• customFunctionTypeType of value returned by the custom function
Default: scalar $\left[$ string, context: colvar $\right]$
With this flag, the user may specify whether the colvar is a scalar or one of the following vector types: vector3 (a 3D vector), unit_vector3 (a normalized 3D vector), or unit_quaternion (a normalized quaternion), or vector. Note that the scalar and vector cases are not necessary, as they are detected automatically.

The expression may use the collective variable components as variables, referred to by their user-defined name. Scalar elements of vector components may be accessed by appending a 1-based index to their name, as in the example below. When implementing generic functions of Cartesian coordinates rather than functions of existing components, the cartesian component may be particularly useful. A scalar-valued custom variable may be manually defined as periodic by providing the keyword period, and the optional keyword wrapAround, with the same meaning as in periodic components (see 5.15 for details). A vector variable may be defined by specifying the customFunction parameter several times: each expression defines one scalar element of the vector colvar, as in this example:

colvar {  name custom  # A 2-dimensional vector function of a scalar x and a 3-vector r  customFunction cos(x) * (r1 + r2 + r3)  customFunction sqrt(r1 * r2)  distance {    name x    group1 { atomNumbers 1 }    group2 { atomNumbers 50 }  }  distanceVec {    name r    group1 { atomNumbers 10 11 12 }    group2 { atomNumbers  20 21 22 }  }}

Numeric constants may be given in either decimal or exponential form (e.g. 3.12e-2). An expression may be followed by definitions for intermediate values that appear in the expression, separated by semicolons. For example, the expression:
a^2 + a*b + b^2; a = a1 + a2; b = b1 + b2
is exactly equivalent to:
(a1 + a2)^2 + (a1 + a2) * (b1 + b2) + (b1 + b2)^2.
The definition of an intermediate value may itself involve other intermediate values. All uses of a value must appear before that value's definition.

Lepton supports the usual arithmetic operators +, -, *, /, and ^ (power), as well as the following functions:

 sqrt Square root exp Exponential log Natural logarithm erf Error function erfc Complementary error function sin Sine (angle in radians) cos Cosine (angle in radians) sec Secant (angle in radians) csc Cosecant (angle in radians) tan Tangent (angle in radians) cot Cotangent (angle in radians) asin Inverse sine (in radians) acos Inverse cosine (in radians) atan Inverse tangent (in radians) atan2 Two-argument inverse tangent (in radians) sinh Hyperbolic sine cosh Hyperbolic cosine tanh Hyperbolic tangent abs Absolute value floor Floor ceil Ceiling min Minimum of two values max Maximum of two values delta $delta\left(x\right)=1$ if $x=0$, 0 otherwise step $step\left(x\right)=0$ if $x<0$, 1 if $x>=0$ select $select\left(x,y,z\right)=z$ if $x=0$, $y$ otherwise

#### 5.19 Scripted functions

When scripting is supported (default in VMD), a colvar may be defined as a scripted function of its components, rather than a linear or polynomial combination. When implementing generic functions of Cartesian coordinates rather than functions of existing components, the cartesian component may be particularly useful. A scalar-valued scripted variable may be manually defined as periodic by providing the keyword period, and the optional keyword wrapAround, with the same meaning as in periodic components (see 5.15 for details).

An example of elaborate scripted colvar is given in example 10, in the form of path-based collective variables as defined by Branduardi et al[11] (Section 5.11.3).

• scriptedFunctionCompute colvar as a scripted function of its components
$\left[$ string, context: colvar $\right]$
If this option is specified, the colvar will be computed as a scripted function of the values of its components. To that effect, the user should define two Tcl procedures: calc_$<$scriptedFunction$>$ and calc_$<$scriptedFunction$>$_gradient, both accepting as many parameters as the colvar has components. Values of the components will be passed to those procedures in the order defined by their sorted name strings. Note that if all components are of the same type, their default names are sorted in the order in which they are defined, so that names need only be specified for combinations of components of different types. calc_$<$scriptedFunction$>$ should return one value of type $<$scriptedFunctionType$>$, corresponding to the colvar value. calc_$<$scriptedFunction$>$_gradient should return a Tcl list containing the derivatives of the function with respect to each component. If both the function and some of the components are vectors, the gradient is really a Jacobian matrix that should be passed as a linear vector in row-major order, i.e. for a function ${f}_{i}\left({x}_{j}\right)$: ${\nabla ⁡}_{x}{f}_{1}{\nabla ⁡}_{x}{f}_{2}\cdots \phantom{\rule{0.17em}{0ex}}$.
• scriptedFunctionTypeType of value returned by the scripted colvar
Default: scalar $\left[$ string, context: colvar $\right]$
If a colvar is defined as a scripted function, its type is not constrained by the types of its components. With this flag, the user may specify whether the colvar is a scalar or one of the following vector types: vector3 (a 3D vector), unit_vector3 (a normalized 3D vector), or unit_quaternion (a normalized quaternion), or vector (a vector whose size is specified by scriptedFunctionVectorSize). Non-scalar values should be passed as space-separated lists.
• scriptedFunctionVectorSizeDimension of the vector value of a scripted colvar
$\left[$ positive integer, context: colvar $\right]$
This parameter is only valid when scriptedFunctionType is set to vector. It defines the vector length of the colvar value returned by the function.

#### 5.20 Defining grid parameters for a colvar

Many algorithms require the definition of two boundaries and a bin width for each colvar, which are necessary to compute discrete “states" for a collective variable's otherwise continuous values. The following keywords define these parameters for a specific variable, and will be used by all bias that refer to that variable unless otherwise specified.

• lowerBoundaryLower boundary of the colvar
Default: natural boundary of the function $\left[$ decimal, context: colvar $\right]$
Defines the lowest end of the interval of “relevant" values for the variable. This number can be, for example, a true physical boundary imposed by the choice of function (e.g. the distance function is always larger than zero): if this is the case, and only one function is used to define the variable, the default value of this number is set to the lowest end of the range of values of that function, if available (see Section 5.1). Alternatively, this value may be provided by the user, to represent for example the left-most point of a PMF calculation along this variable. In the latter case, it is the user's responsibility to either (a) ensure the variable does not go significantly beyond the boundary (for example by adding a harmonicWalls restraint, 7.7), or (b) instruct the code that this is a true physical boundary by setting hardLowerBoundary.
• upperBoundaryUpper boundary of the colvar
Default: natural boundary of the function $\left[$ decimal, context: colvar $\right]$
Similarly to lowerBoundary, defines the highest of the “relevant" values of the variable.
• widthgrid spacing, or unit of the variable
Default: 1.0 $\left[$ positive decimal, context: colvar $\right]$
This number defines the width of a discrete “state" for a collective variable, and is used by the many biasing methods to achieve different purposes. Histograms (7.10), ABF (7.2) and metadynamics (7.4) all use this number as the initial choice for the grid spacing along this variable. As a typical rule of thumb, width should be no larger than the standard deviation of the colvar in an unbiased simulation (to characterize a local free-energy minimum with at least two points).

Further, many restraints such as harmonic potentials (7.5), harmonic walls (7.7) and linear restraints (7.8) also use this parameter to define the expected fluctuations of the colvar, allowing to express the force constant in terms of this unit. This is most useful with multi-dimensional restraints acting on variables that have very different units (for examples, working with length unit and degrees ${}^{\circ }$ simultaneously): a single force constant can be used for all, which is converted to the respective unit of each variable when forces are applied (the are printed at initialization time.

• hardLowerBoundaryWhether the lower boundary is the physical lower limit
Default: provided by the component $\left[$ boolean, context: colvar $\right]$
When the colvar has a “natural" boundary (for example, a distance colvar cannot go below 0) this flag is automatically enabled. For more complex variable definitions, or when lowerBoundary is provided directly by the user, it may be useful to set this flag explicitly. This option does not affect simulation results, but enables some internal optimizations by letting the code know that the variable is unable to cross the lower boundary, regardless of whether restraints are applied to it.
• hardUpperBoundaryWhether the upper boundary is the physical upper limit of the colvar's values
Default: provided by the component $\left[$ boolean, context: colvar $\right]$
Analogous to hardLowerBoundary.
• expandBoundariesAllow to expand the two boundaries if needed
Default: off $\left[$ boolean, context: colvar $\right]$
If defined, lowerBoundary and upperBoundary may be automatically expanded to accommodate colvar values that do not fit in the initial range. Currently, this option is used by the metadynamics bias (7.4) to keep all of its hills fully within the grid. Enabling this option does not affect any boundaries that are defined as “hard" (see above), or any boundaries that span the full period of a periodic colvar.

#### 5.21 Trajectory output

• outputValueOutput a trajectory for this colvar
Default: on $\left[$ boolean, context: colvar $\right]$
If colvarsTrajFrequency is non-zero, the value of this colvar is written to the trajectory file every colvarsTrajFrequency steps in the column labeled “$<$name$>$".
• outputVelocityOutput a velocity trajectory for this colvar
Default: off $\left[$ boolean, context: colvar $\right]$
If colvarsTrajFrequency is defined, the finite-difference calculated velocity of this colvar are written to the trajectory file under the label “v_$<$name$>$".
• outputEnergyOutput an energy trajectory for this colvar
Default: off $\left[$ boolean, context: colvar $\right]$
This option applies only to extended Lagrangian colvars. If colvarsTrajFrequency is defined, the kinetic energy of the extended degree and freedom and the potential energy of the restraining spring are are written to the trajectory file under the labels “Ek_$<$name$>$" and “Ep_$<$name$>$".
• outputTotalForceOutput a total force trajectory for this colvar
Default: off $\left[$ boolean, context: colvar $\right]$
If colvarsTrajFrequency is defined, the total force on this colvar (i.e. the projection of all atomic total forces onto this colvar — see equation (28) in section 7.2) are written to the trajectory file under the label “fs_$<$name$>$". For extended Lagrangian colvars, the “total force" felt by the extended degree of freedom is simply the force from the harmonic spring. Note: not all components support this option. The physical unit for this force is energy unit/(colvar unit).
• outputAppliedForceOutput an applied force trajectory for this colvar
Default: off $\left[$ boolean, context: colvar $\right]$
If colvarsTrajFrequency is defined, the total force applied on this colvar by Colvars biases are written to the trajectory under the label “fa_$<$name$>$". For extended Lagrangian colvars, this force is actually applied to the extended degree of freedom rather than the geometric colvar itself. The physical unit for this force is energy unit/(colvar unit).

#### 5.22 Extended Lagrangian

The following options enable extended-system dynamics, where a colvar is coupled to an additional degree of freedom (fictitious particle) by a harmonic spring. This extended coordinate masks the colvar and replaces it transparently from the perspective of biasing and analysis methods. Biasing forces are then applied to the extended degree of freedom, and the actual geometric colvar (function of Cartesian coordinates) only feels the force from the harmonic spring. This is particularly useful when combined with an abf bias to perform eABF simulations (7.3).

Note that for some biases (harmonicWalls, histogram), this masking behavior is controlled by the keyword bypassExtendedLagrangian. Specifically for harmonicWalls, the default behavior is to bypass extended Lagrangian coordinates and act directly on the actual colvars.

• extendedLagrangianAdd extended degree of freedom
Default: off $\left[$ boolean, context: colvar $\right]$
Adds a fictitious particle to be coupled to the colvar by a harmonic spring. The fictitious mass and the force constant of the coupling potential are derived from the parameters extendedTimeConstant and extendedFluctuation, described below. Biasing forces on the colvar are applied to this fictitious particle, rather than to the atoms directly. This implements the extended Lagrangian formalism used in some metadynamics simulations [3]. .
• extendedFluctuationStandard deviation between the colvar and the fictitious particle (colvar unit)
$\left[$ positive decimal, context: colvar $\right]$
Defines the spring stiffness for the extendedLagrangian mode, by setting the typical deviation between the colvar and the extended degree of freedom due to thermal fluctuation. The spring force constant is calculated internally as ${k}_{B}T∕{\sigma }^{2}$, where $\sigma$ is the value of extendedFluctuation.
• extendedTimeConstantOscillation period of the fictitious particle (fs)
Default: 200 $\left[$ positive decimal, context: colvar $\right]$
Defines the inertial mass of the fictitious particle, by setting the oscillation period of the harmonic oscillator formed by the fictitious particle and the spring. The period should be much larger than the MD time step to ensure accurate integration of the extended particle's equation of motion. The fictitious mass is calculated internally as ${k}_{B}T{\left(\tau ∕2\pi \sigma \right)}^{2}$, where $\tau$ is the period and $\sigma$ is the typical fluctuation (see above).
• extendedTempTemperature for the extended degree of freedom (K)
Default: thermostat temperature $\left[$ positive decimal, context: colvar $\right]$
Temperature used for calculating the coupling force constant of the extended variable (see extendedFluctuation) and, if needed, as a target temperature for extended Langevin dynamics (see extendedLangevinDamping). This should normally be left at its default value.
• extendedLangevinDampingDamping factor for extended Langevin dynamics (ps${}^{-1}$)
Default: 1.0 $\left[$ positive decimal, context: colvar $\right]$
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 slowing down diffusive sampling) and stochastic noise (increasing the variance of statistical measurements). In doubt, use the default value.
• reflectingLowerBoundaryWhether the lower boundary reflects the extended Lagrangian particle
Default: off $\left[$ boolean, context: colvar $\right]$
This turns the specified lowerBoundary into a reflecting wall for the extended particle: upon collision, the particle is reflected with opposite momentum.
• reflectingUpperBoundaryWhether the upper boundary reflects the extended Lagrangian particle
Default: off $\left[$ boolean, context: colvar $\right]$
This turns the specified upperBoundary into a reflecting wall for the extended particle: upon collision, the particle is reflected with opposite momentum.

#### 5.23 Multiple time-step variables

• timeStepFactorCompute this colvar once in a certain number of timesteps
Default: 1 $\left[$ positive integer, context: colvar $\right]$
Instructs this colvar to activate at a time interval equal to the base (MD) timestep times timeStepFactor.[15] At other time steps, the value of the variable is not updated, and no biasing forces are applied. Any forces exerted by biases are accumulated over the given time interval, then applied as an impulse at the next update.

#### 5.24 Backward-compatibility

• subtractAppliedForceDo not include biasing forces in the total force for this colvar
Default: off $\left[$ boolean, context: colvar $\right]$
If the colvar supports total force calculation (see 5.16.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.

#### 5.25 Statistical analysis

Run-time calculations of statistical properties that depend explicitly on time can be performed for individual collective variables. Currently, several types of time correlation functions, running averages and running standard deviations are implemented. For run-time computation of histograms, please see the histogram bias (7.10).

• corrFuncCalculate a time correlation function?
Default: off $\left[$ boolean, context: colvar $\right]$
Whether or not a time correlaction function should be calculated for this colvar.
• corrFuncWithColvarColvar name for the correlation function
$\left[$ string, context: colvar $\right]$
By default, the auto-correlation function (ACF) of this colvar, ${\xi }_{i}$, is calculated. When this option is specified, the correlation function is calculated instead with another colvar, ${\xi }_{j}$, which must be of the same type (scalar, vector, or quaternion) as ${\xi }_{i}$.
• corrFuncTypeType of the correlation function
Default: velocity $\left[$ velocity, coordinate or coordinate_p2, context: colvar $\right]$
With coordinate or velocity, the correlation function ${C}_{i,j}\left(t\right)$ = $⟨\mathrm{\Pi }\left({\xi }_{i}\left({t}_{0}\right),{\xi }_{j}\left({t}_{0}+t\right)\right)⟩$ is calculated between the variables ${\xi }_{i}$ and ${\xi }_{j}$, or their velocities. $\mathrm{\Pi }\left({\xi }_{i},{\xi }_{j}\right)$ 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, $\left(3\mathrm{cos}⁡{\left(𝜃\right)}^{2}-1\right)∕2$, is used instead of the cosine.
• corrFuncNormalizeNormalize the time correlation function?
Default: on $\left[$ boolean, context: colvar $\right]$
If enabled, the value of the correlation function at $t$ = 0 is normalized to 1; otherwise, it equals to $⟨O\left({\xi }_{i},{\xi }_{j}\right)⟩$.
• corrFuncLengthLength of the time correlation function
Default: 1000 $\left[$ positive integer, context: colvar $\right]$
Length (in number of points) of the time correlation function.
• corrFuncStrideStride of the time correlation function
Default: 1 $\left[$ positive integer, context: colvar $\right]$
Number of steps between two values of the time correlation function.
• corrFuncOffsetOffset of the time correlation function
Default: 0 $\left[$ positive integer, context: colvar $\right]$
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.
• corrFuncOutputFileOutput file for the time correlation function
Default: outputName.$<$name$>$.corrfunc.dat $\left[$ UNIX filename, context: colvar $\right]$
The time correlation function is saved in this file.
• runAveCalculate the running average and standard deviation
Default: off $\left[$ boolean, context: colvar $\right]$
Whether or not the running average and standard deviation should be calculated for this colvar.
• runAveLengthLength of the running average window
Default: 1000 $\left[$ positive integer, context: colvar $\right]$
Length (in number of points) of the running average window.
• runAveStrideStride of the running average window values
Default: 1 $\left[$ positive integer, context: colvar $\right]$
Number of steps between two values within the running average window.
• runAveOutputFileOutput file for the running average and standard deviation
Default: outputName.$<$name$>$.runave.traj $\left[$ UNIX filename, context: colvar $\right]$
The running average and standard deviation are saved in this file.

### 6 Selecting atoms

To define collective variables, atoms are usually selected as groups. Each group is defined using an identifying keyword that is unique in the context of the specific colvar component (e.g. for a distance component, the two groups are identified by the group1 and group2 keywords).

The group's identifying keyword is followed by a brace-delimited block containing selection keywords and other parameters, one of which is name:

• nameUnique name for the atom group
$\left[$ string, context: atom group $\right]$
This parameter defines a globally unique name for this atom group, which can be referred to in the definition of other atom groups (including in other colvars) by invoking atomsOfGroup as a selection keyword. This has two benefits: (1) it can make the configuration shorter and more legible, and (2) several related atom groups can be defined using a common set of atoms, so that this selection can be changed in one place, keeping all related groups synchronized with the same atom set.

Other keywords are documented in the following sections.

In the example below, the gyration component uses the identifying keyword atoms to define its associated group, which is defined based on the index group named “Protein-H". Optionally, the group is also given the unique name “my_protein", so that atom groups defined later in the Colvars configuration may refer to it.

colvar {  name rgyr  gyration {    atoms {      name my_protein      indexGroup Protein-H    }  }}

#### 6.1 Atom selection keywords

Selection keywords may be used individually or in combination with each other, and each can be repeated any number of times. Selection is incremental: each keyword adds the corresponding atoms to the selection, so that different sets of atoms can be combined. However, atoms included by multiple keywords are only counted once. Below is an example configuration for an atom group called “atoms". Note: this is an unusually varied combination of selection keywords, demonstrating how they can be combined together: most simulations only use one of them.

atoms {  # add atoms 1 and 3 to this group (note: first atom in the system is 1)  atomNumbers {     1 3  }  # add atoms starting from 20 up to and including 50  atomNumbersRange  20-50  # add all the atoms with occupancy 2 in the file atoms.pdb  atomsFile             atoms.pdb  atomsCol              O  atomsColValue         2.0  # add all the C-alphas within residues 11 to 20 of segments "PR1" and "PR2"  psfSegID              PR1 PR2  atomNameResidueRange  CA 11-20  atomNameResidueRange  CA 11-20  # add index group (requires a .ndx file to be provided globally)  indexGroup Water}

The resulting selection includes atoms 1 and 3, those between 20 and 50, the ${C}_{\alpha }$ atoms between residues 11 and 20 of the two segments PR1 and PR2, and those in the index group called “Water". The indices of this group are read from the file provided by the global keyword indexFile.

In the current version, the Colvars module does not manipulate VMD atom selections directly: however, these can be converted to atom groups within the Colvars configuration string, using selection keywords such as atomNumbers. The complete list of selection keywords available in VMD is:

• atomNumbersList of atom numbers
$\left[$ space-separated list of positive integers, context: atom group $\right]$
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".
• indexGroupName of index group to be used (GROMACS format)
$\left[$ string, context: atom group $\right]$
If the name of an index file has been provided by indexFile, this option allows to select one index group from that file: the atoms from that index group will be used to define the current group.
• atomsOfGroupName of group defined previously
$\left[$ string, context: atom group $\right]$
Refers to a group defined previously using its user-defined name. This adds all atoms of that named group to the current group.
• atomNumbersRangeAtoms within a number range
$\left[$ $<$Starting number$>$-$<$Ending number$>$, context: atom group $\right]$
This option includes in the group all atoms whose numbers are within the range specified. The number of the first atom in the system is 1.
• atomNameResidueRangeNamed atoms within a range of residue numbers
$\left[$ $<$Atom name$>$ $<$Starting residue$>$-$<$Ending residue$>$, context: atom group $\right]$
This option adds to the group all the atoms with the provided name, within residues in the given range.
• psfSegIDPSF segment identifier
$\left[$ space-separated list of strings (max 4 characters), context: atom group $\right]$
This option sets the PSF segment identifier for atomNameResidueRange. Multiple values may be provided, which correspond to multiple instances of atomNameResidueRange, in order of their occurrence. This option is only necessary if a PSF topology file is used.
• atomsFilePDB file name for atom selection
$\left[$ UNIX filename, context: atom group $\right]$
This option selects atoms from the PDB file provided and adds them to the group according to numerical flags in the column atomsCol. Note: the sequence of atoms in the PDB file provided must match that in the system's topology.
• atomsColPDB column to use for atom selection flags
$\left[$ O, B, X, Y, or Z, context: atom group $\right]$
This option specifies which PDB column in atomsFile is used to determine which atoms are to be included in the group.
• atomsColValueAtom selection flag in the PDB column
$\left[$ positive decimal, context: atom group $\right]$
If defined, this value in atomsCol identifies atoms in atomsFile that are included in the group. If undefined, all atoms with a non-zero value in atomsCol are included.
• dummyAtomDummy atom position (length unit)
$\left[$ (x, y, z) triplet, context: atom group $\right]$
Instead of selecting any atom, this option makes the group a virtual particle at a fixed position in space. This is useful e.g. to replace a group's center of geometry with a user-defined position.

#### 6.2 Moving frame of reference.

The following options define an automatic calculation of an optimal translation (centerToReference) or optimal rotation (rotateToReference), that superimposes the positions of this group to a provided set of reference coordinates. Alternately, centerToOrigin applies a translation to place the geometric center of the group at (0, 0, 0). This can allow, for example, to effectively remove from certain colvars the effects of molecular tumbling and of diffusion. Given the set of atomic positions ${x}_{i}$, the colvar $\xi$ can be defined on a set of roto-translated positions ${x}_{i}^{\prime }=R\left({x}_{i}-{x}^{C}\right)+{x}^{ref}$. ${x}^{C}$ is the geometric center of the ${x}_{i}$, $R$ is the optimal rotation matrix to the reference positions and ${x}^{ref}$ is the geometric center of the reference positions.

Components that are defined based on pairwise distances are naturally invariant under global roto-translations. Other components are instead affected by global rotations or translations: however, they can be made invariant if they are expressed in the frame of reference of a chosen group of atoms, using the centerToReference and rotateToReference options. Finally, a few components are defined by convention using a roto-translated frame (e.g. the minimal RMSD): for these components, centerToReference and rotateToReference are enabled by default. In typical applications, the default settings result in the expected behavior.

Warning on rotating frames of reference and periodic boundary conditions. rotateToReference affects coordinates that depend on minimum-image distances in periodic boundary conditions (PBC). After 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 centerToReference and rotateToReference 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.

• centerToReferenceImplicitly remove translations for this group
Default: off $\left[$ boolean, context: atom group $\right]$
If this option is on, the center of geometry of the group will be aligned with that of the reference positions provided by either refPositions or refPositionsFile. Colvar components will only have access to the aligned positions. Note: unless otherwise specified, rmsd and eigenvector set this option to on by default.
• centerToOriginImplicitly remove translations for this group by keeping its center at the origin
Default: off $\left[$ boolean, context: atom group $\right]$
This option implies centerToReference. If this option is on, coordinates from the group will be translated so that the center of geometry of the group remains at (0, 0, 0), except if fittingGroup is enabled. In that case, the translation applied is the translation that brings the center of geometry of the fitting group to (0, 0, 0).
• rotateToReferenceImplicitly remove rotations for this group
Default: off $\left[$ boolean, context: atom group $\right]$
If this option is on, the coordinates of this group will be optimally superimposed to the reference positions provided by either refPositions or refPositionsFile. The rotation will be performed around the center of geometry if centerToReference is on, or around the origin otherwise. The algorithm used is the same employed by the orientation colvar component [4]. Forces applied to the atoms of this group will also be implicitly rotated back to the original frame. Note: unless otherwise specified, rmsd and eigenvector set this option to on by default.
• refPositionsReference positions for fitting (length unit)
$\left[$ space-separated list of (x, y, z) triplets, context: atom group $\right]$
This option provides a list of reference coordinates for centerToReference and/or rotateToReference, and is mutually exclusive with refPositionsFile. If only centerToReference is on, the list may contain a single (x, y, z) triplet; if also rotateToReference is on, the list should be as long as the atom group, and its order must match the order in which atoms were defined.
• refPositionsFileFile containing the reference positions for fitting
$\left[$ UNIX filename, context: atom group $\right]$
This option provides a list of reference coordinates for centerToReference and/or rotateToReference, and is mutually exclusive with refPositions. The acceptable file format is XYZ (4.7.3), which is read in double precision. Alternatively, a PDB file may be read (see 4.7.4) using VMD's reader; however, due to the constraints of the PDB format PDB files are discouraged if the precision of the reference coordinates is a concern.
• refPositionsColPDB column containing atom flags
$\left[$ O, B, X, Y, or Z, context: atom group $\right]$
Like atomsCol for atomsFile, indicates which column to use to identify the atoms in refPositionsFile (if this is a PDB file).
• refPositionsColValueAtom selection flag in the PDB column
$\left[$ positive decimal, context: atom group $\right]$
Analogous to atomsColValue, but applied to refPositionsCol.
• fittingGroupUse an alternate set of atoms to define the roto-translation
Default: This atom group itself $\left[$ Atom group, context: atom group $\right]$
If either centerToReference or rotateToReference 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!"). Performance considerations: note that enabling this option will result in projecting each of the atomic gradients of the colvar (e.g. the RMSD) onto each the gradients of the roto-translation, which may be a computationally expensive operation: see the closely related enableFitGradients for details.

The following example illustrates the use of fittingGroup as part of a Distance to Bound Configuration (DBC) coordinate for use in ligand restraints for binding affinity calculations.[16] The group called “atoms" describes coordinates of a ligand's atoms, expressed in a moving frame of reference tied to a binding site (here within a protein). An optimal roto-translation is calculated automatically by fitting the C${}_{\alpha }$ trace of the rest of the protein onto the coordinates provided by a PDB file. To define a DBC coordinate, this atom group would be used within an rmsd function.

# Example: defining a group "atoms" (the ligand) whose coordinates are expressed # in a roto-translated frame of reference defined by a second group (the receptor)atoms {  atomNumbers 1 2 3 4 5 6 7 # atoms of the ligand (1-based)  centerToReference yes  rotateToReference yes  fittingGroup {    # define the frame by fitting alpha carbon atoms    # in 2 protein segments close to the site    psfSegID              PROT PROT    atomNameResidueRange  CA 1-40    atomNameResidueRange  CA 59-100  }   refPositionsFile all.pdb  # can be the entire system}

The following options have default values appropriate for the vast majority of applications, and are only provided to support rare, special cases.

Default: on $\left[$ boolean, context: atom group $\right]$
When either centerToReference or rotateToReference is on, the gradients of some colvars include terms proportional to $\partial R∕\partial {x}_{i}$ (rotational gradients) and $\partial {x}^{C}∕\partial {x}_{i}$ (translational gradients). By default, these terms are calculated and included in the total gradients; if this option is set to off, they are neglected. In the case of a minimum RMSD component, this flag is automatically disabled because the contributions of those derivatives to the gradients cancel out; other types of variable will require projecting each of the gradients of the variable onto each of the gradients of the roto-translation (i.e. a $O\left({N}^{2}\right)$ loop). When fittingGroup is enabled, the computation is a $O\left(N×M\right)$ loop for all variables, including RMSDs.

#### 6.3 Treatment of periodic boundary conditions.

In simulations with periodic boundary conditions (PBCs), Colvars computes all distances between two points following the nearest-image convention, using PBC parameters provided by VMD. However, many common variables rely on a consistent definition of the center of mass or geometry of a group of atoms. This requires the use of unwrapped coordinates, which are not subject to “jumps" when they diffuse across periodic boundaries.

In general, internal coordinate wrapping by VMD does not affect the calculation of colvars if each atom group satisfies one or more of the following:

1. it is composed by only one atom;
2. 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);
3. 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).

If none of these conditions are met, wrapping may affect the calculation of collective variables: a possible solution is to use pbc wrap or pbc unwrap (or the alternative qwrap or qunwrap: https://github.com/jhenin/qwrap) prior to processing a trajectory with the Colvars module.

#### 6.4 Performance of a Colvars calculation based on group size.

In simulations performed with MD simulation engines such as GROMACS, LAMMPS or NAMD, the computation of energy and forces is distributed (i.e., parallelized) over multiple nodes, as well as over the CPU/GPU cores of each node. When Colvars is enabled, atomic coordinates are collected on a single CPU core, where collective variables and their biases are computed. This means that in the case of simulations that are already being run over large numbers of nodes, or inside a GPU, a Colvars calculation may produce a significant overhead. This overhead comes from the combined cost of two operation: transmitting atomic coordinates, and computing functions of the same.

Performance can be improved in multiple ways:

• 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). For example, restraining a protein through a RMSD colvar defined over all of its atoms is only marginally different than one defined over only the $\alpha$ carbon atoms, but the difference in computational cost is much higher. To gain an estimate of the computational cost of a specific Colvars configuration, one may use a test calculation of the same colvar in VMD (hint: use the time Tcl command to measure the cost of running cv update).
• 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. The messages “SMP parallelism is available" or “SMP parallelism is enabled", printed by Colvars at initialization time, indicate the availability or status of this feature (will be supported in a future release of VMD). If available, the option is turned on by default, but may be disabled using the keyword smp if required for debugging or troubleshooting.

### 7 Biasing and analysis methods

A biasing or analysis method can be applied to existing collective variables by using the following configuration:

$<$biastype$>$ {  name $<$name$>$
colvars $<$xi1$>$ $<$xi2$>$ ...  $<$parameters$>$} 

The keyword $<$biastype$>$ indicates the method of choice. There can be multiple instances of the same method, e.g. using multiple harmonic blocks allows defining multiple restraints.

All biasing and analysis methods implemented recognize the following options:

• nameIdentifier for the bias
Default: $<$type of bias$><$bias index$>$ $\left[$ string, context: colvar bias $\right]$
This string is used to identify the bias or analysis method in the output, and to name some output files. Tip: although a unique name is assigned automatically, you are strongly encouraged to give a name to a bias that you may want to analyze later. For example, processing a trajectory file (sec. 4.7.6) containing a harmonic restraint is much simpler with a clearly identifiable name, like “smd" for a moving harmonic restraint or “us" for a static one.
• colvarsCollective variables involved
$\left[$ space-separated list of colvar names, context: colvar bias $\right]$
This option selects by name all the variables to which this bias or analysis will be applied.
• outputEnergyWrite the current bias energy to the trajectory file
Default: off $\left[$ boolean, context: colvar bias $\right]$
If this option is chosen and colvarsTrajFrequency is not zero, the current value of the biasing energy will be written to the trajectory file during the simulation.
• outputFreqFrequency (number of steps) at which output files are written
Default: colvarsRestartFrequency $\left[$ positive integer, context: colvar bias $\right]$
If this bias produces aggregated data that needs to be written to disk (for example, a PMF), this number specifies the number of steps after which these data are written to files. A value of zero disables writing files for this bias during the simulation (except for outputEnergy, which is controlled by colvarsTrajFrequency). All output files are also written at the end of a simulation run, regardless of the value of this number. In VMD, this option has no effect.
• bypassExtendedLagrangianApply bias to actual colvars, bypassing extended coordinates
Default: off $\left[$ boolean, context: colvar bias $\right]$
This option is implemented by the harmonicWalls and histogram biases. It is only relevant if the bias is applied to one or several extended-Lagrangian colvars (5.22), for example within an eABF (7.3) simulation. Usually, biases use the value of the extended coordinate as a proxy for the actual colvar, and their biasing forces are applied to the extended coordinates as well. If bypassExtendedLagrangian is enabled, the bias behaves as if there were no extended coordinates, and accesses the value of the underlying colvars, applying any biasing forces along the gradients of those variables.
• stepZeroDataAccumulate data starting at step 0 of a simulation run
Default: off $\left[$ boolean, context: colvar bias $\right]$
This option is meaningful for biases that record and accumulate data during a simulation, such as ABF (7.2), metadynamics (7.4), histograms (7.10) and in general any bias that accumulates free-energy samples with thermodynamic integration, or TI (7.1). When this option is disabled (default), data will only be recorded into the bias after the first coordinate update: this is generally the correct choice in simulation runs. Biasing energy and forces will always be computed for all active biases, regardless of this option.
• scaledBiasingForceScale biasing force by a factor in an external histogram
Default: off $\left[$ boolean, context: colvar bias $\right]$
If this option is set to on, the biasing force at each step will be scaled by a factor provided in the grid of an external histogram. The histogram file is provided by scaledBiasingForceFactorsGrid. It ought to be noted that if the variables are not in any grids of the histogram, the scaling factor is 1.0.
• scaledBiasingForceFactorsGridA histogram file with the scaling factor of biasing force in each bin
$\left[$ string, context: colvar bias $\right]$
If scaledBiasingForce is set to on, this option accepts the filename of the histogram file that contains the scaling factors. The histogram file is expected to be in “multicolumn" format (4.7.5), similar to the low-dimensional the PMF files written by metadynamics and ABF.

#### 7.1 Thermodynamic integration

The methods implemented here provide a variety of estimators of conformational free-energies. These are carried out at run-time, or with the use of post-processing tools over the generated output files. The specifics of each estimator are discussed in the documentation of each biasing or analysis method.

A special case is the traditional thermodynamic integration (TI) method, used for example to compute potentials of mean force (PMFs). Most types of restraints (7.5, 7.7, 7.8, ...) as well as metadynamics (7.4) can optionally use TI alongside their own estimator, based on the keywords documented below.

• writeTIPMFWrite the PMF computed by thermodynamic integration
Default: off $\left[$ boolean, context: colvar bias $\right]$
If the bias is applied to a variable that supports the calculation of total forces (see outputTotalForce and 5.16.1), this option allows calculating the corresponding PMF by thermodynamic integration, and writing it to the file outputName.$<$name$>$.ti.pmf, where $<$name$>$ is the name of the bias and the contents of the file are in multicolumn text format (4.7.5). The total force includes the forces applied to the variable by all bias, except those from this bias itself. If any bias applies time-dependent forces besides the one using this option, an error is raised.
• writeTISamplesWrite the free-energy gradient samples
Default: off $\left[$ boolean, context: colvar bias $\right]$
This option allows to compute total forces for use with thermodynamic integration as done by the keyword writeTIPMF. The names of the files containing the variables' histogram and mean thermodynamic forces are outputName.$<$name$>$.ti.count and outputName.$<$name$>$.ti.force, respectively: these can be used by abf_integrate (see 7.2.4) or similar utility. Note that because the .force file contains mean forces instead of free-energy gradients, abf_integrate $<$filename$>$ -s -1.0 should be used. This option is on by default when 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.

In adaptive biasing force (ABF) (7.2) the above keywords are not recognized, because their functionality is either included already (conventional ABF) or not available (extended-system ABF).

For a full description of the Adaptive Biasing Force method, see reference [17]. For details about this implementation, see references [18] and [19]. When publishing research that makes use of this functionality, please cite references [17] and [19].

An alternate usage of this feature is the application of custom tabulated biasing potentials to one or more colvars. See inputPrefix and updateBias below.

Combining ABF with the extended Lagrangian feature (5.22) of the variables produces the extended-system ABF variant of the method (7.3).

ABF is based on the thermodynamic integration (TI) scheme for computing free energy profiles. The free energy as a function of a set of collective variables $\text{}\xi \text{}={\left({\xi }_{i}\right)}_{i\in \left[1,n\right]}$ is defined from the canonical distribution of $\text{}\xi \text{}$, $\mathsc{𝒫}\left(\text{}\xi \text{}\right)$:

 $A\left(\text{}\xi \text{}\right)=-\frac{1}{\beta }\mathrm{ln}⁡\mathsc{𝒫}\left(\text{}\xi \text{}\right)+{A}_{0}$ (24)

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 ${\text{}F\text{}}_{\xi }$ exerted on $\text{}\xi \text{}$, taken over an iso-$\text{}\xi \text{}$ surface:

 ${\text{}\nabla ⁡\text{}}_{\xi }A\left(\text{}\xi \text{}\right)={⟨-{\text{}F\text{}}_{\xi }⟩}_{\text{}\xi \text{}}$ (25)

Several formulae that take the form of (25) have been proposed. This implementation relies partly on the classic formulation [20], and partly on a more versatile scheme originating in a work by Ruiz-Montero et al. [21], generalized by den Otter [22] and extended to multiple variables by Ciccotti et al. [23]. Consider a system subject to constraints of the form ${\sigma }_{k}\left(\text{}x\text{}\right)=0$. Let ${\left({\text{}v\text{}}_{i}\right)}_{i\in \left[1,n\right]}$ be arbitrarily chosen vector fields (${ℝ}^{3N}\to {ℝ}^{3N}$) verifying, for all $i$, $j$, and $k$:

$\begin{array}{rcll}{\text{}v\text{}}_{i}\cdot \text{}{\nabla ⁡}_{\phantom{\rule{-0.17em}{0ex}}\phantom{\rule{-0.17em}{0ex}}x}\phantom{\rule{0.17em}{0ex}}\text{}{\xi }_{j}& =& {\delta }_{ij}& \text{(26)}\text{}\text{}\\ {\text{}v\text{}}_{i}\cdot \text{}{\nabla ⁡}_{\phantom{\rule{-0.17em}{0ex}}\phantom{\rule{-0.17em}{0ex}}x}\phantom{\rule{0.17em}{0ex}}\text{}{\sigma }_{k}& =& 0& \text{(27)}\text{}\text{}\end{array}$

then the following holds [23]:

 $\frac{\partial A}{\partial {\xi }_{i}}={⟨{\text{}v\text{}}_{i}\cdot \text{}{\nabla ⁡}_{\phantom{\rule{-0.17em}{0ex}}\phantom{\rule{-0.17em}{0ex}}x}\phantom{\rule{0.17em}{0ex}}\text{}V-{k}_{B}T\text{}{\nabla ⁡}_{\phantom{\rule{-0.17em}{0ex}}\phantom{\rule{-0.17em}{0ex}}x}\phantom{\rule{0.17em}{0ex}}\text{}\cdot {\text{}v\text{}}_{i}⟩}_{\text{}\xi \text{}}$ (28)

where $V$ is the potential energy function. ${\text{}v\text{}}_{i}$ can be interpreted as the direction along which the force acting on variable ${\xi }_{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 [20]. Condition (26) states that the direction along which the total force on ${\xi }_{i}$ is measured is orthogonal to the gradient of ${\xi }_{j}$, which means that the force measured on ${\xi }_{i}$ does not act on ${\xi }_{j}$.

Equation (27) implies that constraint forces are orthogonal to the directions along which the free energy gradient is measured, so that the measurement is effectively performed on unconstrained degrees of freedom.

In the framework of ABF, ${F}_{\xi }$ is accumulated in bins of finite size $\delta \xi$, thereby providing an estimate of the free energy gradient according to equation (25). The biasing force applied along the collective variables to overcome free energy barriers is calculated as:

 ${F}^{ABF}=\alpha \left({N}_{\xi }\right)×\text{}{\nabla ⁡}_{\phantom{\rule{-0.17em}{0ex}}\phantom{\rule{-0.17em}{0ex}}x}\phantom{\rule{0.17em}{0ex}}\text{}\stackrel{~}{A}\left(\text{}\xi \text{}\right)$ (29)

where $\text{}{\nabla ⁡}_{\phantom{\rule{-0.17em}{0ex}}\phantom{\rule{-0.17em}{0ex}}x}\phantom{\rule{0.17em}{0ex}}\text{}\stackrel{~}{A}$ denotes the current estimate of the free energy gradient at the current point $\text{}\xi \text{}$ in the collective variable subspace, and $\alpha \left({N}_{\xi }\right)$ is a scaling factor that is ramped from 0 to 1 as the local number of samples ${N}_{\xi }$ increases to prevent non-equilibrium 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 $\text{}{\nabla ⁡}_{\phantom{\rule{-0.17em}{0ex}}\phantom{\rule{-0.17em}{0ex}}x}\phantom{\rule{0.17em}{0ex}}\text{}\stackrel{~}{A}$ is progressively refined. The biasing force introduced in the equations of motion guarantees that in the bin centered around $\text{}\xi \text{}$, the forces acting along the selected collective variables average to zero over time. Eventually, as the underlying free energy surface is canceled by the adaptive bias, evolution of the system along $\text{}\xi \text{}$ 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 be difficult to sample and visualize. Most commonly, the number of variables is one or two, sometimes three.

##### 7.2.1 ABF requirements on collective variables

The following conditions must be met for an ABF simulation to be possible and to produce an accurate estimate of the free energy profile. Note that these requirements do not apply when using the extended-system ABF method (7.3).

1. Only linear combinations of colvar components can be used in ABF calculations.
2. Availability of total forces is necessary. The following colvar components can be used in ABF calculations: 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 measurement by specifying oneSiteTotalForce, if available.
3. Mutual orthogonality of colvars. In a multidimensional ABF calculation, equation (26) must be satisfied for any two colvars ${\xi }_{i}$ and ${\xi }_{j}$. Various cases fulfill this orthogonality condition:
• ${\xi }_{i}$ and ${\xi }_{j}$ are based on non-overlapping sets of atoms.
• atoms involved in the force measurement on ${\xi }_{i}$ do not participate in the definition of ${\xi }_{j}$. This can be obtained using the option oneSiteTotalForce of the distance, angle, and dihedral components (example: Ramachandran angles $\varphi$, $\psi$).
• ${\xi }_{i}$ and ${\xi }_{j}$ are orthogonal by construction. Useful cases are the sum and difference of two components, or distance_z and distance_xy using the same axis.
4. Mutual orthogonality of components: when several components are combined into a colvar, it is assumed that their vectors ${\text{}v\text{}}_{i}$ (equation (28)) are mutually orthogonal. The cases described for colvars in the previous paragraph apply.
5. Orthogonality of colvars and constraints: equation 27 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 atoms to the left-hand side of equation 27 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.

##### 7.2.2 Parameters for ABF

ABF depends on parameters from each collective variable to define the grid on which free energy gradients are computed: see 5.20 for detauls. Other parameters to control the ABF runtime can be set in the ABF configuration block:

• name — same definition as name (biasing and analysis methods)
• colvars — same definition as colvars (biasing and analysis methods)
• outputEnergy — same definition as outputEnergy (biasing and analysis methods)
• outputFreq — same definition as outputFreq (biasing and analysis methods)
• stepZeroData — same definition as stepZeroData (biasing and analysis methods)
• fullSamplesNumber of samples in a bin prior to full application of the ABF
Default: 200 $\left[$ positive integer, context: abf $\right]$
To avoid non-equilibrium effects due to large fluctuations of the force exerted along the colvars, it is recommended to apply a biasing force only after a the estimate has started converging. If fullSamples is non-zero, the applied biasing force is scaled by a factor $\alpha \left({N}_{\xi }\right)$ between 0 and 1. If the number of samples ${N}_{\xi }$ in the current bin is higher than fullSamples, the factor is one. If it is less than minSamples (by default, half of fullSamples), the factor is zero and no bias is applied. Between those two thresholds, the factor follows a linear ramp from 0 to 1: $\alpha \left({N}_{\xi }\right)=\left({N}_{\xi }-minSamples\right)∕\left(fullSamples-minSamples\right)$.
• minSamplesNumber of samples in a bin prior to application of the ABF
Default: fullSamples / 2 $\left[$ positive integer, context: abf $\right]$
See fullSamples.
• maxForceMaximum magnitude of the ABF force
Default: disabled $\left[$ positive decimals (one per colvar), context: abf $\right]$
This option enforces a cap on the magnitude of the biasing force effectively applied by this ABF bias on each colvar. This can be useful in the presence of singularities in the PMF such as hard walls, where the discretization of the average force becomes very inaccurate, causing the colvar's diffusion to get “stuck" at the singularity. To enable this cap, provide one non-negative value for each colvar. The unit of force is energy unit/(colvar unit).
• hideJacobianRemove geometric entropy term from calculated free energy gradient?
Default: no $\left[$ boolean, context: abf $\right]$
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. The Jacobian term is exactly represented in equation (28) by the second term of the average, $-{k}_{B}T\text{}{\nabla ⁡}_{\phantom{\rule{-0.17em}{0ex}}\phantom{\rule{-0.17em}{0ex}}x}\phantom{\rule{0.17em}{0ex}}\text{}\cdot {\text{}v\text{}}_{i}$. Enabling the hideJacobian option causes the output data to follow the traditional potential of mean force convention, by omitting this contribution from the measured free energy gradients. To ensure uniform sampling despite the incomplete description of the free energy, an additional biasing force that counteracts the Jacobian force is applied internally by the colvar. Warning: using this option without detailed knowledge of the terms of equation (28) is not recommended. Warning: a bug affecting Colvars version until October 2020 leads to this term to be subtracted twice in the PMFs reported by conventional ABF. The bug does not affect the simulated trajectory, and the correct PMF can be recovered by adding back the term manually. Other than conventional ABF, the PMFs computed by other sampling methods were never affected.
• historyFreqFrequency (in timesteps) at which ABF history files are accumulated
Default: 0 $\left[$ positive integer, context: abf $\right]$
If this number is non-zero, the free energy gradient estimate and sampling histogram (and the PMF in one-dimensional calculations) are written to files on disk at the given time interval. History file names use the same prefix as output files, with “.hist" appended (outputName.hist.pmf). historyFreq must be a multiple of outputFreq.
• inputPrefixFilename prefix for reading ABF data
$\left[$ list of strings, context: abf $\right]$
If this parameter is set, for each item in the list, ABF tries to read a gradient and a sampling files named $<$inputPrefix$>$.grad and $<$inputPrefix$>$.count. This is done at startup and sets the initial state of the ABF algorithm. The data from all provided files is combined appropriately. Also, the grid definition (min and max values, width) need not be the same that for the current run. This command is useful to piece together data from simulations in different regions of collective variable space, or change the colvar boundary values and widths. Note that it is not recommended to use it to switch to a smaller width, as that will leave some bins empty in the finer data grid. This option is NOT compatible with reading the data from a restart file (cv load command).
• applyBiasApply the ABF bias?
Default: yes $\left[$ boolean, context: abf $\right]$
If this is set to no, the calculation proceeds normally but the adaptive biasing force is not applied. Data is still collected to compute the free energy gradient. This is mostly intended for testing purposes, and should not be used in routine simulations.
• updateBiasUpdate the ABF bias?
Default: yes $\left[$ boolean, context: abf $\right]$
If this is set to no, the initial biasing force (e.g. read from a restart file or through inputPrefix) is not updated during the simulation. As a result, a constant bias is applied. This can be used to apply a custom, tabulated biasing potential to any combination of colvars. To that effect, one should prepare a gradient file containing the gradient of the potential to be applied (negative of the bias force), and a count file containing only values greater than fullSamples. These files must match the grid parameters of the colvars.

##### 7.2.3 Output files

The ABF bias produces the following files, all in multicolumn text format (4.7.5):

• outputName.grad: current estimate of the free energy gradient (grid), in multicolumn;
• outputName.count: histogram of samples collected, on the same grid;
• outputName.pmf: integrated free energy profile or PMF (for dimension 1, and dimension 2 or 3).

Also in the case of one-dimensional calculations, the ABF bias can report its current energy via outputEnergy; in higher dimensions, such computation is not implemented and the energy reported is zero.

If several ABF biases are defined concurrently, their name is inserted to produce unique filenames for output, as in outputName.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).

##### 7.2.4 Multidimensional free energy surfaces

The ABF method only produces an estimate of the free energy gradient. The free energy surface itself can be computed depending on the value of integrate and related options.

• integrateIntegrate free energy surface from ABF gradients (dim < 3)
Default: yes $\left[$ boolean, context: abf $\right]$
This option, active by default when the dimension of the colvar space is 3 or less, enables the calculation of an integrated free energy surface every time ABF output files are written. In dimension 2 or 3, integration is performed by solving a Poisson equation: [24]  ${\nabla ⁡}^{2}{A}_{t}=\nabla ⁡\cdot {G}_{t}$ (30)

wehere ${G}_{t}$ is the estimated gradient at time $t$, and ${A}_{t}$ is corresponding free energy surface. The free energy surface is written under the file name <outputName>.pmf, in a plain text format (see 4.7.5) that can be read by most data plotting and analysis programs (e.g. Gnuplot). Periodic boundary conditions are applied to periodic coordinates, and Neumann boundary conditions otherwise (imposed free energy gradient at the boundary of the domain). The grid used for free energy discretization is extended by one point along non-periodic coordinates, but not along periodic coordinates. See ref. [24] for details.

Default: 1e-6 $\left[$ positive decimal, context: abf $\right]$
The conjugate gradients algorithm used to integrate the free energy surface is stopped when the RMS error reaches integrateTol.
Default: 10000 $\left[$ integer, context: abf $\right]$
The conjugate gradients algorithm used to integrate the free energy surface is stopped when the number of iterations reaches integrateMaxIterations, unless the RMS error has reached integrateTol before.

In dimension 4 or greater, integrating the discretized gradient becomes non-trivial. The standalone utility abf_integrate is provided to perform that task. Because 4D ABF calculations are uncommon, this tool is practically deprecated by the Poisson integration described above.

abf_integrate reads the gradient data and uses it to perform a Monte-Carlo (M-C) simulation in discretized collective variable space (specifically, on the same grid used by ABF to discretize the free energy gradient). By default, a history-dependent bias (similar in spirit to metadynamics) is used: at each M-C step, the bias at the current position is incremented by a preset amount (the hill height). Upon convergence, this bias counteracts optimally the underlying gradient; it is negated to obtain the estimate of the free energy surface.

abf_integrate is invoked using the command-line:
abf_integrate <gradient_file> [-n <nsteps>] [-t <temp>] [-m (0|1)] [-h <hill_height>] [-f <factor>]

The gradient file name is provided first, followed by other parameters in any order. They are described below, with their default value in square brackets:

• -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; expects kcal/mol as energy unit (unrelated to the simulation temperature) [500 K]
• -s: scaling factor for the gradients; when using a histogram of total forces obtained from outputTotalForce or the .force file written by writeTISamples, a scaling factor of -1 should be used [1.0]
• -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.

abf_integrate produces the following output files:

• <gradient_file>.pmf: computed free energy surface
• <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 differences)
• <gradient_file>.dev: deviation between the user-provided numerical gradient and the actual gradient of the calculated free energy surface. The RMS norm of this vector field is used as a convergence criterion and output periodically during 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). See Ref.[24] for details.

#### 7.3 Extended-system Adaptive Biasing Force (eABF)

Extended-system ABF (eABF) is a variant of ABF (7.2) where the bias is not applied directly to the collective variable, but to an extended coordinate (“fictitious variable") $\lambda$ that evolves dynamically according to Newtonian or Langevin dynamics. Such an extended coordinate is enabled for a given colvar using the extendedLagrangian and associated keywords (5.22). The theory of eABF and the present implementation are documented in detail in reference [25].

Defining an ABF bias on a colvar wherein the extendedLagrangian option is active will perform eABF automatically; there is no dedicated option.

The extended variable $\lambda$ is coupled to the colvar $z=\xi \left(q\right)$ by the harmonic potential $\left(k∕2\right){\left(z-\lambda \right)}^{2}$. Under eABF dynamics, the adaptive bias on $\lambda$ is the running estimate of the average spring force:

 ${F}^{bias}\left({\lambda }^{\ast }\right)={⟨k\left(\lambda -z\right)⟩}_{{\lambda }^{\ast }}$ (31)

where the angle brackets indicate a canonical average conditioned by $\lambda ={\lambda }^{\ast }$. At long simulation times, eABF produces a flat histogram of the extended variable $\lambda$, and a flattened histogram of $\xi$, whose exact shape depends on the strength of the coupling as defined by extendedFluctuation in the colvar. Coupling should be somewhat loose for faster exploration and convergence, but strong enough that the bias does help overcome barriers along the colvar $\xi$.[25] Distribution of the colvar may be assessed by plotting its histogram, which is written to the outputName.zcount file in every eABF simulation. Note that a histogram bias (7.10) applied to an extended-Lagrangian colvar will access the extended degree of freedom $\lambda$, not the original colvar $\xi$; however, the joint histogram may be explicitly requested by listing the name of the colvar twice in a row within the colvars parameter of the histogram block.

The eABF PMF is that of the coordinate $\lambda$, it is not exactly the free energy profile of $\xi$. That quantity can be calculated based on the CZAR estimator.

##### 7.3.1 CZAR estimator of the free energy

The corrected z-averaged restraint (CZAR) estimator is described in detail in reference [25]. It is computed automatically in eABF simulations, regardless of the number of colvars involved. Note that ABF may also be applied on a combination of extended and non-extended colvars; in that case, CZAR still provides an unbiased estimate of the free energy gradient.

CZAR estimates the free energy gradient as:

 ${A}^{\prime }\left(z\right)=-\frac{1}{\beta }\frac{d\mathrm{ln}⁡\stackrel{~}{\rho }\left(z\right)}{dz}+k\left({⟨\lambda ⟩}_{z}-z\right).$ (32)

where $z=\xi \left(q\right)$ is the colvar, $\lambda$ is the extended variable harmonically coupled to $z$ with a force constant $k$, and $\stackrel{~}{\rho }\left(z\right)$ is the observed distribution (histogram) of $z$, affected by the eABF bias.

Parameters for the CZAR estimator are:

• CZARestimatorCalculate CZAR estimator of the free energy?
Default: yes $\left[$ boolean, context: abf $\right]$
This option is only available when ABF is performed on extended-Lagrangian colvars. When enabled, it triggers calculation of the free energy following the CZAR estimator.
• writeCZARwindowFileWrite internal data from CZAR to a separate file?
Default: no $\left[$ boolean, context: abf $\right]$
When this option is enabled, eABF simulations will write a file containing the $z$-averaged restraint force under the name outputName.zgrad. The same information is always included in the colvars state file, which is sufficient for restarting an eABF simulation. These separate file is only useful when joining adjacent windows from a stratified eABF simulation, either to continue the simulation in a broader window or to compute a CZAR estimate of the PMF over the full range of the coordinate(s). Important warning. Unbiased free-energy estimators from eABF dynamics rely on some form of sampling histogram. When running stratified (windowed) calculations this histogram becomes discontinuous, and as a result the free energy gradient estimated by CZAR is inaccurate at the window boundary, resulting in visible "blips" in the PMF. As a workaround, we recommend manually replacing the two free energy gradient values at the boundary, either with the ABF values from .grad files (accurate in the limit of tight coupling), or with values interpolated for the neighboring values of the CZAR gradient.

Similar to ABF, the CZAR estimator produces two output files in multicolumn text format (4.7.5):

• outputName.czar.grad: current estimate of the free energy gradient (grid), in multicolumn;
• outputName.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 outputName.zcount.

The metadynamics method uses a history-dependent potential [26] that generalizes to any type of colvars the conformational flooding [27] and local elevation [28] 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 $\text{}\xi \text{}=\left({\xi }_{1},{\xi }_{2},\dots ⁡,{\xi }_{{N}_{cv}}\right)$ is defined as:

 ${V}_{meta}\left(\text{}\xi \text{}\left(t\right)\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sum _{{t}^{\prime }=\delta t,2\delta t,\dots }^{{t}^{\prime } (33)

where ${V}_{meta}$ is the history-dependent potential acting on the current values of the colvars $\text{}\xi \text{}$, and depends only parametrically on the previous values of the colvars. ${V}_{meta}$ is constructed as a sum of ${N}_{cv}$-dimensional repulsive Gaussian “hills", whose height is a chosen energy constant $W$, and whose centers are the previously explored configurations $\left(\text{}\xi \text{}\left(\delta t\right),\text{}\xi \text{}\left(2\delta t\right),\dots ⁡\right)$.

During the simulation, the system evolves towards the nearest minimum of the “effective" potential of mean force $Ã\left(\text{}\xi \text{}\right)$, which is the sum of the “real" underlying potential of mean force $A\left(\text{}\xi \text{}\right)$ and the the metadynamics potential, ${V}_{meta}\left(\text{}\xi \text{}\right)$. Therefore, at any given time the probability of observing the configuration $\text{}{\xi }^{\ast }\text{}$ is proportional to $\mathrm{exp}⁡\left(-Ã\left(\text{}{\xi }^{\ast }\text{}\right)∕{\kappa }_{B}T\right)$: this is also the probability that a new Gaussian “hill" is added at that 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 $Ã\left(\text{}\xi \text{}\right)$ is constant, and $-{V}_{meta}\left(\text{}\xi \text{}\right)$ is an estimator of the “real" potential of mean force $A\left(\text{}\xi \text{}\right)$, save for an additive constant:

 $A\left(\text{}\xi \text{}\right)\phantom{\rule{0.28em}{0ex}}\simeq \phantom{\rule{0.28em}{0ex}}-{V}_{meta}\left(\text{}\xi \text{}\right)+K$ (34)

Such estimate of the free energy can be provided by enabling writeFreeEnergyFile. 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 ${\tau }_{{\xi }_{i}}$, and of the user-defined parameters $W$, ${\sigma }_{{\xi }_{i}}$ and $\delta t$ [29]. In typical applications, a good rule of thumb can be to choose the ratio $W∕\delta t$ much smaller than ${\kappa }_{B}T∕{\tau }_{\text{}\xi \text{}}$, where ${\tau }_{\text{}\xi \text{}}$ is the longest among $\text{}\xi \text{}$'s correlation times: ${\sigma }_{{\xi }_{i}}$ then dictates the resolution of the calculated PMF.

If the metadynamics parameters are chosen correctly, after an equilibration time, ${t}_{e}$, the estimator provided by eq. 34 oscillates on time around the “real" free energy, thereby a better estimate of the latter can be obtained as the time average of the bias potential after ${t}_{e}$ [3031]:

 $A\left(\text{}\xi \text{}\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}-\frac{1}{{t}_{tot}-{t}_{e}}{\int }_{{t}_{e}}^{{t}_{tot}}{V}_{meta}\left(\text{}\xi \text{},t\right)dt$ (35)

where ${t}_{e}$ is the time after which the bias potential grows (approximately) evenly during the simulation and ${t}_{tot}$ is the total simulation time. The free energy calculated according to eq. 35 can thus be obtained averaging on time multiple time-dependent free energy estimates, that can be printed out through the keyword keepFreeEnergyFiles. An alternative is to obtain the free energy profiles by summing the hills added during the simulation; the hills trajectory can be printed out by enabling the option writeHillsTrajectory.

##### 7.4.1 Treatment of the PMF boundaries

In typical scenarios the Gaussian hills of a metadynamics potential are interpolated and summed together onto a grid, which is much more efficient than computing each hill independently at every step (the keyword useGrids is on by default). This numerical approximation typically yields negligible errors in the resulting PMF [1]. However, due to the finite thickness of the Gaussian function, the metadynamics potential would suddenly vanish each time a variable exceeds its grid boundaries.

To avoid such discontinuity the Colvars metadynamics code will keep an explicit copy of each hill that straddles a grid's boundary, and will use it to compute metadynamics forces outside the grid. This measure is taken to protect the accuracy and stability of a metadynamics simulation, except in cases of “natural" boundaries (for example, the $\left[0:180\right]$ interval of an angle colvar) or when the flags hardLowerBoundary and hardUpperBoundary are explicitly set by the user. Unfortunately, processing explicit hills alongside the potential and force grids could easily become inefficient, slowing down the simulation and increasing the state file's size.

In general, it is a good idea to define a repulsive potential to avoid hills from coming too close to the grid's boundaries, for example as a harmonicWalls restraint (see 7.7).

Example: Using harmonic walls to protect the grid's boundaries.

colvar {  name r  distance { ... }  upperBoundary 15.0  width 0.2}metadynamics {  name meta_r  colvars r  hillWeight 0.001  hillWidth 2.0}harmonicWalls {  name wall_r  colvars r  upperWalls 13.0  upperWallConstant 2.0}

In the colvar r, the distance function used has a lowerBoundary automatically set to 0 by default, thus the keyword lowerBoundary itself is not mandatory and hardLowerBoundary is set to yes internally. However, upperBoundary does not have such a “natural" choice of value. The metadynamics potential meta_r will individually process any hill whose center is too close to the upperBoundary, more precisely within fewer grid points than 6 times the Gaussian $\sigma$ parameter plus one. It goes without saying that if the colvar r represents a distance between two freely-moving molecules, it will cross this “threshold" rather frequently.

In this example, where the value of hillWidth ($2\sigma$) amounts to 2 grid points, the threshold is 6+1 = 7 grid points away from upperBoundary. In explicit units, the width of $r$ is ${w}_{r}=$ 0.2 Å, and the threshold is 15.0 - 7$×$0.2 = 13.6 Å.

The wall_r restraint included in the example prevents this: the position of its upperWall is 13 Å, i.e. 3 grid points below the buffer's threshold (13.6 Å). For the chosen value of upperWallConstant, the energy of the wall_r bias at r = ${r}_{upper}$ = 13.6 Å is:

 ${E}^{\ast }=\frac{1}{2}k{\left(\frac{r-{r}_{upper}}{{w}_{r}}\right)}^{2}=\frac{1}{2}2.0{\left(-3\right)}^{2}=9\phantom{\rule{0.33em}{0ex}}kcal∕mol$

which results in a relative probability $\mathrm{exp}⁡\left(-{E}^{\ast }∕{\kappa }_{B}T\right)\simeq$ $3×1{0}^{-7}$ that r crosses the threshold. The probability that r exceeds upperBoundary, which is further away, has also become vanishingly small. At that point, you may want to set hardUpperBoundary to yes for r, and let meta_r know that no special treatment near the grid's boundaries will be needed.

What is the impact of the wall restraint onto the PMF? Not a very complicated one: the PMF reconstructed by metadynamics will simply show a sharp increase in free-energy where the wall potential kicks in (r $>$ 13 Å). You may then choose between using the PMF only up until that point and discard the rest, or subtracting the energy of the harmonicWalls restraint from the PMF itself. Keep in mind, however, that the statistical convergence of metadynamics may be less accurate where the wall potential is strong.

In summary, although it would be simpler to set the wall's position upperWall and the grid's boundary upperBoundary to the same number, the finite width of the Gaussian hills calls for setting the former strictly within the latter.

To enable a metadynamics-based calculation, a metadynamics {...} block must be included in the Colvars configuration file.

By default, metadynamics bias energy and forces will be recorded onto a grid, the parameters of which can be defined within the definition of each colvar, as described in 5.20.

Other required keywords will be specified within the metadynamics block: these are colvars (the names of the variables involved), hillWeight (the weight parameter $W$), and the widths $2\sigma$ of the Gaussian hills in each dimension that can be given either as the single dimensionless parameter hillWidth, or explicitly for each colvar with gaussianSigmas.

• name — same definition as name (biasing and analysis methods)
• colvars — same definition as colvars (biasing and analysis methods)
• outputEnergy — same definition as outputEnergy (biasing and analysis methods)
• outputFreq — same definition as outputFreq (biasing and analysis methods)
• writeTIPMF — same definition as writeTIPMF (biasing and analysis methods)
• writeTISamples — same definition as writeTISamples (biasing and analysis methods)
• stepZeroData — same definition as stepZeroData (biasing and analysis methods)
• hillWeightHeight of each hill (energy unit)
$\left[$ positive decimal, context: metadynamics $\right]$
This option sets the height $W$ of the Gaussian hills that are added during this run. Lower values provide more accurate sampling of the system's degrees of freedom at the price of longer simulation times to complete a PMF calculation based on metadynamics.
• hillWidthWidth $2\sigma$ of a Gaussian hill, measured in number of grid points
$\left[$ positive decimal, context: metadynamics $\right]$
This keyword sets the Gaussian width $2{\sigma }_{{\xi }_{i}}$ for all colvars, expressed in number of grid points, with the grid spacing along each colvar $\xi$ determined by the respective value of width. Values between 1 and 3 are recommended for this option: smaller numbers will fail to adequately interpolate each Gaussian function [1], while larger values may be unable to account for steep free-energy gradients. The values of each half-width ${\sigma }_{{\xi }_{i}}$ in the physical units of ${\xi }_{i}$ are also printed by VMD at initialization time; alternatively, they may be set explicitly via gaussianSigmas.
• gaussianSigmasHalf-widths $\sigma$ of the Gaussian hill (one for each colvar)
$\left[$ space-separated list of decimals, context: metadynamics $\right]$
This option sets the parameters ${\sigma }_{{\xi }_{i}}$ of the Gaussian hills along each colvar ${\xi }_{i}$, expressed in the same unit of ${\xi }_{i}$. No restrictions are placed on each value, but a warning will be printed if useGrids is on and the Gaussian width $2{\sigma }_{{\xi }_{i}}$ is smaller than the corresponding grid spacing, $width\left({\xi }_{i}\right)$. If not given, default values will be computed from the dimensionless number hillWidth.
• newHillFrequencyFrequency of hill creation
Default: 1000 $\left[$ positive integer, context: metadynamics $\right]$
This option sets the number of steps after which a new Gaussian hill is added to the metadynamics potential. The product of this number and the integration time-step defines the parameter $\delta t$ in eq. 33. Higher values provide more accurate statistical sampling, at the price of longer simulation times to complete a PMF calculation. When analyzing data from a previous simulation in VMD, the metadynamics potential does not need to be updated, and it is useful to set this number to 0.

##### 7.4.3 Output files

When interpolating grids are enabled (default behavior), the PMF is written by default every colvarsRestartFrequency steps to the file outputName.pmf in multicolumn text format (4.7.5). The following two options allow to disable or control this behavior and to track statistical convergence:

• writeFreeEnergyFilePeriodically write the PMF for visualization
Default: on $\left[$ boolean, context: metadynamics $\right]$
When useGrids and this option are on, the PMF is written every outputFreq steps.
• keepFreeEnergyFilesKeep all the PMF files
Default: off $\left[$ boolean, context: metadynamics $\right]$
When writeFreeEnergyFile and this option are on, the step number is included in the file name, thus generating a series of PMF files. Activating this option can be useful to follow more closely the convergence of the simulation, by comparing PMFs separated by short times.
• writeHillsTrajectoryWrite a log of new hills
Default: off $\left[$ boolean, context: metadynamics $\right]$
If this option is on, a file containing the Gaussian hills written by the metadynamics bias, with the name:
outputName.colvars.$<$name$>$.hills.traj",
which can be useful to post-process the time series of the Gassian hills. Each line is written every newHillFrequency, regardless of the value of outputFreq. When multipleReplicas is on, its name is changed to:
outputName.colvars.$<$name$>$.$<$replicaID$>$.hills.traj".
The columns of this file are the centers of the hills, ${\xi }_{i}\left({t}^{\prime }\right)$, followed by the half-widths, ${\sigma }_{{\xi }_{i}}$, and the weight, $W$. Note: prior to version 2020-02-24, the full-width $2\sigma$ of the Gaussian was reported in lieu of $\sigma$.

##### 7.4.4 Performance optimization

The following options control the computational cost of metadynamics calculations, but do not affect results. Default values are chosen to minimize such cost with no loss of accuracy.
• useGridsInterpolate the hills with grids
Default: on $\left[$ boolean, context: metadynamics $\right]$
This option discretizes all hills for improved performance, accumulating their energy 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 implemented 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 direction of that colvar.
• rebinGridsRecompute the grids when reading a state file
Default: off $\left[$ boolean, context: metadynamics $\right]$
When restarting from a state file, the grid's parameters (boundaries and widths) saved in the state file override those in the configuration file. Enabling this option forces the grids to match those in the current configuration file.
• keepHillsWrite each individual hill to the state file
Default: off $\left[$ boolean, context: metadynamics $\right]$
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.

The ensemble-biased metadynamics (EBMetaD) approach [32] is designed to reproduce a target probability distribution along selected collective variables. Standard metadynamics can be seen as a special case of EBMetaD with a flat distribution as target. This is achieved by weighing the Gaussian functions used in the metadynamics approach by the inverse of the target probability distribution:

 ${V}_{EBmetaD}\left(\text{}\xi \text{}\left(t\right)\right)\phantom{\rule{0.28em}{0ex}}=\phantom{\rule{0.28em}{0ex}}\sum _{{t}^{\prime }=\delta t,2\delta t,\dots }^{{t}^{\prime } (36)

where ${\rho }_{exp}\left(\text{}\xi \text{}\right)$ is the target probability distribution and ${S}_{\rho }=-\int ⁡{\rho }_{exp}\left(\text{}\xi \text{}\right)\mathrm{log}⁡{\rho }_{exp}\left(\text{}\xi \text{}\right)\phantom{\rule{0.17em}{0ex}}d\text{}\xi \text{}$ its corresponding differential entropy. The method is designed so that during the simulation the resulting distribution of the collective variable $\text{}\xi \text{}$ converges to ${\rho }_{exp}\left(\text{}\xi \text{}\right)$. A practical application of EBMetaD is to reproduce an “experimental" probability distribution, for example the distance distribution between spectroscopic labels inferred from Förster resonance energy transfer (FRET) or double electron-electron resonance (DEER) experiments [32].

The PMF along $\xi$ can be estimated from the bias potential and the target ditribution [32]:

 $A\left(\text{}\xi \text{}\right)\phantom{\rule{0.28em}{0ex}}\simeq \phantom{\rule{0.28em}{0ex}}-{V}_{EBmetaD}\left(\text{}\xi \text{}\right)-{\kappa }_{B}T\mathrm{log}⁡{\rho }_{exp}\left(\text{}\xi \text{}\right)$ (37)

and obtained by enabling writeFreeEnergyFile. Similarly to eq. 35, a more accurate estimate of the free energy can be obtained by averaging (after an equilibration time) multiple time-dependent free energy estimates (see keepFreeEnergyFiles).

The following additional options define the configuration for the ensemble-biased metadynamics approach:

Default: off $\left[$ boolean, context: metadynamics $\right]$
If enabled, this flag activates the ensemble-biased metadynamics as described by Marinelli et al.[32]. The target distribution file, targetdistfile, is then required. The keywords lowerBoundary, upperBoundary and width for the respective variables are also needed to set the binning (grid) of the target distribution file.
• targetDistFileTarget probability distribution file for ensemble-biased metadynamics
$\left[$ multicolumn text file, context: metadynamics $\right]$
This file provides the target probability distribution, ${\rho }_{exp}\left(\text{}\xi \text{}\right)$, reported in eq. 36. The latter distribution must be a tabulated function provided in a multicolumn text format (see 4.7.5). The provided distribution is then normalized.
• ebMetaEquilStepsNumber of equilibration steps for ensemble-biased metadynamics
$\left[$ positive integer, context: metadynamics $\right]$
The EBMetaD approach may introduce large hills in regions with small values of the target probability distribution (eq. 36). This happens, for example, if the probability distribution sampled by a conventional molecular dynamics simulation is significantly different from the target distribution. This may lead to instabilities at the beginning of the simulation related to large biasing forces. In this case, it is useful to introduce an equilibration stage in which the bias potential gradually switches from standard metadynamics (eq. 33) to EBmetaD (eq. 36) as $\lambda {V}_{meta}\left(\text{}\xi \text{}\right)+\left(1-\lambda \right){V}_{EBmetaD}\left(\text{}\xi \text{}\right)$, where $\lambda =\left(ebMetaEquilSteps-step\right)∕ebMetaEquilSteps$ and step is the current simulation step number.
• targetDistMinValMinimum value of the target distribution in reference to its maximum value
$\left[$ positive decimal, context: metadynamics $\right]$
It is useful to set a minimum value of the target probability distribution to avoid values of the latter that are nearly zero, leading to very large hills. This parameter sets the minimum value of the target probability distribution that is expressed as a fraction of its maximum value: minimum value = maximum value X targetDistMinVal. This implies that 0 <targetDistMinVal < 1 and its default value is set to 1/1000000. To avoid divisions by zero (see eq. 36), if targetDistMinVal is set as zero, values of ${\rho }_{exp}$ equal to zero are replaced by the smallest positive value read in the same file.

As with standard metadynamics, multidimensional probability distributions can be targeted using a single metadynamics block using multiple colvars and a multidimensional target distribution file (see 4.7.5). Instead, multiple probability distributions on different variables can be targeted separately in the same simulation by introducing multiple metadynamics blocks with the ebMeta option.

Example: EBmetaD configuration for a single variable.

colvar {  name r   distance {    group1 { atomNumbers 991 992 }    group2 { atomNumbers 1762 1763 }  }  upperBoundary  100.0   width            0.1 }metadynamics {  name              ebmeta  colvars           r  hillWeight        0.01  hillWidth         3.0  ebMeta            on  targetDistFile    targetdist1.dat  ebMetaEquilSteps  500000}

where targetdist1.dat is a text file in “multicolumn" format (4.7.5) with the same width as the variable r (0.1 in this case):

 # 1 # 0.0 0.1 1000 0 0.05 0.0012 0.15 0.0014 … … 99.95 0.0010

Tip: Besides setting a meaningful value for targetDistMinVal, the exploration of unphysically low values of the target distribution (which would lead to very large hills and possibly numerical instabilities) can be also prevented by restricting sampling to a given interval, using e.g. harmonicWalls restraint (7.7).

The following options define the configuration for the “well-tempered" metadynamics approach [33]:
Default: off $\left[$ boolean, context: metadynamics $\right]$
If enabled, this flag causes well-tempered metadynamics as described by Barducci et al.[33] to be performed, rather than standard metadynamics. The parameter biasTemperature is then required. This feature was contributed by Li Li (Luthey-Schulten group, Department of Chemistry, UIUC).
• biasTemperatureTemperature bias for well-tempered metadynamics
$\left[$ positive decimal, context: metadynamics $\right]$
When running metadynamics in the long time limit, collective variable space is sampled to a modified temperature $T+\mathrm{\Delta }T$. In conventional metadynamics, the temperature “boost" $\mathrm{\Delta }T$ would constantly increases with time. Instead, in well-tempered metadynamics $\mathrm{\Delta }T$ must be defined by the user via biasTemperature. The written PMF includes the scaling factor $\left(T+\mathrm{\Delta }T\right)∕\mathrm{\Delta }T$ [33]. A careful choice of $\mathrm{\Delta }T$ determines the sampling and convergence rate, and is hence crucial to the success of a well-tempered metadynamics simulation.

Metadynamics calculations can be performed concurrently by multiple replicas that share a common history. This variant of the method is called multiple-walker metadynamics [34]: the Gaussian hills of all replicas are periodically combined into a single biasing potential, intended to converge to a single PMF.

In the implementation here described [1], replicas communicate through files. This arrangement allows launching the replicas either (1) as a bundle (i.e. a single job in a cluster's queueing system) or (2) as fully independent runs (i.e. as separate jobs for the queueing system). One advantage of the use case (1) is that an identical Colvars configuration can be used for all replicas (otherwise, replicaID needs to be manually set to a different string for each replica). However, the use case (2) is less demanding in terms of high-performance computing resources: a typical scenario would be a computer cluster (including virtual servers from a cloud provider) where not all nodes are connected to each other at high speed, and thus each replica runs on a small group of nodes or a single node.

Whichever way the replicas are started (coupled or not), a shared filesystem is needed so that each replica can read the files created by the others: paths to these files are stored in the shared file replicasRegistry. This file, and those listed in it, are read every replicaUpdateFrequency steps. Each time the Colvars state file is written (for example, colvarsRestartFrequency steps), the file named:
outputName.colvars.name.replicaID.state
is written as well; this file contains only the state of the metadynamics bias, which the other replicas will read in turn. In between the times when this file is modified/replaced, new hills are also temporarily written to the file named:
outputName.colvars.name.replicaID.hills
Both files are only used for communication, and may be deleted after the replica begins writing files with a new outputName.

Example: Multiple-walker metadynamics with file-based communication.

metadynamics {  name mymtd  colvars x  hillWeight 0.001  newHillFrequency 1000  hillWidth 3.0    multipleReplicas       on  replicasRegistry       /shared-folder/mymtd-replicas.txt  replicaUpdateFrequency 50000  # Best if larger than newHillFrequency}

The following are the multiple-walkers related options:

Default: off $\left[$ boolean, context: metadynamics $\right]$
This option turns on multiple-walker communication between replicas.
• replicasRegistryMultiple replicas database file
$\left[$ UNIX filename, context: metadynamics $\right]$
If multipleReplicas is on, this option sets the path to the replicas' shared database file. It is best to use an absolute path (especially when running individual replicas in separate folders).
• replicaUpdateFrequencyHow often hills are shared between replicas
$\left[$ positive integer, context: metadynamics $\right]$
If multipleReplicas is on, this option sets the number of steps after which each replica tries to read the other replicas' files. On a networked file system, it is best to use a number of steps that corresponds to at least a minute of wall time.
• replicaIDSet the identifier for this replica (required only for independent jobs)
Default: replica index (only if MPI is used) $\left[$ string, context: metadynamics $\right]$
If multipleReplicas is on, this option sets a unique identifier for this replicas. Specifying this option is thus only required when the replicas are launched as independent computations: when the replicas share a common parallel communication framework (i.e. they are all launched together as a single message-passing computation via MPI) the default value of this keyword is the replica's numeric index (zero-based).
• writePartialFreeEnergyFilePeriodically write the contribution to the PMF from this replica
Default: off $\left[$ boolean, context: metadynamics $\right]$
If multipleReplicas is on, enabling this option produces an additional file outputName.partial.pmf, which can be useful to monitor the contribution of each replica to the total PMF (which is written to the file outputName.pmf). Note: the name of this file is chosen for consistency and convenience, but its content is not a PMF and it is not expected to converge, even if the total PMF does.

#### 7.5 Harmonic restraints

The harmonic biasing method may be used to enforce fixed or moving restraints, including variants of Steered and Targeted MD. Within energy minimization runs, it allows for restrained minimization, e.g. to calculate relaxed potential energy surfaces. In the context of the Colvars module, harmonic potentials are meant according to their textbook definition:

 $V\left(\xi \right)=\frac{1}{2}k{\left(\frac{\xi -{\xi }_{0}}{{w}_{\xi }}\right)}^{2}$ (38)

There are two noteworthy aspects of this expression:

1. Because the standard coefficient of $1∕2$ of the harmonic potential is included, this expression differs from harmonic bond and angle potentials historically used in common force fields, where the factor was typically omitted resulting in a non-standard definition of the force constant.
2. The variable $\xi$ is not only centered at ${\xi }_{0}$, but is also scaled by its characteristic length scale ${w}_{\xi }$ (keyword width). The resulting dimensionless variable $z=\left(\xi -{\xi }_{0}\right)∕{w}_{\xi }$ is typically easier to treat numerically: for example, when the forces typically experienced by $\xi$ are much smaller than $k∕{w}_{\xi }$ and $k$ is chosen equal to ${\kappa }_{B}T$ (thermal energy), the resulting probability distribution of $z$ is approximately a Gaussian with mean equal to 0 and standard deviation equal to 1.

This property can be used for setting the force constant in umbrella-sampling ensemble runs: if the restraint centers are chosen in increments of ${w}_{\xi }$, the resulting distributions of $\xi$ are most often optimally overlapped. In regions where the underlying free-energy landscape induces highly skewed distributions of $\xi$, additional windows may be added as needed, with spacings finer than ${w}_{\xi }$.

Beyond one dimension, the use of a scaled harmonic potential also allows a standard definition of a multi-dimensional restraint with a unified force constant:

 $V\left({\xi }_{1},\dots ⁡,{\xi }_{M}\right)=\frac{1}{2}k\sum _{i=1}^{M}{\left(\frac{{\xi }_{i}-{\xi }_{0}}{{w}_{\xi }}\right)}^{2}$ (39)

If one-dimensional or homogeneous multi-dimensional restraints are defined, and there are no other uses for the parameter ${w}_{\xi }$, width can be left at its default value of $1$.

A harmonic restraint is defined by a harmonic {...} block, which may contain the following keywords:

• name — same definition as name (biasing and analysis methods)
• colvars — same definition as colvars (biasing and analysis methods)
• outputEnergy — same definition as outputEnergy (biasing and analysis methods)
• writeTIPMF — same definition as writeTIPMF (biasing and analysis methods)
• writeTISamples — same definition as writeTISamples (biasing and analysis methods)
• stepZeroData — same definition as stepZeroData (biasing and analysis methods)
• forceConstantScaled force constant (energy unit)
Default: 1.0 $\left[$ positive decimal, context: harmonic $\right]$
This option defines a scaled force constant $k$ for the harmonic potential (eq. 39). To ensure consistency for multidimensional restraints, it is divided internally by the square of the specific width of each variable (which is 1 by default). This makes all values effectively dimensionless and of commensurate size. For instance, if this force constant is set to the thermal energy ${\kappa }_{B}T$ (equal to $RT$ if molar units are used), then the amplitude of the thermal fluctuations of each variable $\xi$ will be on the order of its width, ${w}_{\xi }$. This can be used to estimate the optimal spacing of umbrella-sampling windows (under the assumption that the force constant is larger than the curvature of the underlying free energy). The values of the actual force constants $k∕{w}_{\xi }^{2}$ are always printed when the restraint is defined.
• centersInitial harmonic restraint centers
$\left[$ space-separated list of colvar values, context: harmonic $\right]$
The centers (equilibrium values) of the restraint, ${\xi }_{0}$, are entered here. The number of values must be the number of requested colvars. Each value is a decimal number if the corresponding colvar returns a scalar, a “(x, y, z)" triplet if it returns a unit vector or a vector, and a “(q0, q1, q2, q3)" quadruplet if it returns a rotational quaternion. If a colvar has periodicities or symmetries, its closest image to the restraint center is considered when calculating the harmonic potential.

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.

##### 7.5.1 Moving restraints: steered molecular dynamics

The following options allow to change gradually the centers of the harmonic restraints during a simulations. When the centers are changed continuously, a steered MD in a collective variable space is carried out.

• targetCentersSteer the restraint centers towards these targets
$\left[$ space-separated list of colvar values, context: harmonic $\right]$
When defined, the current centers will be moved towards these values during the simulation. By default, the centers are moved over a total of targetNumSteps steps by a linear interpolation, in the spirit of Steered MD. If targetNumStages is set to a nonzero value, the change is performed in discrete stages, lasting targetNumSteps steps each. This second mode may be used to sample successive windows in the context of an Umbrella Sampling simulation. When continuing a simulation 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.
• targetNumStepsNumber of steps for steering
$\left[$ positive integer, context: harmonic $\right]$
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.
• outputCentersWrite the current centers to the trajectory file
Default: off $\left[$ boolean, context: harmonic $\right]$
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.

##### 7.5.2 Moving restraints: umbrella sampling

The centers of the harmonic restraints can also be changed in discrete stages: in this cases a one-dimensional umbrella sampling simulation is performed. The sampling windows in simulation are calculated in sequence. The colvars trajectory file may then be used both to evaluate the correlation times between consecutive windows, and to calculate the frequency distribution of the colvar of interest in each window. Furthermore, frequency distributions on a predefined grid can be automatically obtained by using the histogram bias (see 7.10).

To activate an umbrella sampling simulation, the same keywords as in the previous section can be used, with the addition of the following:

• targetNumStagesNumber of stages for steering
Default: 0 $\left[$ non-negative integer, context: harmonic $\right]$
If non-zero, sets the number of stages in which the restraint centers or force constant are changed to their target values. If zero, the change is continuous. Each stage lasts targetNumSteps MD steps. To sample both ends of the transformation, the simulation should be run for targetNumSteps$×$ (targetNumStages + 1).

##### 7.5.3 Changing force constant

The force constant of the harmonic restraint may also be changed to equilibrate [35].

• targetForceConstantChange the force constant towards this value
$\left[$ positive decimal, context: harmonic $\right]$
When defined, the current forceConstant will be moved towards this value during the simulation. Time evolution of the force constant is dictated by the lambdaExponent parameter (see below). By default, the force constant is changed smoothly over a total of targetNumSteps steps. This is useful to introduce or remove restraints in a progressive manner. If targetNumStages is set to a nonzero value, the change is performed in discrete stages, lasting targetNumSteps steps each. This second mode may be used to compute the conformational free energy change associated with the restraint, within the FEP or TI formalisms. For convenience, the code provides an estimate of the free energy derivative for use in TI, with the format:
colvars: Lambda= ***.** dA/dLambda= ***.**
A more complete free energy calculation (particularly with regard to convergence analysis), while not handled by the Colvars module, can be performed by post-processing the colvars trajectory, if colvarsTrajFrequency is set to a suitably small value. It should be noted, however, that restraint free energy calculations may be handled more efficiently by an indirect route, through the determination of a PMF for the restrained coordinate.[35]
• lambdaExponentExponent in the time-dependence of the force constant
Default: 1.0 $\left[$ decimal equal to or greater than 1.0, context: harmonic $\right]$
Sets the exponent, $\alpha$, in the function used to vary the force constant as a function of time. The force is varied according to a coupling parameter $\lambda$, raised to the power $\alpha$: ${k}_{\lambda }={k}_{0}+{\lambda }^{\alpha }\left({k}_{1}-{k}_{0}\right)$, where ${k}_{0}$, ${k}_{\lambda }$, and ${k}_{1}$ are the initial, current, and final values of the force constant. The parameter $\lambda$ evolves linearly from 0 to 1, either smoothly, or in targetNumStages equally spaced discrete stages, or according to an arbitrary schedule set with lambdaSchedule. When the initial value of the force constant is zero, an exponent greater than 1.0 distributes the effects of introducing the restraint more smoothly over time than a linear dependence, and ensures that there is no singularity in the derivative of the restraint free energy with respect to lambda. A value of 4 has been found to give good results in some tests. To remove the restraint over time rather than introduce it, use the decoupling option.
• decouplingPerform a restraint decoupling transformation
Default: off $\left[$ boolean, context: harmonic $\right]$
When this option is enabled, the restraint is decoupled by changing the force constant from forceConstant to 0.0 over the course of the simulation, as specified by targetNumSteps and, optionally, targetNumStages. The force constant is then varied as: ${k}_{\lambda }={\left(1-\lambda \right)}^{\alpha }k$, where $\alpha$ is the value of lambdaExponent. Setting lambdaExponent to a value greater than 1 (e.g. 4) ensures a smoother dependence of the energy on $\lambda$ around ${k}_{\lambda }=0$.
• targetEquilStepsNumber of steps discarded from TI estimate
$\left[$ positive integer, context: harmonic $\right]$
Defines the number of steps within each stage that are considered equilibration and discarded from the restraint free energy derivative estimate reported reported in the output.
• lambdaScheduleSchedule of lambda-points for changing force constant
$\left[$ list of real numbers between 0 and 1, context: harmonic $\right]$
If specified together with targetForceConstant, sets the sequence of discrete $\lambda$ values that will be used for different stages.

#### 7.6 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:

• outputAccumulatedWorkWrite the accumulated work of the changing restraint to the Colvars trajectory file
Default: off $\left[$ boolean, context: harmonic $\right]$
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.

#### 7.7 Harmonic wall restraints

The harmonicWalls {...} bias is closely related to the harmonic bias (see 7.5), with the following two differences: (i) instead of a center a lower wall and/or an upper wall are defined, outside of which the bias implements a half-harmonic potential;

 $V\left(\xi \right)=\left\{\begin{array}{cc}\frac{1}{2}k{\left(\frac{\xi -{\xi }_{upper}}{{w}_{\xi }}\right)}^{2}\hfill & if\phantom{\rule{0.33em}{0ex}}\xi >{\xi }_{upper}\hfill \\ 0\hfill & if\phantom{\rule{0.33em}{0ex}}{\xi }_{lower}\le \xi \le {\xi }_{upper}\hfill \\ \frac{1}{2}k{\left(\frac{\xi -{\xi }_{lower}}{{w}_{\xi }}\right)}^{2}\hfill & if\phantom{\rule{0.33em}{0ex}}\xi <{\xi }_{lower}\hfill \end{array}$ (40)

where ${\xi }_{lower}$ and ${\xi }_{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. Those keywords are deprecated.

The harmonicWalls bias implements the following options:

• name — same definition as name (biasing and analysis methods)
• colvars — same definition as colvars (biasing and analysis methods)
• outputEnergy — same definition as outputEnergy (biasing and analysis methods)
• writeTIPMF — same definition as writeTIPMF (biasing and analysis methods)
• writeTISamples — same definition as writeTISamples (biasing and analysis methods)
• stepZeroData — same definition as stepZeroData (biasing and analysis methods)
• lowerWallsPosition of the lower wall(s)
$\left[$ Space-separated list of decimals, context: colvar $\right]$
Defines the values ${\xi }_{lower}$ below which a confining restraint on the colvar is applied to each colvar $\xi$.
• upperWallsPosition of the upper wall(s)
$\left[$ Space-separated list of decimals, context: colvar $\right]$
Defines the values ${\xi }_{upper}$ above which a confining restraint on the colvar is applied to each colvar $\xi$.
• forceConstant — same definition as forceConstant (Harmonic restraints)
• lowerWallConstantForce constant for the lower wall
Default: forceConstant $\left[$ positive decimal, context: harmonicWalls $\right]$
When both sets of walls are defined (lower and upper), this keyword allows setting different force constants for them. As with forceConstant, the specified constant is divided internally by the square of the specific width of each variable (see also the equivalent keyword for the harmonic restraint, forceConstant). The force constant reported in the output as “$k$", and used in the change of force constant scheme, is the geometric mean of upperWallConstant and upperWallConstant.
• upperWallConstant — analogous to lowerWallConstant
• targetForceConstant — same definition as targetForceConstant (harmonic restraints)
• targetForceConstantChange the force constant(s) towards this value
$\left[$ positive decimal, context: harmonicWalls $\right]$
This keyword allows changing either one or both of the wall force constants over time. In the case that lowerWallConstant and upperWallConstant have the same value, the behavior of this keyword is identical to the corresponding keyword in the harmonic restraint; otherwise, the change schedule is applied to the geometric mean of the two constant. When only one set of walls is defined (lowerWall or upperWalls), only the respective force constant is changed. Note: if only one of the two force constants is meant to change over time, it is possible to use two instances of harmonicWalls, and apply the changing schedule only to one of them.
• targetNumSteps — same definition as targetNumSteps (harmonic restraints)
• lambdaExponent — same definition as lambdaExponent (harmonic restraints)
• targetEquilSteps — same definition as targetEquilSteps (harmonic restraints)
• targetNumStages — same definition as targetNumStages (harmonic restraints)
• lambdaSchedule — same definition as lambdaSchedule (harmonic restraints)
• outputAccumulatedWork — same definition as outputAccumulatedWork (harmonic restraints)
• bypassExtendedLagrangianApply bias to actual colvars, bypassing extended coordinates
Default: on $\left[$ boolean, context: harmonicWalls $\right]$
This option behaves as bypassExtendedLagrangian for other biases, but it defaults to on, unlike in the general case. Thus, by default, the harmonicWalls bias applies to the actual colvars, so that the distribution of the colvar between the walls is unaffected by the bias, which then applies a flat-bottom potential as a function of the colvar value. This bias will affect the extended coordinate distribution near the walls. If bypassExtendedLagrangian is disabled, harmonicWalls applies a flat-bottom potential as a function of the extended coordinate. Conversely, this bias will then modify the distribution of the actual colvar value near the walls.

Example 1: harmonic walls for one variable with two different force constants.

harmonicWalls {  name  mywalls  colvars    dist  lowerWalls  22.0   upperWalls  38.0   lowerWallConstant  2.0   upperWallConstant 10.0 }

Example 2: harmonic walls for two variables with a single force constant.

harmonicWalls {  name  mywalls  colvars       phi    psi  lowerWalls -180.0    0.0  upperWalls    0.0  180.0  forceConstant 5.0 }

#### 7.8 Linear restraints

The linear keyword defines a linear potential:

 $V\left(\xi \right)=k\left(\frac{\xi -{\xi }_{0}}{{w}_{\xi }}\right)$ (41)

whose force is simply given by the constant $k∕{w}_{\xi }$ itself:

 $f\left(\xi \right)=k∕{w}_{\xi }$ (42)

This type of bias is therefore most useful in situations where a constant force is desired. As all other restraints, it can be defined on one or more CVs, with each contribution added to the total potential and the parameters ${w}_{\xi }$ determining the relative magnitude for each.

Example: A possible use case of the linear bias is mimicking a constant electric field acting on a specific particle, or the center of mass of many particles. In the following example, a linear restraint is applied on a distanceZ variable (5.3.2), generating a constant force parallel to the Z axis of magnitude 5 energy unit/length unit:

colvar {  name z  distanceZ {    ...  }}linear {  colvars z  forceConstant 5.0  centers 0.0}

Another useful application of a linear restraint is to enforce experimental constraints in a simulation, with a lower non-equilibrium work than e.g. harmonic restraints [36]. There is generally a unique strength of bias for each CV center, which means you must know the bias force constant specifically for the center of the CV. This force constant may be found by using experiment directed simulation described in section 7.9.

• name — same definition as name (biasing and analysis methods)
• colvars — same definition as colvars (biasing and analysis methods)
• outputEnergy — same definition as outputEnergy (biasing and analysis methods)
• forceConstantScaled force constant (energy unit)
Default: 1.0 $\left[$ Decimal, context: linear $\right]$
This option defines a scaled force constant $k$ for the linear bias. To ensure consistency for multidimensional restraints, it is divided internally by the specific width of each variable (which is 1 by default), so that all variables are effectively dimensionless and of commensurate size. The values of $k∕{w}_{\xi }$ are always printed when the restraint is defined.
• centersInitial linear restraint centers
$\left[$ space-separated list of colvar values, context: linear $\right]$
These are analogous to the centers keyword of the harmonic restraint. Although they do not affect dynamics, they are here necessary to ensure a well-defined energy for the linear bias.
• writeTIPMF — same definition as writeTIPMF (biasing and analysis methods)
• writeTISamples — same definition as writeTISamples (biasing and analysis methods)
• targetForceConstant — same definition as targetForceConstant (Harmonic restraints)
• targetNumSteps — same definition as targetNumSteps (Harmonic restraints)
• lambdaExponent — same definition as lambdaExponent (Harmonic restraints)
• targetEquilSteps — same definition as targetEquilSteps (Harmonic restraints)
• targetNumStages — same definition as targetNumStages (Harmonic restraints)
• lambdaSchedule — same definition as lambdaSchedule (Harmonic restraints)
• outputAccumulatedWork — same definition as outputAccumulatedWork (Harmonic restraints)

#### 7.9 Adaptive Linear Bias/Experiment Directed Simulation

Experiment directed simulation applies a linear bias with a changing force constant. Please cite White and Voth [37] when using this feature. As opposed to that reference, the force constant here is scaled by the width corresponding to the biased colvar. In White and Voth, each force constant is scaled by the colvars set center. The bias converges to a linear bias, after which it will be the minimal possible bias. You may also stop the simulation, take the median of the force constants (ForceConst) found in the colvars trajectory file, and then apply a linear bias with that constant. All the notes about units described in sections 7.8 and 7.5 apply here as well. This is not a valid simulation of any particular statistical ensemble and is only an optimization algorithm until the bias has converged.

• name — same definition as name (biasing and analysis methods)
• colvars — same definition as colvars (biasing and analysis methods)
• centersCollective variable centers
$\left[$ space-separated list of colvar values, context: alb $\right]$
The desired center (equilibrium values) which will be sought during the adaptive linear biasing. The number of values must be the number of requested colvars. Each value is a decimal number if the corresponding colvar returns a scalar, a “(x, y, z)" triplet if it returns a unit vector or a vector, and a “q0, q1, q2, q3)" quadruplet if it returns a rotational quaternion. If a colvar has periodicities or symmetries, its closest image to the restraint center is considered when calculating the linear potential.
$\left[$ An integer, context: alb $\right]$
This is, $N$, the number of simulation steps to use for each update to the bias. This determines how long the system requires to equilibrate after a change in force constant ($N∕2$), how long statistics are collected for an iteration ($N∕2$), and how quickly energy is added to the system (at most, $A∕2N$, where $A$ is the forceRange). Until the force constant has converged, the method as described is an optimization procedure and not an integration of a particular statistical ensemble. It is important that each step should be uncorrelated from the last so that iterations are independent. Therefore, $N$ should be at least twice the autocorrelation time of the collective variable. The system should also be able to dissipate energy as fast as $N∕2$, which can be done by adjusting thermostat parameters. Practically, $N$ has been tested successfully at significantly shorter than the autocorrelation time of the collective variables being biased and still converge correctly.
• forceRangeThe expected range of the force constant in units of energy
Default: 3 ${k}_{b}T$ $\left[$ A space-separated list of decimal numbers, context: alb $\right]$
This is largest magnitude of the force constant which one expects. If this parameter is too low, the simulation will not converge. If it is too high the simulation will waste time exploring values that are too large. A value of 3 ${k}_{b}T$ has worked well in the systems presented as a first choice. This parameter is dynamically adjusted over the course of a simulation. The benefit is that a bad guess for the forceRange can be corrected. However, this can lead to large amounts of energy being added over time to the system. To prevent this dynamic update, add hardForceRange yes as a parameter
• rateMaxThe maximum rate of change of force constant
$\left[$ A list of space-separated real numbers, context: alb $\right]$
This optional parameter controls how much energy is added to the system from this bias. Tuning this separately from the updateFrequency and forceRange can allow for large bias changes but with a low rateMax prevents large energy changes that can lead to instability in the simulation.

#### 7.10 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. Defining such a histogram is generally useful for analysis purposes, but it has no effect on the simulation.

Example 1: the two-dimensional histogram of a distance and an angle can be generated using the configuration below. The histogram code requires that each variable is a scalar number that is confined within a pre-defined interval. The interval's boundaries may be specified by hand (e.g. through lowerBoundary and upperBoundary in the variable definition), or auto-detected based on the type of function. In this example, the lower boundary for the distance variable “r" is automatically set to zero, and interval for the three-body angle “theta" is ${0}^{\circ }$ and $18{0}^{\circ }$: however, that an upper boundary for the distance “r" still needs to be specified manually. The grid spacings for the two variables are $0.2$ length unitand $3.{0}^{\circ }$, respectively.

colvar {  name r  width 0.2  upperBoundary 20.0  distance { ... }}colvar {  name theta  width 3.0  dihedral { ... }}histogram {  name hist2d  colvars r theta}

Example 2: This example is similar to the previous one, but with the important difference that the parameters for the histogram's grid are defined explicitly for this histogram instance. Therefore, this histogram's grid may differ from the one defined from parameters embedded in the colvar { ... } block (for example, narrower intervals and finer grid spacings may be selected).

colvar {  name r  upperBoundary 20.0  distance { ... }}colvar {  name theta  dihedral { ... }}histogram {  name hist2d  colvars r theta  histogramGrid {    widths  0.1 1.0    lowerBoundaries   2.0 30.0    upperBoundaries  10.0 90.0  }}

The standard keywords below are used to control the histogram's computation and to select the variables that are sampled. See also 7.10.1 for keywords used to define the grid, 7.10.2 for output parameters and 7.10.3 for more advanced keywords.

• name — same definition as name (biasing and analysis methods)
• colvars — same definition as colvars (biasing and analysis methods)
• stepZeroData — same definition as stepZeroData (biasing and analysis methods)

##### 7.10.1 Defining grids for multidimensional histograms

Grid parameters for the histogram may be provided at the level of the individual variables, or via a dedicated configuration block histogramGrid { …} inside the configuration of this histogram. The options supported inside this block are:

• lowerBoundariesLower boundaries of the grid
$\left[$ list of space-separated decimals, context: histogramGrid $\right]$
This option defines the lower boundaries of the grid, overriding any values defined by the lowerBoundary keyword of each colvar. Note that when gatherVectorColvars is on, each vector variable is automatically treated as a scalar, and a single value should be provided for it.
• upperBoundaries — analogous to lowerBoundaries
• widths — analogous to lowerBoundaries

##### 7.10.2 Output options for multi-dimensional histograms

The accumulated histogram is written in the Colvars state file, allowing for its accumulation across continued runs. Additionally, the following files are written depending on the histogram's dimensionality:

• outputFreq — same definition as outputFreq (biasing and analysis methods)
• outputFileWrite the histogram to a file
Default: outputName.$<$name$>$.dat $\left[$ UNIX filename, context: histogram $\right]$
Name of the file containing histogram data (multicolumn format, see 4.7.5), which is written every outputFreq steps. If outputFile is set to none, the file is not written.
• outputFileDXWrite the histogram to a file
Default: outputName.$<$name$>$.dx $\left[$ UNIX filename, context: histogram $\right]$
Name of the file containing histogram data (OpenDX format), which is written every outputFreq steps. For the special case of 3 variables, VMD may be used to visualize this file. This file is written by default if the dimension is 3 or more (you cannot visualize it easily for dimensions 4 and above, but the DX format is still more compact than the multicolumn format). If outputFileDX is set to none, the file is not written.

##### 7.10.3 Histogramming vector variables

• gatherVectorColvarsTreat vector variables as multiple observations of a scalar variable?
Default: off $\left[$ UNIX filename, context: histogram $\right]$
When this is set to on, the components of a multi-dimensional colvar (e.g. one based on cartesian, distancePairs, or a vector of scalar numbers given by scriptedFunction) are treated as multiple observations of a scalar variable. This results in the histogram being accumulated multiple times for each simulation step or iteration of cv update). When multiple vector variables are included in histogram, these must have the same length because their components are accumulated together. For example, if $\xi$, $\lambda$ and $\tau$ are three variables of dimensions 5, 5 and 1, respectively, for each iteration 5 triplets $\left({\xi }_{i},{\lambda }_{i},\tau \right)$ ($i=1,\dots ⁡5$) are accumulated into a 3-dimensional histogram.
• weightsRelative contributions of each vector component to the histogram
Default: all weights equal to 1 $\left[$ list of space-separated decimals, context: histogram $\right]$

#### 7.13 Performance of scripted biases

If concurrent computation over multiple threads is available (this is indicated by the message “SMP parallelism is available." printed at initialization time), it is useful to take advantage of the scripting interface to combine many components, all computed in parallel, into a single variable.

The default SMP schedule is the following:

1. distribute the computation of all components across available threads;
2. on a single thread, collect the results of multi-component variables using polynomial combinations (see 5.17), or custom functions (see 5.18), or scripted functions (see 5.19);
3. distribute the computation of all biases across available threads;
4. compute on a single thread any scripted biases implemented via the keyword scriptedColvarForces.
5. communicate on a single thread forces to VMD.

The following options allow to fine-tune this schedule:

• scriptingAfterBiasesScripted colvar forces need updated biases?
Default: on $\left[$ boolean, context: global $\right]$
This flag specifies that the calc_colvar_forces procedure (last step in the list above) is executed only after all biases have been updated (next-to-last step) For example, this allows using the energy of a restraint bias, or the force applied on a colvar, to calculate additional scripted forces, such as boundary constraints. When this flag is set to off, it is assumed that only the values of the variables (but not the energy of the biases or applied forces) will be used by calc_colvar_forces: this can be used to schedule the calculation of scripted forces and biases concurrently to increase performance.

### 8 Tcl command-line interface: list of commands

This section lists all the commands used in VMD to control the behavior of the Colvars module from within a run script.

#### 8.1 Commands to manage the Colvars module

cv addenergy <E>     Add an energy to the MD engine (no effect in VMD)     Parameters     E : float - Amount of energy to add

cv config <conf>     Read configuration from the given string     Parameters     conf : string - Configuration string

cv configfile <conf_file>     Read configuration from a file     Parameters     conf_file : string - Path to configuration file

cv delete     Delete this Colvars module instance (VMD only)

cv featurereport     Return a summary of Colvars features used so far and their citations     Returns     report : string - Feature report and citations

cv frame [frame]     Get or set current frame number (VMD only)     Parameters     frame : integer - Frame number (optional)     Returns     frame : integer - Frame number

cv getatomappliedforces     Get the list of forces applied by Colvars to atoms     Returns     forces : array of arrays of floats - Atomic forces

cv getatomappliedforcesmax     Get the maximum norm of forces applied by Colvars to atoms     Returns     force : float - Maximum atomic force

cv getatomappliedforcesmaxid     Get the atom ID with the largest applied force     Returns     id : int - ID of the atom with the maximum atomic force

cv getatomappliedforcesrms     Get the root-mean-square norm of forces applied by Colvars to atoms     Returns     force : float - RMS atomic force

cv resetatomappliedforces     Reset forces applied by Colvars to atoms

cv getatomids     Get the list of indices of atoms used in Colvars     Returns     indices : array of ints - Atom indices

cv getatomcharges     Get the list of charges of atoms used in Colvars     Returns     charges : array of floats - Atomic charges

cv getatommasses     Get the list of masses of atoms used in Colvars     Returns     masses : array of floats - Atomic masses

cv getatompositions     Get the list of cached positions of atoms used in Colvars     Returns     positions : array of arrays of floats - Atomic positions

cv getatomtotalforces     Get the list of cached total forces of atoms used in Colvars     Returns     forces : array of arrays of floats - Atomic total foces

cv getconfig     Get the module's configuration string read so far     Returns     conf : string - Current configuration string

cv getenergy     Get the current Colvars energy     Returns     E : float - Amount of energy (internal units)

cv getnumactiveatomgroups     Get the number of atom groups that currently have positive ref counts     Returns     count : integer - Total number of atom groups

cv getnumactiveatoms     Get the number of atoms that currently have positive ref counts     Returns     count : integer - Total number of atoms

cv getnumatoms     Get the number of requested atoms, including those not in use now     Returns     count : integer - Total number of atoms

cv getstepabsolute     Get the current step number of the simulation (including restarts)     Returns     step : int - Absolute step number

cv getsteprelative     Get the current step number from the start of this job     Returns     step : int - Relative step number

cv help [command]     Get the help string of the Colvars scripting interface     Parameters     command : string - Get the help string of this specific command (optional)
Returns     help : string - Help string 

cv languageversion     Get the C++ language version number     Returns     version : string - C++ language version

cv list [param]     Return a list of all variables or biases     Parameters     param : string - "colvars" or "biases"; default is "colvars" (optional)     Returns     list : sequence of strings - List of elements

cv listcommands     Get the list of script functions, prefixed with "cv_", "colvar_" or "bias_"
Returns     list : sequence of strings - List of commands 

cv listindexfiles     Get a list of the index files loaded in this session     Returns     list : sequence of strings - List of index file names

cv listinputfiles     Get a list of all input/configuration files loaded in this session     Returns     list : sequence of strings - List of file names

cv load <prefix>     Load data from a state file into all matching colvars and biases     Parameters     prefix : string - Path to existing state file or input prefix

cv loadfromstring <buffer>     Load state data from a string into all matching colvars and biases     Parameters     buffer : string - String buffer containing the state information

cv molid [molid]     Get or set the molecule ID on which Colvars is defined (VMD only)     Parameters     molid : integer - New molecule ID; -1 means undefined (optional)     Returns     molid : integer - Current molecule ID

cv printframe     Return the values that would be written to colvars.traj     Returns     values : string - The values

cv printframelabels     Return the labels that would be written to colvars.traj     Returns     Labels : string - The labels

cv reset     Delete all internal configuration

cv resetindexgroups     Clear the index groups loaded so far, allowing to replace them

cv save <prefix>     Change the prefix of all output files and save them     Parameters     prefix : string - Output prefix with trailing ".colvars.state" gets removed)


cv savetostring     Write the Colvars state to a string and return it     Returns     state : string - The saved state

cv targettemperature [T]     Get/set target temperature, overriding internally what the MD engine reports
Parameters     T : float - New target temperature in K (internal use) (optional)     Returns     T : float - Current target temperature in K 

cv timestep [dt]     Get/set integration timestep, overriding internally what the MD engine reports
Parameters     dt : float - New integration timestep in MD engine units (optional)     Returns     dt : float - Current integration timestep in MD engine units 

cv units [units]     Get or set the current Colvars unit system     Parameters     units : string - The new unit system (optional)     Returns     units : string - The current unit system

cv update     Recalculate colvars and biases

cv version     Get the Colvars Module version string     Returns     version : string - Colvars version

#### 8.2 Commands to manage individual collective variables

cv colvar name addforce <force>     Apply the given force onto this colvar (no effects outside run)     Parameters     force : float or array - Applied force; must match colvar dimensionality     Returns     force : float or array - Applied force; matches colvar dimensionality

cv colvar name communicateforces     Communicate bias forces from this colvar to atoms

cv colvar name cvcflags <flags>     Enable or disable individual components by setting their active flags     Parameters     flags : integer array - Zero/nonzero value disables/enables the CVC

cv colvar name delete     Delete this colvar, along with all biases that depend on it

cv colvar name get <feature>     Get the value of the given feature for this colvar     Parameters     feature : string - Name of the feature     Returns     state : 1/0 - State of the given feature

cv colvar name getappliedforce     Return the total of the forces applied to this colvar     Returns     force : float - Applied force; matches the colvar dimensionality

cv colvar name resetbiasforce     Return the total of the forces applied to this colvar

cv colvar name getatomgroups     Return the atom indices used by this colvar as a list of lists     Returns     groups : array of arrays of ints - Atom indices

cv colvar name getatomids     Return the list of atom indices used by this colvar     Returns     indices : array of ints - Atom indices

cv colvar name getconfig     Return the configuration string of this colvar     Returns     conf : string - Current configuration string

cv colvar name getgradients     Return the atomic gradients of this colvar     Returns     gradients : array of arrays of floats - Atomic gradients

cv colvar name gettotalforce     Return the sum of internal and external forces to this colvar     Returns     force : float - Total force; matches the colvar dimensionality

cv colvar name getvolmapids     Return the list of volumetric map indices used by this colvar

cv colvar name help [command]     Get a help summary or the help string of one colvar subcommand     Parameters     command : string - Get the help string of this specific command (optional)
Returns     help : string - Help string 

cv colvar name modifycvcs <confs>     Modify configuration of individual components by passing string arguments
Parameters     confs : sequence of strings - New configurations; empty strings are skipped


cv colvar name run_ave     Get the current running average of the value of this colvar     Returns     value : float or array - Averaged value; matches the colvar dimensionality


cv colvar name set <feature> <value>     Set the given feature of this colvar to a new value     Parameters     feature : string - Name of the feature     value : string - String representation of the new feature value

cv colvar name state     Print a string representation of the feature state of this colvar     Returns     state : string - The feature state

cv colvar name type     Get the type description of this colvar     Returns     type : string - Type description

cv colvar name update     Recompute this colvar and return its up-to-date value     Returns     value : float or array - Current value; matches the colvar dimensionality


cv colvar name value     Get the current value of this colvar     Returns     value : float or array - Current value; matches the colvar dimensionality


cv colvar name width     Get the width of this colvar     Returns     width : float - Value of the width

#### 8.3 Commands to manage individual biases

cv bias name bin     Get the current grid bin index (flattened if more than 1d)     Returns     bin : integer - Bin index

cv bias name bincount [index]     Get the number of samples at the given grid bin (1D ABF only for now)     Parameters     index : integer - Grid index; defaults to current bin (optional)     Returns     samples : integer - Number of samples

cv bias name local_sample_count [radius]     Get the number of samples around the current binsamples : integer - Number of samples
Parameters     radius : integer - Sum over radius bins around current bin (optional) 

cv bias name binnum     Get the total number of grid points of this bias (1D ABF only for now)     Returns     Bins : integer - Number of grid points

cv bias name delete     Delete this bias

cv bias name energy     Get the current energy of this bias     Returns     E : float - Energy value

cv bias name get <feature>     Get the value of the given feature for this bias     Parameters     feature : string - Name of the feature     Returns     state : 1/0 - State of the given feature

cv bias name getconfig     Return the configuration string of this bias     Returns     conf : string - Current configuration string

cv bias name help [command]     Get a help summary or the help string of one bias subcommand     Parameters     command : string - Get the help string of this specific command (optional)
Returns     help : string - Help string 

cv bias name load <prefix>     Load data into this bias     Parameters     prefix : string - Read from a file with this name or prefix

cv bias name loadfromstring <buffer>     Load state data into this bias from a string     Parameters     buffer : string - String buffer containing the state information

cv bias name save <prefix>     Save data from this bias into a file with the given prefix     Parameters     prefix : string - Prefix for the state file of this bias

cv bias name savetostring     Save data from this bias into a string and return it     Returns     state : string - The bias state

cv bias name set <feature> <value>     Set the given feature of this bias to a new value     Parameters     feature : string - Name of the feature     value : string - String representation of the new feature value

cv bias name share     Share bias information with other replicas (multiple-walker scheme)

cv bias name state     Print a string representation of the feature state of this bias     Returns     state : string - String representation of the bias features

cv bias name type     Print the type of this bias object     Returns     type : string - Type of this bias object (e.g. metadynamics)

cv bias name update     Recompute this bias and return its up-to-date energy     Returns     E : float - Energy value

### 9 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.

• Colvars version 2016-06-09 or later (VMD version 1.9.3 or later).
The legacy keyword refPositionsGroup has been renamed fittingGroup for clarity (the legacy version is still supported).
• Colvars version 2016-08-10 or later (VMD version 1.9.3 or later).
“System forces" have been replaced by “total forces" (see for example outputTotalForce). See the following page for more information:
• Colvars version 2017-01-09 or later (VMD version 1.9.4 or later).
A new type of restraint, harmonicWalls (see 7.7), replaces and improves upon the legacy keywords lowerWall and upperWall: these are still supported as short-hands.
• Colvars version 2018-11-15 or later (VMD version 1.9.4 or later).
The global analysis keyword has been discontinued: specific analysis tasks are controlled directly by the keywords corrFunc and runAve, which continue to remain off by default.
• Colvars version 2020-02-25 or later (VMD version 1.9.4 or later).
The parameter hillWidth, expressing the Gaussian width $2\sigma$ in relative units (number of grid points), does not have a default value any more. A new alternative parameter gaussianSigmas allows setting the $\sigma$ parameters explicitly for each variable if needed.
Furthermore, to facilitate the use of other analysis tools such as for example sum_hills:
https://www.plumed.org/doc-v2.6/user-doc/html/sum_hills.html
the format of the file written by writeHillsTrajectory has also been changed to use $\sigma$ instead of $2\sigma$. This change does not affect how the biasing potential is written in the state file, or the simulated trajectory.
• Colvars version 2020-02-25 or later (VMD version 1.9.4 or later).
The legacy keywords lowerWall and upperWall of a colvar definition block do not have default values any longer, and need to be set explicitly, preferably as part of the harmonicWalls restraint. When using an ABF bias, it is recommended to set the two walls equal to lowerBoundary and upperBoundary, respectively. When using a metadynamics bias, it is recommended to set the two walls strictly within lowerBoundary and upperBoundary; see 7.4.1 for details.
• Colvars version 2020-11-09 or later.
The legacy keyword disableForces for atom groups is now deprecated and will be discontinued in a future release. Atom groups now have an automated way to save computation if forces are not used, and enabling this option otherwise would lead to incorrect behavior.

### 10 Compilation notes

The Colvars module is typically built using the recipes of each supported software package: for this reason, no installation instructions are needed, and the vast majority of the features described in this manual are supported in the most common builds of each package.

This section lists the few cases where the choice of compilation settings affects the availability features in the Colvars module.

• Scripting commands using the Tcl language (https://www.tcl.tk) are supported in VMD, NAMD, and Tinker-HP. All precompiled builds of NAMD and VMD include Tcl, and it is highly recommended to enable Tcl support in any custom build, using precompiled Tcl libraries from the UIUC website.
• The Lepton library (https://simtk.org/projects/lepton) used to implement the customFunction feature is currently included only in NAMD (always on), in LAMMPS (on by default) and in the Colvars-patched GROMACS releases (but currently, not in the standard releases). For VMD, a patch that allows to link Lepton is available.
• Colvars requires the C++11 language standard or higher, which is either supported (VMD) or required (GROMACS, LAMMPS, NAMD) by all the engines. However, many of the VMD official builds are produced on very old architectures, where C++11 features are disabled at build time, thus limiting functionality. For details please see:

### References

[1]   Giacomo Fiorin, Michael L. Klein, and Jérôme Hénin. Using collective variables to drive molecular dynamics simulations. Mol. Phys., 111(22-23):3345--3362, 2013.

[2]   William Humphrey, Andrew Dalke, and Klaus Schulten. VMD: visual molecular dynamics. J. Mol. Graph., 14(1):33--38, 1996.

[3]   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.

[4]   E A Coutsias, C Seok, and K A Dill. Using quaternions to calculate RMSD. J. Comput. Chem., 25(15):1849--1857, 2004.

[5]   Mina Ebrahimi and Jérôme Hénin. Symmetry-adapted restraints for binding free energy calculations. Journal of Chemical Theory and Computation, 18(4):2494--2502, 2022.

[6]   Haohao Fu, Wensheng Cai, Jérôme Hénin, Benoît Roux, and Christophe Chipot. New coarse variables for the accurate determination of standard binding free energies. J. Chem. Theory. Comput., 13(11):5173--5178, 2017.

[7]   Yuguang Mu, Phuong H. Nguyen, and Gerhard Stock. Energy landscape of a small peptide revealed by dihedral angle principal component analysis. Proteins, 58(1):45--52, 2005.

[8]   Alexandros Altis, Phuong H. Nguyen, Rainer Hegger, and Gerhard Stock. Dihedral angle principal component analysis of molecular dynamics simulations. J. Chem. Phys., 126(24):244111, 2007.

[9]   Nicholas M Glykos. Carma: a molecular dynamics analysis program. J. Comput. Chem., 27(14):1765--1768, 2006.

[10]   G. D. Leines and B. Ensing. Path finding on high-dimensional free energy landscapes. Phys. Rev. Lett., 109:020601, 2012.

[11]   Davide Branduardi, Francesco Luigi Gervasio, and Michele Parrinello. From a to b in free energy space. J Chem Phys, 126(5):054103, 2007.

[12]   F. Comitani L. Hovan and F. L. Gervasio. Defining an optimal metric for the path collective variables. J. Chem. Theory Comput., 15:25--32, 2019.

[13]   Haochuan Chen, Han Liu, Heying Feng, Haohao Fu, Wensheng Cai, Xueguang Shao, and Christophe Chipot. Mlcv: Bridging Machine-Learning-Based Dimensionality Reduction and Free-Energy Calculation. J. Chem. Inf. Model., 62(1):1--8, 2022.

[14]   Giacomo Fiorin, Fabrizio Marinelli, and José D. Faraldo-Gómez. Direct derivation of free energies of membrane deformation and other solvent density variations from enhanced sampling molecular dynamics. J. Comp. Chem., 41(5):449--459, 2020.

[15]   Marco Jacopo Ferrarotti, Sandro Bottaro, Andrea Pérez-Villa, and Giovanni Bussi. Accurate multiple time step in biased molecular simulations. Journal of chemical theory and computation, 11:139--146, 2015.

[16]   Reza Salari, Thomas Joseph, Ruchi Lohia, Jérôme Hénin, and Grace Brannigan. A streamlined, general approach for computing ligand binding free energies and its application to GPCR-bound cholesterol. Journal of Chemical Theory and Computation, 14(12):6560--6573, 2018.

[17]   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.

[18]   J. Hénin and C. Chipot. Overcoming free energy barriers using unconstrained molecular dynamics simulations. J. Chem. Phys., 121:2904--2914, 2004.

[19]   Jérôme Hénin, Giacomo Fiorin, Christophe Chipot, and Michael L. Klein. Exploring multidimensional free energy landscapes using time-dependent biases on collective variables. J. Chem. Theory Comput., 6(1):35--47, 2010.

[20]   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.

[21]   M. J. Ruiz-Montero, D. Frenkel, and J. J. Brey. Efficient schemes to compute diffusive barrier crossing rates. Mol. Phys., 90:925--941, 1997.

[22]   W. K. den Otter. Thermodynamic integration of the free energy along a reaction coordinate in cartesian coordinates. J. Chem. Phys., 112:7283--7292, 2000.

[23]   Giovanni Ciccotti, Raymond Kapral, and Eric Vanden-Eijnden. Blue moon sampling, vectorial reaction coordinates, and unbiased constrained dynamics. ChemPhysChem, 6(9):1809--1814, 2005.

[24]   J. Hénin. Fast and accurate multidimensional free energy integration. J. Chem. Theory Comput., 2021.

[25]   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.

[26]   A. Laio and M. Parrinello. Escaping free-energy minima. Proc. Natl. Acad. Sci. USA, 99(20):12562--12566, 2002.

[27]   Helmut Grubmüller. Predicting slow structural transitions in macromolecular systems: Conformational flooding. Phys. Rev. E, 52(3):2893--2906, Sep 1995.

[28]   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 Design, 8(6):695--708, DEC 1994.

[29]   G. Bussi, A. Laio, and M. Parrinello. Equilibrium free energies from nonequilibrium metadynamics. Phys. Rev. Lett., 96(9):090601, 2006.

[30]   Fabrizio Marinelli, Fabio Pietrucci, Alessandro Laio, and Stefano Piana. A kinetic model of trp-cage folding from multiple biased molecular dynamics simulations. PLOS Computational Biology, 5(8):1--18, 2009.

[31]   Yanier Crespo, Fabrizio Marinelli, Fabio Pietrucci, and Alessandro Laio. Metadynamics convergence law in a multidimensional system. Phys. Rev. E, 81:055701, May 2010.

[32]   Fabrizio Marinelli and José D. Faraldo-Gómez. Ensemble-biased metadynamics: A molecular simulation method to sample experimental distributions. Biophys. J., 108(12):2779--2782, 2015.

[33]   Alessandro Barducci, Giovanni Bussi, and Michele Parrinello. Well-tempered metadynamics: A smoothly converging and tunable free-energy method. Phys. Rev. Lett., 100:020603, 2008.

[34]   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, 2006.

[35]   Yuqing Deng and Benoît Roux. Computations of standard binding free energies with molecular dynamics simulations. J. Phys. Chem. B, 113(8):2234--2246, 2009.

[36]   Jed W. Pitera and John D. Chodera. On the use of experimental observations to bias simulated ensembles. J. Chem. Theory Comput., 8:3445--3451, 2012.

[37]   Andrew D. White and Gregory A. Voth. Efficient and minimal method to bias molecular simulations with experimental data. J. Chem. Theory Comput., 10(8):3023----3030, 2014.

[38]   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.