6 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:

  • •

    name — Identifier for the bias
    Default: <type of bias><bias index> [ string, context: colvar bias ]

    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. 3.8.5) 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.

  • •

    colvars — Collective variables involved
    [ space-separated list of colvar names, context: colvar bias ]

    This option selects by name all the variables to which this bias or analysis will be applied.

  • •

    outputEnergy — Write the current bias energy to the trajectory file
    Default: off [ boolean, context: colvar bias ]

    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.

  • •

    outputFreq — Frequency (number of steps) at which output files are written
    Default: colvarsRestartFrequency [ positive integer, context: colvar bias ]

    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.

  • •

    bypassExtendedLagrangian — Apply bias to actual colvars, bypassing extended coordinates
    Default: off [ boolean, context: colvar bias ]

    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 (4.21), for example within an eABF (6.4) 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.

  • •

    stepZeroData — Accumulate data starting at step 0 of a simulation run
    Default: off [ boolean, context: colvar bias ]

    This option is meaningful for biases that record and accumulate data during a simulation, such as ABF (6.3), metadynamics (6.6), histograms (6.13) and in general any bias that accumulates free-energy samples with thermodynamic integration, or TI (6.2). 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.

  • •

    scaledBiasingForce — Scale biasing force by a factor in an external histogram
    Default: off [ boolean, context: colvar bias ]

    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.

  • •

    scaledBiasingForceFactorsGrid — A histogram file with the scaling factor of biasing force in each bin
    [ string, context: colvar bias ]

    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 (3.8.4), similar to the low-dimensional the PMF files written by metadynamics and ABF.

6.1 Defining grids for biasing and analysis methods

Several methods (histograms, ABF and eABF, optionally metadynamics) rely on discretizing colvars on regular grids to represent functions such as probability distributions or free energy surfaces.

Grid parameters are specific to each variable, and some of them may even be defined automatically: for instance, periodic angles have default boundaries of -180∘ and 180∘. When not given by default, boundaries may be also specified when defining the collective variable itself (4.19).

Each bias will use by default any colvar boundaries that are automatically defined or explicitly given. Optionally, the bias may also contain a dedicated configuration block grid { …} inside its configuration. The options supported within the grid { …} block are:

  • •

    lowerBoundary — Lower boundaries of the grid
    [ list of space-separated decimals, context: grid ]

    This option is specified once, and takes as many parameters as there are colvars associated with this bias. It defines the lower boundaries of the grid, overriding any values defined by the lowerBoundary keyword of each colvar.

  • •

    upperBoundary — analogous to lowerBoundary

  • •

    width — Bin widths of the grid
    [ list of space-separated decimals, context: grid ]

    This option is specified once, and takes as many parameters as there are colvars associated with this bias. It defines the bin widths of the grid along each dimension, overriding any values defined by the width keyword of each colvar.

Example: Definition of custom grid parameters for a histogram. Note how some of the boundaries of the variables are automatically defined, but this histogram’s grid is custom-defined to also specify a finer width and narrower boundaries.

colvar {
  name r
  # lowerBoundary 0.0 is automatically defined
  upperBoundary 20.0
  distance { ... }
}

colvar {
  name theta
  # lowerBoundary -180.0 is automatically defined
  # upperBoundary 180.0 is automatically defined
  dihedral { ... }
}

histogram {
  name hist2d
  colvars r theta
  grid {
    width  0.1 1.0
    lowerBoundary   2.0 30.0
    upperBoundary  10.0 90.0
  }
}

6.2 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 (6.8, 6.10, 6.11, …) as well as metadynamics (6.6) can optionally use TI alongside their own estimator, based on the keywords documented below.

  • •

    writeTIPMF — Write the PMF computed by thermodynamic integration
    Default: off [ boolean, context: colvar bias ]

    If the bias is applied to a variable that supports the calculation of total forces (see outputTotalForce and 4.16.1), this option allows calculating the corresponding PMF by thermodynamic integration, and writing it to the file output.<name>.ti.pmf, where <name> is the name of the bias and the contents of the file are in multicolumn text format (3.8.4). 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.

  • •

    writeTISamples — Write the free-energy gradient samples
    Default: off [ boolean, context: colvar bias ]

    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 output.<name>.ti.count and output.<name>.ti.force, respectively: these can be used by abf_integrate (see 6.3.5) 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) (6.3) the above keywords are not recognized, because their functionality is either included already (conventional ABF) or not available (extended-system ABF).

6.3 Adaptive Biasing Force

For a full description of the Adaptive Biasing Force method, see ref. Darve et al., 2008. For details about this implementation, see references Hénin and Chipot (2004) and Hénin et al. (2010). When publishing research that makes use of this functionality, please cite references Darve et al. (2008) and Hénin et al. (2010).

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 (4.21) of the variables produces the extended-system ABF variant of the method (6.4).

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 𝝃=(ξi)i∈[1,n] is defined from the canonical distribution of 𝝃, 𝒫⁢(𝝃):

A⁢(𝝃)=−1β⁢ln⁡𝒫⁢(𝝃)+A0 (22)

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 𝑭ξ exerted on 𝝃, taken over an iso-𝝃 surface:

∇ξA⁢(𝝃)=⟨−𝑭ξ⟩𝝃 (23)

Several formulae that take the form of (23) have been proposed. This implementation relies partly on the classic formulation Carter et al. (1989), and partly on a more versatile scheme originating in a work by Ruiz-Montero et al. Ruiz-Montero et al. (1997), generalized by den Otter den Otter (2000) and extended to multiple variables by Ciccotti et al. Ciccotti et al. (2005). Consider a system subject to constraints of the form σk⁢(𝒙)=0. Let (𝒗i)i∈[1,n] be arbitrarily chosen vector fields (ℝ3⁢N→ℝ3⁢N) verifying, for all i, j, and k:

𝒗i⋅∇𝒙⁢ξj = δi⁢j (24)
𝒗i⋅∇𝒙⁢σk = 0 (25)

then the following holds Ciccotti et al. (2005):

∂A∂ξi=⟨𝒗i⋅∇𝒙⁢V−kB⁢T⁢∇𝒙⋅𝒗i⟩𝝃 (26)

where V is the potential energy function. 𝒗i can be interpreted as the direction along which the force acting on variable ξi is measured, whereas the second term in the average corresponds to the geometric entropy contribution that appears as a Jacobian correction in the classic formalism Carter et al. (1989). Condition (24) states that the direction along which the total force on ξi is measured is orthogonal to the gradient of ξj, which means that the force measured on ξi does not act on ξj.

Equation (25) 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, 𝐅ξ is accumulated in bins of finite size δ⁢ξ, thereby providing an estimate of the free energy gradient according to equation (23). The biasing force applied along the collective variables to overcome free energy barriers is calculated as:

𝐅ABF=α⁢(Nξ)×∇𝒙⁢A~⁢(𝝃) (27)

where ∇𝒙⁢A~ denotes the current estimate of the free energy gradient at the current point 𝝃 in the collective variable subspace, and α⁢(Nξ) is a scaling factor that is ramped from 0 to 1 as the local number of samples Nξ increases to prevent 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 ∇𝒙⁢A~ is progressively refined. The biasing force introduced in the equations of motion guarantees that in the bin centered around 𝝃, the forces acting along the selected collective variables average to zero over time. Eventually, as the underlying free energy surface is canceled by the adaptive bias, evolution of the system along 𝝃 is governed mainly by diffusion. Although this implementation of ABF can in principle be used in arbitrary dimension, a higher-dimension collective variable space is likely to be difficult to sample and visualize. Most commonly, the number of variables is one or two, sometimes three.

6.3.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 (6.4).

  1. 1.

    Only linear combinations of colvar components can be used in ABF calculations.

  2. 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. 3.

    Mutual orthogonality of colvars. In a multidimensional ABF calculation, equation (24) must be satisfied for any two colvars ξi and ξj. Various cases fulfill this orthogonality condition:

    • •

      ξi and ξj are based on non-overlapping sets of atoms.

    • •

      atoms involved in the force measurement on ξi do not participate in the definition of ξj. This can be obtained using the option oneSiteTotalForce of the distance, angle, and dihedral components (example: Ramachandran angles ϕ, ψ).

    • •

      ξi and ξ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. 4.

    Mutual orthogonality of components: when several components are combined into a colvar, it is assumed that their vectors 𝒗i (equation (26)) are mutually orthogonal. The cases described for colvars in the previous paragraph apply.

  5. 5.

    Orthogonality of colvars and constraints: equation 25 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 25 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.

6.3.2 Parameters for ABF

ABF depends on parameters from each collective variable to define the grid on which free energy gradients are computed: see 4.19 for details. Alternately, grid parameters can be set directly inside the abf block by inserting a grid sub-block, as explained in 6.1. 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)

  • •

    fullSamples — Number of samples in a bin prior to full application of the ABF
    Default: 200 [ positive integer, context: abf ]

    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 α⁢(Nξ) between 0 and 1. If the number of samples Nξ 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: α⁢(Nξ)=(Nξ−minSamples)/(fullSamples−minSamples).

  • •

    minSamples — Number of samples in a bin prior to application of the ABF
    Default: fullSamples / 2 [ positive integer, context: abf ]

  • •

    maxForce — Maximum magnitude of the ABF force
    Default: disabled [ positive decimals (one per colvar), context: abf ]

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

  • •

    hideJacobian — Remove geometric entropy term from calculated free energy gradient?
    Default: no [ boolean, context: abf ]

    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 (26) by the second term of the average, −kB⁢T⁢∇𝒙⋅𝒗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 (26) 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.

  • •

    historyFreq — Frequency (in timesteps) at which ABF history files are accumulated
    Default: 0 [ positive integer, context: abf ]

    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 (output.hist.pmf). historyFreq must be a multiple of outputFreq.

  • •

    inputPrefix — Filename prefix for reading ABF data
    [ list of strings, context: abf ]

    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 (input keyword of the fix ID group-ID colvars command).

  • •

    applyBias — Apply the ABF bias?
    Default: yes [ boolean, context: abf ]

    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.

  • •

    updateBias — Update the ABF bias?
    Default: yes [ boolean, context: abf ]

    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.

6.3.3 Multiple-walker ABF

This implements the multiple-walker ABF scheme described in Minoukadeh et al. (2010). The references for this implementation are Comer et al. (2014) and Fiorin et al. (2024). This feature requires that LAMMPS be compiled and executed with multiple-replica support.

If shared is enabled, the total force samples will be synchronized among all replicas at intervals defined by sharedFreq. Each replica maintains a separate buffer of total force samples that determine the biasing force. Every sharedFreq steps, the replicas communicate the samples that have been gathered since the last synchronization time, ensuring all replicas apply a similar biasing force. Thus, it is as if total force samples among all replicas are gathered in a single shared buffer. Shared ABF allows all replicas to benefit from the sampling done by other replicas and can lead to faster convergence of the biasing force.

Output files of multiple-walker ABF.

In multiple-walker ABF runs, since Colvars version 2024-01-06, each walker outputs gradient and count files containing only data collected locally. In addition, the first walker outputs the collected data using the common prefix, with an additional ".all" string (i.e. file names ending with ".all.count", ".all.grad" etc.).

  • •

    shared — Apply multiple-walker ABF, sharing force samples among the replicas?
    Default: no [ boolean, context: abf ]

    Enable sharing of ABF data between replicas, in a multi-replica simulation.

  • •

    sharedFreq — Frequency (in timesteps) at which force samples are synchronized among the replicas
    Default: outputFreq [ positive integer or zero, context: abf ]

    Every sharedFreq steps, the replicas communicate the samples that have been gathered since the last synchronization time. Because this forces the replicas to synchronize, small values of this parameter may slightly reduce the overall throughput, especially on systems with unequal performance.

6.3.4 Output files

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

  • •

    output.grad: current estimate of the free energy gradient (grid), in multicolumn;

  • •

    output.count: histogram of samples collected, on the same grid;

  • •

    output.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 output.abf1.grad. This should not be done routinely and could lead to meaningless results: only do it if you know what you are doing!

If the colvar space has been partitioned into sections (windows) in which independent ABF simulations have been run, the resulting data can be merged using the inputPrefix option described above (a run of 0 steps is enough).

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

  • •

    integrate — Integrate free energy surface from ABF gradients (dim < 3)
    Default: yes [ boolean, context: abf ]

    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, by default integration is performed by solving an unweighted Poisson equation: Hénin (2021)

    ∇2At=∇⋅Gt (28)

    where Gt is the estimated gradient at time t, and At is corresponding free energy surface. The free energy surface is written under the file name <outputName>.pmf, in a plain text format (see 3.8.4) 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. Hénin (2021),  Chen for implementation details.

  • •

    integrateTol — Tolerance for free energy integration
    Default: 1e-6 [ positive decimal, context: abf ]

    The conjugate gradients algorithm used to integrate the free energy surface is stopped when the RMS error reaches integrateTol.

  • •

    integrateMaxIterations — Maximum iterations for free energy integration
    Default: 10000 [ integer, context: abf ]

    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.

  • •

    integrateWeighted — Use weighted method to integrate free energy surface from ABF gradients
    Default: no [ boolean, context: abf ]

    This option is disabled by default. If activated, the calculation of the free energy will be performed using weighted integration. This means solving the following weighted Poisson equation:

    ∇⋅θ⁢∇At=∇⋅Gt. (29)

    With θ, the weights, corresponding to how much an area has been visited during the simulation. The weights values are all strictly superior to 0 so the problem is well-posed. For any cell with zero visits, its weight is assigned to the value corresponding to the 10th percentile of the visit-count distribution. Moreover, visit counts are capped at the 50th percentile measured from the upper tail (i.e., the 50th percentile from the lower tail). The choice of the percentile is hard code. The goal is that the most visited cells which corresponds to the cells where the gradient is the best known have more importance in the free energy calculation.

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.Hénin (2021) for details.

6.4 Extended-system Adaptive Biasing Force (eABF)

Extended-system ABF (eABF) is a variant of ABF (6.3) where the bias is not applied directly to the collective variable, but to an extended coordinate (“fictitious variable”) λ 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 (4.21). The theory of eABF and the present implementation are documented in detail in ref. Lesage et al., 2017.

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 λ is coupled to the colvar z=ξ⁢(q) by the harmonic potential (k/2)⁢(z−λ)2. Under eABF dynamics, the adaptive bias on λ is the running estimate of the average spring force:

Fbias⁢(λ∗)=⟨k⁢(λ−z)⟩λ∗ (30)

where the angle brackets indicate a canonical average conditioned by λ=λ∗. At long simulation times, eABF produces a flat histogram of the extended variable λ, and a flattened histogram of ξ, whose exact shape depends on the strength of the coupling as defined by extendedFluctuation in the colvar.

Coupling should be strong enough that the bias helps overcome barriers along the colvar.Lesage et al. (2017) A value of extendedFluctuation equal to the bin width is often reasonable. In the limit of strong coupling (small extendedFluctuation), the eABF free energy surface (.pmf file) becomes close to the true one, making the asymptotically more accurate but noisier CZAR estimator (.czar.pmf file) unnecessary. In practice, we recommend comparing these two free energy surfaces to decide which one to use.

Distribution of the colvar may be assessed by plotting its histogram, which is written to the output.zcount file in every eABF simulation. Note that a histogram bias (6.13) applied to an extended-Lagrangian colvar will access the extended degree of freedom λ, not the original colvar ξ; 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 λ, it is not exactly the free energy profile of ξ. That quantity can be calculated based on the CZAR estimator.

6.4.1 CZAR estimator of the free energy

The corrected z-averaged restraint (CZAR) estimator is described in detail in ref. Lesage et al., 2017. 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′⁢(z)=−1β⁢d⁢ln⁡ρ~⁢(z)d⁢z+k⁢(⟨λ⟩z−z). (31)

where z=ξ⁢(q) is the colvar, λ is the extended variable harmonically coupled to z with a force constant k, and ρ~⁢(z) is the observed distribution (histogram) of z, affected by the eABF bias.

Parameters for the CZAR estimator are:

  • •

    CZARestimator — Calculate CZAR estimator of the free energy?
    Default: yes [ boolean, context: abf ]

    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.

  • •

    writeCZARwindowFile — Write internal data from CZAR to a separate file?
    Default: no [ boolean, context: abf ]

    When this option is enabled, eABF simulations will write a file containing the z-averaged restraint force under the name output.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 (3.8.4):

  • •

    output.czar.grad: current estimate of the free energy gradient (grid), in multicolumn;

  • •

    output.czar.pmf: only for one-dimensional calculations, integrated free energy profile or PMF.

The sampling histogram associated with the CZAR estimator is the z-histogram, which is written in the file output.zcount.

6.5 Adiabatic Bias Molecular Dynamics (ABMD)

This implements the Adiabatic Bias Molecular Dynamics (ABMD) method of Marchi and Ballone Marchi and Ballone (1999), sometimes referred to as ratchet-and-pawl or ratcheted MD. ABMD is a non-equilibrium process that enhances the motion of a scalar colvar in a given direction. For simplicity, the case of an increasing value is described below, but enhancing downward motion of the variable is also supported via the decreasing flag.

ABMD does not directly push the variable forward, but prevents it from backtracking by applying a time-dependent half-harmonic potential Vt, the center of which is the highest value attained by the variable so far (its high-water mark). This design implies that the bias is conservative at all times and therefore exerts zero net work, hence the “adiabatic” qualifier:

Vt⁢(ξt)={12⁢k⁢(ξt−ξtref)2if ⁢ξt<ξtref0otherwise (32)

where ξtref is the high-water mark at time t, bounded by a user-defined stopping value ξstop:

ξtref=min⁡(maxs=0t⁡ξs,ξstop). (33)

Note: because the ABMD potential in eq. 32 is never defined for more than one variable, no internal unit conversion is applied to k: this behavior is different from other restraints available in Colvars, such as the harmonic wall restraints in 6.10.

Besides the name of the biased variable specified by the colvars keyword, the tunable parameters of ABMD are the force constant k and the stopping value ξstop, set by the following user keywords:

  • •

    forceConstant — Force constant for the half-harmonic bias
    [ positive decimal, context: abmd ]

    The value of k. Stronger values result if faster motion of the coordinate, along more biased pathways.

  • •

    stoppingValue — Value beyong which the reference value is not updated
    [ decimal, context: abmd ]

    This sets the value of ξstop. It is useful to prevent the variable from reaching unrealistic values after the relevant range has been covered.

  • •

    decreasing — Should the variable decrease over time?
    Default: no [ boolean, context: abmd ]

    This is used to make ABMD enhance motion toward lower colvar values. When enabled, it reverses the shape of the half-harmonic potential, and makes the reference value follow the minimum of the variable.

ABMD also supports the following common bias parameters:

  • •

    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)

6.6 Metadynamics

The metadynamics method uses a history-dependent potential Laio and Parrinello (2002) that generalizes to any type of colvars the conformational flooding Grubmüller (1995) and local elevation Huber et al. (1994) methods, originally formulated to use as colvars the principal components of a covariance matrix or a set of dihedral angles, respectively. The metadynamics potential on the colvars 𝝃=(ξ1,ξ2,…,ξNcv) is defined as:

Vmeta⁢(𝝃⁢(t))=∑t′=δ⁢t,2⁢δ⁢t,…t′<tW⁢∏i=1Ncvexp⁡(−(ξi⁢(t)−ξi⁢(t′))22⁢σξi2), (34)

where Vmeta is the history-dependent potential acting on the current values of the colvars 𝝃, and depends only parametrically on the previous values of the colvars. Vmeta is constructed as a sum of Ncv-dimensional repulsive Gaussian “hills”, whose height is a chosen energy constant W, and whose centers are the previously explored configurations (𝝃⁢(δ⁢t),𝝃⁢(2⁢δ⁢t),…).

During the simulation, the system evolves towards the nearest minimum of the “effective” potential of mean force A~⁢(𝝃), which is the sum of the “real” underlying potential of mean force A⁢(𝝃) and the the metadynamics potential, Vmeta⁢(𝝃). Therefore, at any given time the probability of observing the configuration 𝝃∗ is proportional to exp⁡(−A~⁢(𝝃∗)/κB⁢T): 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 A~⁢(𝝃) is constant, and −Vmeta⁢(𝝃) is an estimator of the “real” potential of mean force A⁢(𝝃), save for an additive constant:

A⁢(𝝃)≃−Vmeta⁢(𝝃)+K (35)

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 τξi, and of the user-defined parameters W, σξi and δ⁢t Bussi et al. (2006). In typical applications, a good rule of thumb can be to choose the ratio W/δ⁢t much smaller than κB⁢T/τ𝝃, where τ𝝃 is the longest among 𝝃’s correlation times: σξi then dictates the resolution of the calculated PMF.

If the metadynamics parameters are chosen correctly, after an equilibration time, te, the estimator provided by eq. 35 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 te Marinelli et al. (2009); Crespo et al. (2010):

A⁢(𝝃)=−1tt⁢o⁢t−te⁢∫tett⁢o⁢tVmeta⁢(𝝃,t)⁢𝑑t (36)

where te is the time after which the bias potential grows (approximately) evenly during the simulation and tt⁢o⁢t is the total simulation time. The free energy calculated according to eq. 36 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.

6.6.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 Fiorin et al. (2013). 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 [0:180] 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 6.10).

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 σ 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⁢σ) amounts to 2 grid points, the threshold is 6+1 = 7 grid points away from upperBoundary. In explicit units, the width of r is wr= 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 = rupper = 13.6 Å is:

E∗=12⁢k⁢(r−rupperwr)2=12⁢2.0⁢(−3)2=9⁢kcal/mol

which results in a relative probability exp⁡(−E∗/κB⁢T)≃ 3×10−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.

6.6.2 Required metadynamics keywords

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 4.19. Alternately, grid parameters can be set directly inside the metadynamics block by inserting a grid sub-block, as explained in 6.1.

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⁢σ 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)

  • •

    hillWeight — Height of each hill (energy unit)
    [ positive decimal, context: metadynamics ]

    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.

  • •

    hillWidth — Width 2⁢σ of a Gaussian hill, measured in number of grid points
    [ positive decimal, context: metadynamics ]

    This keyword sets the Gaussian width 2⁢σξi for all colvars, expressed in number of grid points, with the grid spacing along each colvar ξ 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 Fiorin et al. (2013), while larger values may be unable to account for steep free-energy gradients. The values of each half-width σξi in the physical units of ξi are also printed by LAMMPS at initialization time; alternatively, they may be set explicitly via gaussianSigmas.

  • •

    gaussianSigmas — Half-widths σ of the Gaussian hill (one for each colvar)
    [ space-separated list of decimals, context: metadynamics ]

    This option sets the parameters σξi of the Gaussian hills along each colvar ξi, expressed in the same unit of ξi. No restrictions are placed on each value, but a warning will be printed if useGrids is on and the Gaussian width 2⁢σξi is smaller than the corresponding grid spacing, 𝚠𝚒𝚍𝚝𝚑⁢(ξi). If not given, default values will be computed from the dimensionless number hillWidth.

  • •

    newHillFrequency — Frequency of hill creation
    Default: 1000 [ positive integer, context: metadynamics ]

    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 δ⁢t in eq. 34. Higher values provide more accurate statistical sampling, at the price of longer simulation times to complete a PMF calculation.

6.6.3 Output files

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

  • •

    writeFreeEnergyFile — Periodically write the PMF for visualization
    Default: on [ boolean, context: metadynamics ]

    When useGrids and this option are on, the PMF is written every outputFreq steps.

  • •

    keepFreeEnergyFiles — Keep all the PMF files
    Default: off [ boolean, context: metadynamics ]

    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.

  • •

    writeHillsTrajectory — Write a log of new hills
    Default: off [ boolean, context: metadynamics ]

    If this option is on, a file containing the Gaussian hills written by the metadynamics bias, with the name:
    “output.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:
    “output.colvars.<name>.<replicaID>.hills.traj”.
    The columns of this file are the centers of the hills, ξi⁢(t′), followed by the half-widths, σξi, and the weight, W. Note: prior to version 2020-02-24, the full-width 2⁢σ of the Gaussian was reported in lieu of σ.

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

  • •

    useGrids — Interpolate the hills with grids
    Default: on [ boolean, context: metadynamics ]

    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.

  • •

    rebinGrids — Recompute the grids when reading a state file
    Default: off [ boolean, context: metadynamics ]

    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.

  • •

    keepHills — Write each individual hill to the state file
    Default: off [ boolean, context: metadynamics ]

    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.

6.6.5 Ensemble-Biased Metadynamics

The ensemble-biased metadynamics (EBMetaD) approach Marinelli and Faraldo-Gómez (2015) 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:

VEBmetaD⁢(𝝃⁢(t))=∑t′=δ⁢t,2⁢δ⁢t,…t′<tWexp⁡(Sρ)⁢ρe⁢x⁢p⁢(𝝃⁢(t′))⁢∏i=1Ncvexp⁡(−(ξi⁢(t)−ξi⁢(t′))22⁢σξi2), (37)

where ρe⁢x⁢p⁢(𝝃) is the target probability distribution and Sρ=−∫ρe⁢x⁢p⁢(𝝃)⁢log⁡ρe⁢x⁢p⁢(𝝃)⁢d𝝃 its corresponding differential entropy. The method is designed so that during the simulation the resulting distribution of the collective variable 𝝃 converges to ρe⁢x⁢p⁢(𝝃). 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 Marinelli and Faraldo-Gómez (2015).

The PMF along ξ can be estimated from the bias potential and the target ditribution Marinelli and Faraldo-Gómez (2015):

A⁢(𝝃)≃−VEBmetaD⁢(𝝃)−κB⁢T⁢log⁡ρe⁢x⁢p⁢(𝝃) (38)

and obtained by enabling writeFreeEnergyFile. Similarly to eq. 36, 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:

  • •

    ebMeta — Perform ensemble-biased metadynamics
    Default: off [ boolean, context: metadynamics ]

    If enabled, this flag activates the ensemble-biased metadynamics as described by Marinelli et al.Marinelli and Faraldo-Gómez (2015). 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.

  • •

    targetDistFile — Target probability distribution file for ensemble-biased metadynamics
    [ multicolumn text file, context: metadynamics ]

    This file provides the target probability distribution, ρe⁢x⁢p⁢(𝝃), reported in eq. 37. The latter distribution must be a tabulated function provided in a multicolumn text format (see 3.8.4). The provided distribution is then normalized.

  • •

    ebMetaEquilSteps — Number of equilibration steps for ensemble-biased metadynamics
    [ positive integer, context: metadynamics ]

    The EBMetaD approach may introduce large hills in regions with small values of the target probability distribution (eq. 37). 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. 34) to EBmetaD (eq. 37) as λ⁢Vmeta⁢(𝝃)+(1−λ)⁢VEBmetaD⁢(𝝃), where λ=(𝚎𝚋𝙼𝚎𝚝𝚊𝙴𝚚𝚞𝚒𝚕𝚂𝚝𝚎𝚙𝚜−𝚜𝚝𝚎𝚙)/𝚎𝚋𝙼𝚎𝚝𝚊𝙴𝚚𝚞𝚒𝚕𝚂𝚝𝚎𝚙𝚜 and step is the current simulation step number.

  • •

    targetDistMinVal — Minimum value of the target distribution in reference to its maximum value
    [ positive decimal, context: metadynamics ]

    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. 37), if targetDistMinVal is set as zero, values of ρe⁢x⁢p 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 3.8.4). 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 (3.8.4) 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 (6.10).

6.6.6 Well-tempered metadynamics

The following options define the configuration for the “well-tempered” metadynamics approach Barducci et al. (2008):

  • •

    wellTempered — Perform well-tempered metadynamics
    Default: off [ boolean, context: metadynamics ]

    If enabled, this flag causes well-tempered metadynamics as described by Barducci et al.Barducci et al. (2008) 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).

  • •

    biasTemperature — Temperature bias for well-tempered metadynamics
    [ positive decimal, context: metadynamics ]

    When running metadynamics in the long time limit, collective variable space is sampled to a modified temperature T+Δ⁢T. In conventional metadynamics, the temperature “boost” Δ⁢T would constantly increases with time. Instead, in well-tempered metadynamics Δ⁢T must be defined by the user via biasTemperature. The written PMF includes the scaling factor (T+Δ⁢T)/Δ⁢T Barducci et al. (2008). A careful choice of Δ⁢T determines the sampling and convergence rate, and is hence crucial to the success of a well-tempered metadynamics simulation.

Note: usage of well-tempered metadynamics in combination with multiple walkers (6.6.7) is discouraged. Should you want to use the two features, keep in mind that in Colvars, the well-tempered scaling factor is applied independently of the communication between replicas, i.e. each walker has its Gaussian hills scaled independently of the other walkers.

6.6.7 Multiple-walker metadynamics

Metadynamics calculations can be performed concurrently by multiple replicas that share a common history. This variant of the method is called multiple-walker metadynamics Raiteri et al. (2006): 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 Fiorin et al. (2013), 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:
output.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:
output.colvars.name.replicaID.hills
Both files are only used for communication, and may be deleted after the replica begins writing files with a new output.

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:

  • •

    multipleReplicas — Enable multiple-walker metadynamics
    Default: off [ boolean, context: metadynamics ]

    This option turns on multiple-walker communication between replicas.

  • •

    replicasRegistry — Multiple replicas database file
    [ UNIX filename, context: metadynamics ]

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

  • •

    replicaUpdateFrequency — How often hills are shared between replicas
    [ positive integer, context: metadynamics ]

    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.

  • •

    replicaID — Set the identifier for this replica (required only for independent jobs)
    Default: replica index (only if MPI is used) [ string, context: metadynamics ]

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

  • •

    writePartialFreeEnergyFile — Periodically write the contribution to the PMF from this replica
    Default: off [ boolean, context: metadynamics ]

    If multipleReplicas is on, enabling this option produces an additional file output.partial.pmf, which can be useful to monitor the contribution of each replica to the total PMF (which is written to the file output.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.

6.7 On-the-fly probability enhanced sampling (OPES)

This biasing method implements the on-the-fly probability enhanced sampling (OPES) with metadynamics-like target distribution.Invernizzi and Parrinello (2020) The bias samples target distributions defined via their marginal distribution ptg⁢(𝝃) over some CVs, 𝝃=𝝃⁢(x). By default opes_metad targets the well-tempered distribution, pWT⁢(𝝃)=[P⁢(𝝃)]1/γ, where γ is known as the biasfactor. Similarly to metadynamics, opes_metad optimizes the bias on-the-fly, with a given newHillfrequency. It does so by reweighting via kernel density estimation of the unbiased distribution in the CV space, P⁢(𝝃). A compression algorithm is used to prevent the number of kernels from growing linearly with the simulation time. The bias at step n is

Vn⁢(𝝃)=−kB⁢T⁢(1−1/γ)⁢ln⁡(Pn⁢(𝝃)Zn+ϵ), (39)

where the probability Pn⁢(𝝃) and the normalization factor Zn are computed as

Pn⁢(𝝃)=∑knwk⁢G⁢(𝝃,𝝃k)∑knwk (40)
Zn=1|Ωn|⁢∫ΩnPn⁢(𝝃)⁢d𝝃, (41)

where the weights wk are given by wk=exp⁡(β⁢Vk−1⁢(𝝃k)), and the Gaussian kernels G⁢(𝝃,𝝃′)=h⁢exp⁡[−1/2⁢(𝝃−𝝃′)T⁢Σ−1⁢(𝝃−𝝃′)] have a diagonal covariance matrix Σi⁢j=σ2⁢δi⁢j and fixed height h=Πi⁢(σi⁢2⁢π)−1 (see Ref.Invernizzi and Parrinello (2020) for a complete description of the method).

If the exploration mode (keyword explore) is on, then the on-the-fly target probability distribution pWT⁢(𝝃) is used to define the biasing energy:

Vn⁢(𝝃)=−kB⁢T⁢(γ−1)⁢ln⁡(pnWT⁢(𝝃)Zn+ϵ), (42)

(See Ref.Invernizzi and Parrinello (2022) for a complete description of the exploration mode.)

The implementation of opes_metad and its documentation are largely based on the OPES module of the PLUMED package.

6.7.1 Implementation notes

Compared to the the OPES module in PLUMED Tribello et al. (2014), this implementation currently has the following limitations:

  • •

    Colvars does not support chaining bias actions in PLUMED, so the Colvars OPES implementation cannot take the biasing energies of other biases, such as harmonic restraints, into account for the internal reweighting, which means that there is no way to achieve the same functionality as the EXTRA_BIAS option in the OPES module in PLUMED. This means that it is not possible to sample a custom target distribution in the Colvars OPES implementation.

  • •

    Due to the same limitation of Colvars as described above, you cannot collect samples on-the-fly by chaining opes_metad with a weighted histogram for PMF calculations. Although the PMF calculation via reweighting is implemented into the pmf option, the functionality is quite limited. The CVs in pmfColvars must be among the biased ones. In other words, you cannot apply bias on (ξ1,ξ2) and compute the PMF along ξ3 by the on-the-fly reweighting using pmf (you can only compute the PMF along ξ1, ξ2 or (ξ1,ξ2)). In addition, you can only specify one set of CVs for estimating the PMF (you cannot apply the OPES bias on (ξ1,ξ2,ξ3) and compute two 2D PMFs along (ξ1,ξ2) and (ξ2,ξ3) simultaneously using the pmf option). However, you can always bypass this limitation by post-hoc reweighting with the trajectories.

  • •

    Colvars computes the biases in parallel with SMP, so it cannot use multiple threads again for computing the probability and the normalization factor, searching the kernels that are able to compress and updating the neighbor list. As a result, the CPU performance of this implementation may be slower than the PLUMED OPES module.

The following table summarizes the differences of the option names in Colvars and the corresponding option names in the PLUMED OPES module:

Colvars keyword PLUMED keyword
barrier BARRIER
newHillFrequency PACE
gaussianSigma SIGMA
gaussianSigmaMin SIGMA_MIN
kernelCutoff KERNEL_CUTOFF
compressionThreshold COMPRESSION_THRESHOLD
adaptiveSigma (use SIGMA=ADAPTIVE)
adaptiveSigmaStride ADAPTIVE_SIGMA_STRIDE
neighborList NLIST
neighborListNewHillReset NLIST_PACE_RESET
neighborListParameters NLIST_PARAMETERS
noZed NO_ZED
fixedGaussianSigma FIXED_SIGMA
recursiveMerge (the opposite of RECURSIVE_MERGE_OFF)
calcWork CALC_WORK
multipleReplicas WALKERS_MPI

The PLUMED options for restarting (STATE_RFILE, STATE_WFILE and STATE_WSTRIDE) are not necessary in Colvars, since Colvars has a unified mechanism to save the information required for restarting in the .colvars.state file.

6.7.2 General options

To enable a OPES-based calculation, a opes_metad {...} block must be included in the Colvars configuration file. The opes_metad block supports 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)

  • •

    barrier — The highest free-energy barrier you wish to overcome (energy unit)
    [ positive decimal, context: opes_metad ]

    This parameter should be set to be at least equal to the highest free energy barrier you wish to overcome. If it is much lower than that, you will not cross the barrier, if it is much higher, convergence might take a little longer. If the system has a basin that is clearly more stable than the others, it is better to start the simulation from there.

  • •

    newHillFrequency — Frequency of hill creation
    [ positive integer, context: opes_metad ]

    The frequency for kernel deposition.

  • •

    biasfactor — The γ biasfactor used for the well-tempered target distribution
    Default: barrier/kB⁢T [ positive decimal or “inf”, context: opes_metad ]

    This option sets the γ in Eq.(39). If setting to “inf”, the target distribution is uniform. It cannot be “inf” in the exploration mode.

  • •

    gaussianSigma — The initial widths of the kernels (divided by the square root of gamma in exploration mode)
    [ positive decimal, context: opes_metad ]

    This option sets the initial σ values of the Gaussian kernels. The number of gaussianSigma values should match the number of CVs used by colvars. If adaptiveSigma is set, then this option can be ignored.

  • •

    gaussianSigmaMin — The minimum widths of the kernels (divided by the square root of gamma in exploration mode)
    [ positive decimal (optional), context: opes_metad ]

    This option sets the minimum σ values of the Gaussian kernels. The number of gaussianSigmaMin values should match the number of CVs used by colvars. The OPES method scales down the σ during the simulation, and will never shrink σ under gaussianSigmaMin if this option is set.

  • •

    explore — Exploration mode
    Default: off [ boolean, context: opes_metad ]

    If enabled, the OPES exploration mode will be used (see Ref.Invernizzi and Parrinello (2022) for more information about the exploration mode).

  • •

    epsilon — The value of the regularization constant for the probability
    Default: exp⁡(−barrier/kB⁢T/(1−1/γ)) [ positive decimal, context: opes_metad ]

    This option sets the ϵ in Eq.(39).

  • •

    kernelCutoff — Truncate kernels at this distance, in units of σ
    Default: 2∗barrier/kB⁢T/(1−1/γ) [ positive decimal, context: opes_metad ]

    If the value of (𝝃−𝝃′)T⁢Σ−1⁢(𝝃−𝝃′) is larger than the square of this value, then G⁢(𝝃,𝝃′) is evaluated as zero.

  • •

    compressionThreshold — Merge kernels if closer than this threshold, in units of σ
    Default: 1.0 [ positive decimal, context: opes_metad ]

    Kernels will be merged the distances of their centers (scaled by the square of σ) are closer than this threshold.

  • •

    adaptiveSigma — Adaptively compute the bandwidths
    Default: off [ boolean, context: opes_metad ]

    If enabled, the values of σ of CVs are computed adaptively based on their variances. See the Supporting Information of Ref.Invernizzi and Parrinello (2022) for more details.

  • •

    adaptiveSigmaStride — Number of steps for measuring adaptive sigma
    Default: 10×newHillFrequency [ positive integer, context: opes_metad ]

    This option sets the number of steps for measuring the rolling variances of CVs that are used by the adaptive kernel bandwidth algorithm. See the Supporting Information of Ref.Invernizzi and Parrinello (2022) for more details.

  • •

    neighborList — Use neighbor list for kernels summation (experimental)
    Default: off [ boolean, context: opes_metad ]

    If enabled, a neighbor list will be used for kernels summation.

  • •

    neighborListNewHillReset — Force the reset of the neighbor list at each time when depositing a new hill
    Default: off [ boolean, context: opes_metad ]

    If enabled, the neighbor list will be rebuilt at each time when depositing a new hill.

  • •

    neighborListParameters — The two cutoff parameters of the neighbor list
    Default: 3.0 0.5 [ positive decimals, context: opes_metad ]

    The first parameter is the maximum distance of neighboring kernels. The second parameters is the threshold for rebuilding.

  • •

    noZed — Do not normalize the probability over the explored CV space
    Default: off [ boolean, context: opes_metad ]

    If enabled, Zn is always 1.

  • •

    fixedSigma — Do not scale down 𝛔
    Default: off [ boolean, context: opes_metad ]

    If enabled, 𝝈 will not be decreased as the simulation proceeds.

  • •

    recursiveMerge — Merge the kernels recursively
    Default: on [ boolean, context: opes_metad ]

    If enabled, the kernels will be compressed recursively when a new kernel is added.

  • •

    calcWork — Calculate the work done by the bias
    Default: off [ boolean, context: opes_metad ]

    If enabled, the total accumulated work will be computed.

6.7.3 Multiple-walker options

The following options can be used for the multiple-walker OPES, and require the direct communication between replicas through MPI:

  • •

    multipleReplicas — Enable multiple-walker OPES
    Default: off [ boolean, context: opes_metad ]

    This option turns on multiple-walker communication between replicas.

  • •

    replicaID — Set the identifier for this replica (required only for independent jobs)
    Default: replica index) [ string, context: opes_metad ]

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

  • •

    sharedFreq — Frequency (in number of steps) at which force samples are synchronized among the replicas
    Default: outputFreq [ positive integer or zero, context: opes_metad ]

    Every sharedFreq steps, the replicas communicate the samples that have been gathered since the last synchronization time. Because this forces the replicas to synchronize, small values of this parameter may slightly reduce the overall throughput, especially on systems with unequal performance.

6.7.4 Output options

The following options are used for setting the PMF and trajectory output. The PMF is calculated based on reweighting the CVs specified by pmfColvars, which collects on-the-fly the biasing energy V⁢(𝝃) and the values of CVs of every step, and builds a weighted histogram to calculate the unbiased probability of 𝝃

⟨𝒫⁢(𝝃′)⟩=∑t=0Nδ⁢(𝝃⁢(𝐱)−𝝃′)⁢exp⁡(V⁢(𝝃)kB⁢T)∑t=0Nexp⁡(V⁢(𝝃)kB⁢T) (43)

where N is the total number of simulation steps, 𝝃′ is the grid center in the histogram, and δ is the dirac delta function. The PMF is then obtained by

A⁢(𝝃′)=−kB⁢T⁢ln⁡⟨𝒫⁢(𝝃′)⟩+A0 (44)

where A0 is a constant to ensure A⁢(𝝃′) on every grid of the histogram is not negative.

The grid used for discretizing the free energy surface (PMF) computated by OPES is defined by the relevant options of the colvars. Alternately, grid parameters can be set directly inside the opes_metad block by inserting a grid sub-block, as explained in 6.1.

  • •

    pmf — Output the PMF
    Default: off [ boolean, context: opes_metad ]

    This option turns on the PMF output based on reweighting.

  • •

    pmfColvars — The CVs used for estimating the PMF
    [ positive decimal, context: opes_metad ]

    This option sets the CVs used for the PMF. The CVs specified in this option must have appeared in colvars and had the boundaries and widths.

  • •

    pmfHistoryFrequency — The frequency of saving the PMF history file
    Default: 0 [ positive integer, context: opes_metad ]

    If this option is larger than 0 and pmf is on, then every pmfHistoryFrequency steps the current PMF will also be saved into “output.colvars.<name>.<replicaID>.hist.pmf”.

  • •

    pmfShared — Output a global PMF for multiple-walker OPES
    Default: on [ boolean, context: opes_metad ]

    If multipleReplicas is on and this option is also on, then a global reweighting histogram will be built to collect samples from all replicas, and the corresponding global PMF is written into “output.colvars.<name>.<replicaID>.global.pmf” by replica 0. The history global PMF is also written to “output.colvars.<name>.<replicaID>.global.hist.pmf” by replica 0.

  • •

    printTrajectoryFrequency — The frequency of saving the trajectories
    Default: colvarsTrajFrequency [ positive integer, context: opes_metad ]

    If this option is larger than 0, then every printTrajectoryFrequency, the simulation time in ps, the values of CVs, the biasing energy, c⁢(t), Zn (if noZed is off), the effective sample size (Neff in Ref.Invernizzi and Parrinello (2020)), the work (if calcWork is on), the total number of compressed kernels, the number of kernels in the neighbor list (if neighborList is on), and the number of steps from the last neighbor list update (if neighborList is on) will be written to
    “output.colvars.<name>.<replicaID>.misc.traj”.

Similar to the output file specified by the FILE option in the PLUMED implementation, the output file “output.colvars.<name>.<replicaID>.kernels.dat” includes all deposited uncompressed kernels (the step number of deposition, the kernel center, the Gaussian kernel σ, the height of the kernel, and the biasing energy in kB⁢T). The format of .kernels.dat files manages to be compatible with the post-processing tools provided in the PLUMED OPES tutorial, so that it is possible to run State_from_Kernels.py and then FES_from_State.py to get the PMF along the biased CVs. Besides the pmf option, there are two ways to manually estimate the PMF, namely (i) reweighting the trajectories using the biasing energy either in the .colvars.traj file (with outputEnergy) or the .misc.traj file (the <name>.bias column), and (ii) summing up all the kernels (see Ref.Invernizzi and Parrinello (2020) for more information).

6.7.5 Example input

Example: OPES with adaptive kernel bandwidth, neighbor list and PMF based on reweighting.

colvarsTrajFrequency    500 

colvar { 
  name phi 
  lowerBoundary -180 
  upperBoundary 180 
  width 5.0 
  dihedral { 
    group1 {atomNumbers { 5 }}
    group2 {atomNumbers { 7 }}
    group3 {atomNumbers { 9 }}
    group4 {atomNumbers { 15}}
  } 
} 

colvar { 
  name psi 
  lowerBoundary -180 
  upperBoundary 180 
  width 5.0 
  dihedral { 
    group1 {atomNumbers { 7 }} 
    group2 {atomNumbers { 9 }} 
    group3 {atomNumbers { 15 }} 
    group4 {atomNumbers { 17 }} 
  } 
} 

opes_metad { 
  colvars phi psi 
  newHillFrequency 500 
  barrier 11.950286806883364 
  adaptiveSigma on 
  neighborList on 
  printTrajectoryFrequency 500 
  pmf on 
  pmfColvars phi psi 
  pmfHistoryFrequency 1000 
  outputEnergy on 
}

6.8 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⁢(ξ)=12⁢k⁢(ξ−ξ0wξ)2 (45)

There are two noteworthy aspects of this expression:

  1. 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. 2.

    The variable ξ is not only centered at ξ0, but is also scaled by its characteristic length scale wξ (keyword width). The resulting dimensionless variable z=(ξ−ξ0)/wξ is typically easier to treat numerically: for example, when the forces typically experienced by ξ are much smaller than k/wξ and k is chosen equal to κ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ξ, the resulting distributions of ξ are most often optimally overlapped. In regions where the underlying free-energy landscape induces highly skewed distributions of ξ, additional windows may be added as needed, with spacings finer than wξ.

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⁢(ξ1,…,ξM)=12⁢k⁢∑i=1M(ξi−ξ0wξ)2 (46)

If one-dimensional or homogeneous multi-dimensional restraints are defined, and there are no other uses for the parameter wξ, 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)

  • •

    forceConstant — Scaled force constant (energy unit)
    Default: 1.0 [ positive decimal, context: harmonic ]

    This option defines a scaled force constant k for the harmonic potential (eq. 46). 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 κB⁢T (equal to R⁢T if molar units are used), then the amplitude of the thermal fluctuations of each variable ξ will be on the order of its width, wξ. 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ξ2 are always printed when the restraint is defined.

  • •

    centers — Initial harmonic restraint centers
    [ space-separated list of colvar values, context: harmonic ]

    The centers (equilibrium values) of the restraint, ξ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.

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

  • •

    targetCenters — Steer the restraint centers towards these targets
    [ space-separated list of colvar values, context: harmonic ]

    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.

  • •

    targetNumSteps — Number of steps for steering
    [ positive integer, context: harmonic ]

    In single-stage (continuous) transformations, defines the number of MD steps required to move the restraint centers (or force constant) towards the values specified with targetCenters or targetForceConstant. After the target values have been reached, the centers (resp. force constant) are kept fixed. In multi-stage transformations, this sets the number of MD steps per stage.

  • •

    outputCenters — Write the current centers to the trajectory file
    Default: off [ boolean, context: harmonic ]

    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.

6.8.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 6.13).

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

  • •

    targetNumStages — Number of stages for steering
    Default: 0 [ non-negative integer, context: harmonic ]

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

6.8.3 Changing force constant

The force constant of the harmonic restraint may also be changed over time, either to introduce or remove a restraint smoothly, or to estimate a restraint free energyDeng and Roux (2009).

  • •

    targetForceConstant — Change the force constant towards this value
    [ positive decimal, context: harmonic ]

    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 free energy profile for the restrained coordinate.Deng and Roux (2009)

  • •

    lambdaExponent — Exponent in the time-dependence of the force constant
    Default: 1.0 [ decimal equal to or greater than 1.0, context: harmonic ]

    Sets the exponent, α, in the function used to vary the force constant as a function of time. The force is varied according to a coupling parameter λ, raised to the power α: kλ=k0+λα⁢(k1−k0), where k0, kλ, and k1 are the initial, current, and final values of the force constant. The parameter λ 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.

  • •

    decoupling — Perform a restraint decoupling transformation
    Default: off [ boolean, context: harmonic ]

    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λ=(1−λ)α⁢k, where α is the value of lambdaExponent. Setting lambdaExponent to a value greater than 1 (e.g. 4) ensures a smoother dependence of the energy on λ around kλ=0.

  • •

    targetEquilSteps — Number of steps discarded from TI estimate
    Default: 0 [ positive integer, context: harmonic ]

    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.

  • •

    lambdaSchedule — Schedule of lambda-points for changing force constant
    [ list of real numbers between 0 and 1, context: harmonic ]

    If specified together with targetForceConstant, sets the sequence of discrete λ values that will be used for different stages.

6.9 Computing the work of a changing restraint

If the restraint centers or force constant are changed continuosly (targetNumStages undefined) it is possible to record the net work performed by the changing restraint:

  • •

    outputAccumulatedWork — Write the accumulated work of the changing restraint to the Colvars trajectory file
    Default: off [ boolean, context: harmonic ]

    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.

6.10 Harmonic wall restraints

The harmonicWalls {...} bias is closely related to the harmonic bias (see 6.8), 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⁢(ξ)={12⁢k⁢(ξ−ξupperwξ)2if⁢ξ>ξupper0if⁢ξlower≤ξ≤ξupper12⁢k⁢(ξ−ξlowerwξ)2if⁢ξ<ξlower (47)

where ξlower and ξupper are the lower and upper wall thresholds, respectively; (ii) because an interval between two walls is defined, only scalar variables can be used (but any number of variables can be defined, and the wall bias is intrinsically multi-dimensional).

Note: this bias replaces the keywords lowerWall, lowerWallConstant, upperWall and upperWallConstant defined in the colvar context. 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)

  • •

    lowerWalls — Position of the lower wall(s)
    [ Space-separated list of decimals, context: colvar ]

    Defines the values ξlower below which a confining restraint on the colvar is applied to each colvar ξ.

  • •

    upperWalls — Position of the upper wall(s)
    [ Space-separated list of decimals, context: colvar ]

    Defines the values ξupper above which a confining restraint on the colvar is applied to each colvar ξ.

  • •

    forceConstant — same definition as forceConstant (Harmonic restraints)

  • •

    lowerWallConstant — Force constant for the lower wall
    Default: forceConstant [ positive decimal, context: harmonicWalls ]

    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)

  • •

    targetForceConstant — Change the force constant(s) towards this value
    [ positive decimal, context: harmonicWalls ]

    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.

  • •

    targetLowerWalls — Change the lower wall value(s) towards these values
    [ positive decimal, context: harmonicWalls ]

    This keyword allows changing the lower wall position over time. By default, this change is continuous over targetEquilSteps. In that case, the non-equilibrium work performed can be obtained by enabling outputAccumulatedWork. If targetNumStages is provided, the change happens in the given number of increments. See targetNumStages for details.

  • •

    targetUpperWalls — Change the upper wall value(s) towards these values
    [ positive decimal, context: harmonicWalls ]

    Analogous to targetLowerWalls.

  • •

    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)

  • •

    bypassExtendedLagrangian — Apply bias to actual colvars, bypassing extended coordinates
    Default: on [ boolean, context: harmonicWalls ]

    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 
}

6.11 Linear restraints

The linear keyword defines a linear potential:

V⁢(ξ)=k⁢(ξ−ξ0wξ) (48)

whose force is simply given by the constant k/wξ itself:

f⁢(ξ)=k/wξ (49)

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ξ 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 (4.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 Pitera and Chodera (2012). 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 6.12.

  • •

    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)

  • •

    forceConstant — Scaled force constant (energy unit)
    Default: 1.0 [ Decimal, context: linear ]

    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ξ are always printed when the restraint is defined.

  • •

    centers — Initial linear restraint centers
    [ space-separated list of colvar values, context: linear ]

    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)

6.12 Adaptive Linear Bias/Experiment Directed Simulation

Experiment directed simulation applies a linear bias with a changing force constant. Please cite White and Voth White and Voth (2014) 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 6.11 and 6.8 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)

  • •

    centers — Collective variable centers
    [ space-separated list of colvar values, context: alb ]

    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.

  • •

    updateFrequency — The duration of updates
    [ An integer, context: alb ]

    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/2⁢N, 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.

  • •

    forceRange — The expected range of the force constant in units of energy
    Default: 3 kb⁢T [ A space-separated list of decimal numbers, context: alb ]

    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 kb⁢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

  • •

    rateMax — The maximum rate of change of force constant
    [ A list of space-separated real numbers, context: alb ]

    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.

6.13 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: 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∘ and 180∘: 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∘, respectively.

colvar {
  name r
  width 0.2
  upperBoundary 20.0
  distance { ... }
}

colvar {
  name theta
  width 3.0
  dihedral { ... }
}

histogram {
  name hist2d
  colvars r theta
}

The standard keywords below are used to control the histogram’s computation and to select the variables that are sampled. See also 6.1 for keywords used to define the grid, 6.13.1 for output parameters and 6.13.2 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)

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

Note that when gatherVectorColvars is on, each vector variable is automatically treated as a scalar, and a single value of each grid parameter should be provided for it.

6.13.1 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)

  • •

    outputFile — Write the histogram to a file
    Default: output.<name>.dat [ UNIX filename, context: histogram ]

    Name of the file containing histogram data (multicolumn format, see 3.8.4), which is written every outputFreq steps. If outputFile is set to none, the file is not written.

  • •

    outputFileDX — Write the histogram to a file
    Default: output.<name>.dx [ UNIX filename, context: histogram ]

    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.

6.13.2 Histogramming vector variables

  • •

    gatherVectorColvars — Treat vector variables as multiple observations of a scalar variable?
    Default: off [ boolean, context: histogram ]

    When this is set to on, the components of a multi-dimensional colvar (e.g. one based on cartesian, distancePairs) are treated as multiple observations of a scalar variable. This results in the histogram being accumulated multiple times for each simulation step. When multiple vector variables are included in histogram, these must have the same length because their components are accumulated together. For example, if ξ, λ and τ are three variables of dimensions 5, 5 and 1, respectively, for each iteration 5 triplets (ξi,λi,τ) (i=1,…⁢5) are accumulated into a 3-dimensional histogram.

  • •

    weights — Relative contributions of each vector component to the histogram
    Default: all weights equal to 1 [ list of space-separated decimals, context: histogram ]

    When gatherVectorColvars is on, the components of each multi-dimensional colvar are accumulated with a different weight. For example, if x and y are two distinct cartesian variables defined on the same group of atoms, the corresponding 2D histogram can be weighted on a per-atom basis in the definition of histogram.

As with any other biasing and analysis method, when a histogram is applied to an extended-system colvar (4.21), it accesses the value of the extended coordinate rather than that of the actual colvar. This can be overridden by enabling the bypassExtendedLagrangian option. A joint histogram of the actual colvar and the extended coordinate may be collected by specifying the colvar name twice in a row in the colvars parameter (e.g. colvars myColvar myColvar): the first instance will be understood as the actual colvar, and the second, as the extended coordinate.

6.14 Probability distribution-restraints

The histogramRestraint bias implements a continuous potential of many variables (or of a single high-dimensional variable) aimed at reproducing a one-dimensional statistical distribution that is provided by the user. The M variables (ξ1,…,ξM) are interpreted as multiple observations of a random variable ξ with unknown probability distribution. The potential is minimized when the histogram h⁢(ξ), estimated as a sum of Gaussian functions centered at (ξ1,…,ξM), is equal to the reference histogram h0⁢(ξ):

V⁢(ξ1,…,ξM)=12⁢k⁢∫(h⁢(ξ)−h0⁢(ξ))2⁢dξ (50)
h⁢(ξ)=1M⁢2⁢π⁢σ2⁢∑i=1Mexp⁡(−(ξ−ξi)22⁢σ2) (51)

When used in combination with a distancePairs multi-dimensional variable, this bias implements the refinement algorithm against ESR/DEER experiments published by Shen et al Shen et al. (2015).

This bias behaves similarly to the histogram bias with the gatherVectorColvars option, with the important difference that all variables are gathered, resulting in a one-dimensional histogram. Future versions will include support for multi-dimensional histograms.

The list of options is as follows:

  • •

    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)

  • •

    lowerBoundary — Lower boundary of the colvar grid
    [ decimal, context: histogramRestraint ]

    Defines the lowest end of the interval where the reference distribution h0⁢(ξ) is defined. Exactly one value must be provided, because only one-dimensional histograms are supported by the current version.

  • •

    upperBoundary — analogous to lowerBoundary

  • •

    width — Width of the colvar grid
    [ positive decimal, context: histogramRestraint ]

    Defines the spacing of the grid where the reference distribution h0⁢(ξ) is defined.

  • •

    gaussianSigma — Standard deviation of the approximating Gaussian
    Default: 2 × width [ positive decimal, context: histogramRestraint ]

    Defines the parameter σ in eq. 51.

  • •

    forceConstant — Force constant (energy unit)
    Default: 1.0 [ positive decimal, context: histogramRestraint ]

    Defines the parameter k in eq. 50.

  • •

    refHistogram — Reference histogram h0⁢(ξ)
    [ space-separated list of M positive decimals, context: histogramRestraint ]

    Provides the values of h0⁢(ξ) consecutively. The mid-point convention is used, i.e. the first point that should be included is for ξ = lowerBoundary+width/2. If the integral of h0⁢(ξ) is not normalized to 1, h0⁢(ξ) is rescaled automatically before use.

  • •

    refHistogramFile — Reference histogram h0⁢(ξ)
    [ UNIX file name, context: histogramRestraint ]

    Provides the values of h0⁢(ξ) as contents of the corresponding file (mutually exclusive with refHistogram). The format is that of a text file, with each line containing the space-separated values of ξ and h0⁢(ξ). The same numerical conventions as refHistogram are used.

  • •

    writeHistogram — Periodically write the instantaneous histogram h⁢(ξ)
    Default: off [ boolean, context: metadynamics ]

    If on, the histogram h⁢(ξ) is written every colvarsRestartFrequency steps to a file with the name output.<name>.hist.datThis is useful to diagnose the convergence of h⁢(ξ) against h0⁢(ξ).