Here, we document the syntax of the commands and parameters used to set up and use the Colvars module in Tinker-HP. One of these parameters is the configuration file or the configuration text for the module itself, whose syntax is described in 3.3 and in the following sections.
The “internal units” of the Colvars module are the units in which values are expressed in the configuration file, and in which collective variable values, energies, etc. are expressed in the output and colvars trajectory files. Generally the Colvars module uses internally the same units as its back-end MD engine, with the exception of VMD, where different unit sets are supported to allow for easy setup, visualization and analysis of Colvars simulations performed with any simulation engine.
Note that angles are expressed in degrees, and derived quantities such as force constants are based on degrees as well. Some colvar components have default values, expressed in Ångström (Å) in this documentation. They are converted to the current length unit, if different from Å. Atomic coordinates read from XYZ files (and PDB files where applicable) are expected to be expressed in Ångström, no matter what unit system is in use by the back-end (Tinker-HP) or the Colvars Module. They are converted internally to the current length unit as needed. Note that force constants in harmonic and harmonicWalls biases (6.8) are rescaled according to the width parameter of colvars, so that they are formally in energy units, although if width is given its default value of 1.0, force constants are effectively expressed in kcal/mol/(colvar unit)2.
To avoid errors due to reading configuration files written in a different unit system, it can be specified within the input:
units — Unit system to be used
[ string, context: global ]
A string defining the units to be used internally by Colvars. In Tinker-HP, the only supported value is Tinker-HP’s native units: real (Å, kcal/mol).
To enable Colvars within a Tinker-HP run, just provide a Colvars configuration file with the same prefix as the .key file, and the extension .colvars. Tcl-scripted variables and biases may be defined by sourcing a script file using the sourceTclFile option.
Configuration for the Colvars module is passed using an external file. Configuration lines follow the format “keyword value” or “keyword { ... }”, where the keyword and its value must be separated by one or more space characters. The following formatting rules apply:
Keywords are case-insensitive; for example, upperBoundary is the same as upperboundary and UPPERBOUNDARY); note that their string values are however still case-sensitive (e.g. names of variables, file names).
A long value, or a list of multiple values, can be distributed across multiple lines by using curly braces, “{” and “}”: the opening brace “{” must occur on the same line as the keyword, following at least one space character; the closing brace “}” may be at any position after that; any keywords following the closing brace on the same line are not valid (they should appear instead on a different line).
Many keywords are nested, and are only meaningful within the specific context of another keyword; for example, the keyword name is available inside the block of the keyword colvar {...}, but not outside of it; for every keyword documented in the following, the “parent” keyword that defines such context is also indicated.
If a keyword requiring a boolean value (yes|on|true or no|off|false) is provided without an explicit value, it defaults to ‘yes|on|true’; for example, ‘outputAppliedForce’ may be used as shorthand for ‘outputAppliedForce on’.
The hash character “#” indicates a comment: all text in the same line following this character will be ignored.
Outside of comments, only ASCII characters are allowed for defining keywords, and the only white-space characters supported are spaces, tabs and newlines: a warning will be printed upon detection of non-ASCII characters in a configuration line, which include both characters that are visibly “special”, as well as those with a very similar appearance to ASCII ones (for instance, non-breaking spaces); common ways to identify/remove non-ASCII characters are using the Emacs text editor, or using LC_ALL=C vi.
The following keywords are available in the global context of the Colvars configuration, i.e. they are not nested inside other keywords:
colvarsTrajFrequency — Colvar value trajectory frequency
Default: 100 [ positive integer, context: global ]
The values of each colvar (and of other related quantities, if requested) are written to the file output.colvars.traj every these many steps throughout the simulation. If the value is 0, such trajectory file is not written. For optimization the output is buffered, and synchronized with the disk only when the restart file is being written.
colvarsRestartFrequency — Colvar module restart frequency
Default: [ positive integer, context: global ]
When this value is non-zero, a state file suitable for restarting will be written every these many steps. Additionally, any other output files produced by Colvars are written as well (except the trajectory file, which is written every colvarsTrajFrequency steps). It is generally a good idea to leave this parameter at its default value, unless needed for special cases or to disable automatic writing of output files altogether.
indexFile — Index file for atom selection (GROMACS “ndx” format)
[ UNIX filename, context: global ]
This option reads an index file (usually with a .ndx extension) as produced by the make_ndx tool of GROMACS. This keyword may be repeated to load multiple index files. A group with the same name may appear multiple times, as long as it contains the same indices in identical order each time: an error is raised otherwise. The names of index groups contained in this file can then be used to define atom groups with the indexGroup keyword. Other supported methods to select atoms are described in 5.
smp — Whether SMP parallelism should be used
Default: on [ boolean, context: global ]
If this flag is enabled (default), SMP parallelism over threads will be used to compute variables and biases, provided that this is supported by the Tinker-HP build in use.
sourceTclFile — Tcl file to be sourced at startup
[ UNIX filename, context: global ]
This option causes the provided Tcl script file to be loaded at startup, e.g. to initialize the Tcl callback procedures for scripted variables or biases. This is the only way to define such callbacks in Tinker-HP.
Several of the sampling methods implemented in Colvars are time- or history-dependent, i.e. they work by accumulating data as a simulation progresses, and use these data to determine their biasing forces. If the simulation engine uses a checkpoint or restart file (as GROMACS and LAMMPS do), any data needed by Colvars are embedded into that file. Otherwise, a dedicated state file can be loaded into Colvars directly.
When a dedicated Colvars state file is used, it may be in either one of two formats:
Formatted, i.e. “text” format, which takes more space and is slower to to load/save but is also portable across different platforms and even different simulation engines (save for changes in physical units). This format is used by default, unless explicitly requested otherwise.
Unformatted, i.e. “binary” format, which is both space-efficient and quick to load/save, but requires that the same Tinker-HP build was used to write the file and that the Colvars configuration remains the same. This format is supported by Colvars versions starting 2023-09-25. Colvars state files can be written in binary format by setting the environment variable “COLVARS_BINARY_RESTART” to 1.
In either format, the state file contains accumulated data as well as the step number at the end of the run. The step number read from a state file overrides any value that Tinker-HP provides, and will be incremented if the simulation proceeds. This means that the step number used internally by Colvars may not always match the step number reported by Tinker-HP.
In some cases, it is useful to modify the configuration of variables or biases between consecutive runs, for example by adding or removing a restraint. Some special provisions will happen in that case. When a state file is loaded, no information is available about any newly added variable or bias, which will thus remain uninitialized until the first compute step. Conversely, any information that the state file may contain about variables or biases that are no longer defined will be silently ignored. Please note that these checks are performed based only on the names of variables and biases: it is your responsibility to ensure that these names have consistent definitions between runs.
The flexibility just described carries some limitations: namely, it is only supported when reading text-format Colvars state files. Instead, restarting from binary files after a configuration change will trigger an error. It is also important to remind that when switching to a different build of Tinker-HP, the binary format may change slightly, even if the release version is the same.
To work around the potential issues just described, a text-format Colvars state file should be loaded.
When the output prefix output is defined, the following output files are written during a simulation run:
A state file, named output.colvars.state, which is written at the end of the specified run. This file is in plain text format by default, or in binary format if the environment variable COLVARS_BINARY_RESTART is set to a non-zero integer. The state file can be used to continue a simulation: unless its contents are embedded in the checkpoint file of the MD engine itself (currently, GROMACS and LAMMPS support this), instructions for loading the Colvars state file will be required in the simulation script (see 3.5).
If the parameter colvarsRestartFrequency is larger than zero and the restart prefix is defined, a restart file is written every that many steps: this file is fully equivalent to the final state file. The name of this file is restart.colvars.state.
If the parameter colvarsTrajFrequency is greater than 0 (default value: 100 steps), a trajectory file, named output.colvars.traj, is written during the simulation. Unlike a state file, this file is not needed to restart a simulation, but can be used for post-processing and analysis. The format of this file is described in sec. 3.7.5.
Additionally, certain features, when enabled, can emit output files with a specific purpose: for example, potentials of mean force (PMFs) can be written to file to be analyzed or plotted. These files are described in the respective sections, but as a general rule they all use names beginning with the output prefix. Like the trajectory file, these additional files are needed only for analyzing a simulation’s results, but not to continue it.
This section summarizes the file formats of various files that Colvars may be reading or writing.
Configuration files are text files that are generally read as input by Tinker-HP. Starting from version 2017-02-01, changes in newline encodings are handled transparently, i.e. it is possible to typeset a configuration file in Windows (CR-LF newlines) and then use it with Linux or macOS (LF-only newlines).
Formatted state files, although not written manually, follow otherwise the same text format as configuration files. Binary state files can only be read by the Colvars code itself.
For atom selections that cannot be specified only by using internal Colvars keywords, external index files may also be used following the NDX format used in GROMACS:
[ group_1_name ] i1 i2 i3 i4 ... ... ... iN [ group_2_name ] ...where i1 through iN are 1-based indices. Each group name may not contain spaces or tabs: otherwise, a parsing error will be raised.
Multiple index files may be provided to Colvars, each using the keyword indexFile. Two index files may contain groups with the same names, however these must also represent identical atom selections, i.e. the same sequence of indices including order.
Other than with GROMACS, an index group may also be generated from the VMD command-line interface, using the helper function write_index_group provided in the colvartools folder:
source colvartools/write_index_group.tcl set sel [atomselect top "resname XXX and not hydrogen"] write_index_group indexfile.ndx $sel "Ligand"
XYZ coordinate files are text files with the extension “.xyz”. They are read by the Colvars module using an internal reader, and expect the following format:
| Comment | line | ||
| … | |||
where is the number of atomic coordinates in the file and is the chemical element of the -th atom. Because is not used in Colvars, any string that does not contain tabs or spaces is acceptable.
Note: all XYZ coordinates are assumed to be expressed in Å units.
An XYZ file may contain either one of the following scenarios:
The file contains as many coordinates as the atoms that they are being read for: all coordinates will be read from the file following the same order as the atoms appear in the selection generated using the keywords listed in section 5. (Note that the order is guaranteed only if a single type of selection keyword is used one or more times, and not guaranteed when different types of selection keywords are used.)
The file contains more coordinates than needed, and it is assumed to contain coordinates for the entire system: only coordinates that match the numeric indices of the selected atoms are read, in order of increasing number.
XYZ-file coordinates are read directly by Colvars and stored internally as double-precision floating point numbers.
Many simulation methods and analysis tools write files that contain functions of the collective variables tabulated on a grid (e.g. potentials of mean force or multidimensional histograms) for the purpose of analyzing results. Such files are produced by ABF (6.3), metadynamics (6.6), multidimensional histograms (6.13), as well as any restraint with optional thermodynamic integration support (6.2).
In some cases, these files may also be read as input of a new simulation.
Suitable input files for this purpose are typically generated as output files of previous simulations, or directly by the user in the specific case of ensemble-biased metadynamics (6.6.5).
This section explains the “multicolumn” format used by these files.
For a multidimensional function the multicolumn grid format is defined as follows:
| # | ||||||
| # | ||||||
| # | ||||||
| # | … | … | … | … | ||
| # | ||||||
| … | f(, , …, ) | |||||
| … | f(, , …, ) | |||||
| … | … | … | … | … |
Lines beginning with the character “#” are the header of the file. is the number of collective variables sampled by the grid. For each variable , is the lowest value sampled by the grid (i.e. the left-most boundary of the grid along ), is the width of each grid step along , is the number of points and is a flag whose value is 1 or 0 depending on whether the grid is periodic along . In most situations:
is given by the lowerBoundary keyword of the variable ;
is given by the width keyword;
is calculated from the two above numbers and the upperBoundary keyword;
is set to 1 if and only if is periodic and the grids’ boundaries cover its period.
How the grid’s boundaries affect the sequence of points depends on how the contents of the file were computed. In many cases, such as histograms and PMFs computed by metadynamics (6.6.5), the values of in the first few columns correspond to the midpoints of the corresponding bins, i.e. . However, there is a slightly different format in PMF files computed by ABF (6.3) or other biases that use thermodynamic integration (6.2). In these cases, it is free-energy gradients that are accumulated on an (npoints)-long grid along each variable : after these gradients are integrated, the resulting PMF is discretized on a slightly larger grid with (npoints+1) points along (unless the interval is periodic). Therefore, the grid’s outer edges extend by above and below the specified boundaries, so that for instance in the header appears to be shifted back by compared to what would be expected. Please keep this difference in mind when comparing PMFs computed by different methods.
After the header, the rest of the file contains values of the tabulated function
, one for each line.
The first columns contain values of , , … and the last column contains the value of the function .
Points are sorted in ascending order with the fastest-changing values at the right (“C-style” order).
Each sweep of the right-most variable is terminated by an empty line.
For two dimensional grid files, this allows quick visualization by programs such as GNUplot.
Example 1: multicolumn text file for a one-dimensional histogram with lowerBoundary = 15, upperBoundary = 48 and width = 0.1.
| # | 1 | ||||
|---|---|---|---|---|---|
| # | 15 | 0.1 | 330 | 0 | |
| 15.05 | 6.14012e-07 | ||||
| 15.15 | 7.47644e-07 | ||||
| … | … | ||||
| 47.85 | 1.65944e-06 | ||||
| 47.95 | 1.46712e-06 |
Example 2: multicolumn text file for a two-dimensional histogram of two dihedral angles (periodic interval with 6∘ bins):
| # | 2 | ||||
| # | -180.0 | 6.0 | 30 | 1 | |
| # | -180.0 | 6.0 | 30 | 1 | |
| -177.0 | -177.0 | 8.97117e-06 | |||
| -177.0 | -171.0 | 1.53525e-06 | |||
| … | … | … | |||
| -177.0 | 177.0 | 2.442956-06 | |||
| -171.0 | -177.0 | 2.04702e-05 | |||
| … | … | … |
The Colvars trajectory file (with a suffix .colvars.traj) is a plain text file (scientific notation with 14-digit precision) whose columns represent quantities such as colvar values, applied forces, or individual restraints’ energies. Under most scenarios, plotting or analyzing this file is straightforward: for example, the following contains a variable “” and the energy of a restraint “”:
# step A E_rA
0 1.42467449615693e+01 6.30982865292123e+02
100 1.42282559728026e+01 6.20640585041317e+02
…
Occasionally, if the Colvars configuration is changed mid-run certain quantities may be added or removed, changing the column layout. Labels in comment lines can assist in such cases: for example, consider the trajectory above with the addition of a second variable, “”, after 10,000 steps:
# step A E_rA
0 1.42467449615693e+01 6.30982865292123e+02
100 1.42282559728026e+01 6.20640585041317e+02
…
# step A B E_rA
10000 1.38136915830229e+01 9.99574098859265e-01 4.11184644791030e+02
10100 1.36437184346326e+01 9.99574091957314e-01 3.37726286543895e+02
Analyzing the above file with standard tools is possible, but laborious: a convenience script is provided for this and related purposes. It may be used either as a command-line tool or as a Python module:
>>> from plot_colvars_traj import Colvars_traj
>>> traj = Colvars_traj('test.colvars.traj')
>>> print(traj['A'].steps, traj['A'].values)
[ 0 100 ... 10000 10100] [14.246745 14.228256 ... 13.813692 13.643718]
>>> print(traj['B'].steps, traj['B'].values)
[10000 10100] [0.999574 0.9995741]