MultiColvar

Oftentimes, when you do not need one of the collective variables described elsewhere in the manual, what you want instead is a function of a distribution of collective variables of a particular type. In other words, you would like to calculate a function something like this:

\[ s = \sum_i g[f(\{X\}_i)] \]

In this expression \(g\) is a function that takes in one argument and \(f\) is a function that takes a set of atomic positions as argument. The symbol \(\{X\}_i\) is used to indicate the fact that the function \(f\) is evaluated for a number of different sets of atoms. If you would just like to output the values of all the various \(f\) functions you should use the command DUMPMULTICOLVAR

This functionality is useful if you need to calculate a minimum distance or the number of coordination numbers greater than a 3.0.
To avoid duplicating the code to calculate an angle or distance many times and to make it easier to implement very complex collective variables PLUMED provides these sort of collective variables using so-called MultiColvars. MultiColvars are named in this way because a single PLUMED action can be used to calculate a number of different collective variables. For instance the DISTANCES action can be used to calculate the minimum distance, the number of distances less than a certain value, the number of distances within a certain range... A more detailed introduction to multicolvars is provided in this 10-minute video. Descriptions of the various multicolvars that are implemented in PLUMED 2 are given below:

ALPHABETA Calculate the alpha beta CV
AROUND_CALC Calculate a vector from the input positions with elements equal to one when the positions are in a particular part of the cell and elements equal to zero otherwise
ATOMIC_SMAC Calculate the atomic smac CV
BRIDGE Calculate a matrix with elements equal to one if there is a bridging atom between the two atoms
BRIDGE_MATRIX Calculate the number of atoms that bridge two parts of a structure
CAVITY_CALC Calculate a vector from the input positions with elements equal to one when the positions are in a particular part of the cell and elements equal to zero otherwise
CHARGE Get the charges of one or multiple atoms
CHARGE_SCALAR Get the charges of one or multiple atoms
CHARGE_VECTOR Get the charges of one or multiple atoms
CONCATENATE Join vectors or matrices together
COORDINATIONNUMBER Calculate the coordination numbers of atoms so that you can then calculate functions of the distribution of coordination numbers such as the minimum, the number less than a certain quantity and so on.
COORDINATION_MOMENTS Calculate moments of the distribution of distances in the first coordination sphere
COORDINATION_SHELL_AVERAGE Calculate an arbitrary function of all the bond vectors in the first coordination sphere of an atom and take an average
COORDINATION_SHELL_FUNCTION Calculate an arbitrary function of all the bond vectors in the first coordination sphere of an atom
COORD_ANGLES Calculate all the angles between bonds in the first coordination spheres of a set of atoms
CYLINDRICAL_HARMONIC Calculate the cylindrical harmonic function
CYLINDRICAL_HARMONIC_MATRIX Calculate the cylindrical harmonic function from the elements in two input matrices
DENSITY Depreciated command that is bascially equivalant to GROUP.
DETERMINANT Calculate the determinant of a matrix
DIPOLE_VECTOR Calculate a vector of dipole moments for a set of groups of atoms.
DISPLACEMENT Calculate the displacement vector between the pair of input vectors
DISTANCES Calculate the distances between multiple piars of atoms
DISTANCE_SCALAR Calculate the distance between a pair of atoms
DISTANCE_VECTOR Calculate a vector containing the distances between various pairs of atoms
DUMPMULTICOLVAR Basically equivalent to DUMPATOMS
ENVIRONMENTSIMILARITY Measure how similar the environment around atoms is to that found in some reference crystal structure.
EUCLIDEAN_DISTANCE Calculate the euclidean distance between two vectors of arguments
FCCUBIC Measure how similar the environment around atoms is to that found in a FCC structure.
FCCUBIC_FUNC Measure how similar the environment around atoms is to that found in a FCC structure.
FCCUBIC_FUNC_MATRIX Measure how similar the environment around atoms is to that found in a FCC structure.
GRADIENT Calculate the gradient of an input grid
GYRATION_TENSOR Calculate the gyration tensor using a user specified vector of weights
HEXACTIC_PARAMETER Calculate the hexatic order parameter
INCYLINDER_CALC Calculate a vector from the input positions with elements equal to one when the positions are in a particular part of the cell and elements equal to zero otherwise
INPLANEDISTANCES Calculate the distance between a pair of atoms in the plane
INSPHERE_CALC Calculate a vector from the input positions with elements equal to one when the positions are in a particular part of the cell and elements equal to zero otherwise
INVERT_MATRIX Calculate the inverse of the input matrix
LOCAL_CRYSTALINITY Calculate the local crystalinity symmetry function
MASS Get the mass of one or multiple atoms
MASS_SCALAR Get the mass of one or multiple atoms
MASS_VECTOR Get the mass of one or multiple atoms
MATRIX_PRODUCT Calculate the product of two matrices
MATRIX_VECTOR_PRODUCT Calculate the product of the matrix and the vector
MFILTER_LESS Basically equivalent to LESS_THAN.
MFILTER_MORE Basically equivalent to MORE_THAN.
NEIGHBORS Build a matrix with ones in for the N nearest neighbours of an atom
PAIRENTROPIES Calculate the KL entropy from the RDF around each of the atoms
PAIRENTROPY Calculate the KL Entropy from the radial distribution function
PLANES Calculate the components of the normal to the plane containing three atoms
Q1 Calculate 1st order Steinhardt parameters
Q3 Calculate 3rd order Steinhardt parameters.
Q4 Calculate fourth order Steinhardt parameters.
Q6 Calculate sixth order Steinhardt parameters.
QUATERNION_BOND_PRODUCT_MATRIX Calculate the product between a matrix of quaternions and the bonds
QUATERNION_PRODUCT_MATRIX Calculate the outer product matrix from two vectors of quaternions
SECONDARY_STRUCTURE_RMSD Calclulate the distance between segments of a protein and a reference structure of interest
SIMPLECUBIC Calculate whether or not the coordination spheres of atoms are arranged as they would be in a simple cubic structure.
SMAC Calculate the SMAC order parameter for a set of molecules
SPHERICAL_HARMONIC Calculate the values of all the spherical harmonic funtions for a particular value of l.
SPHERICAL_HARMONIC_MATRIX Calculate the values of all the spherical harmonic funtions for a particular value of l for all the elements of a set of three input matrices
TETRAHEDRAL Calculate the degree to which the environment about ions has a tetrahedral order.
TETRAHEDRALPORE_CALC Calculate a vector from the input positions with elements equal to one when the positions are in a particular part of the cell and elements equal to zero otherwise
TETRA_ANGULAR Calculate the angular tetra CV
TETRA_RADIAL Calculate the radial tetra CV
TORSIONS Calculate whether or not a set of torsional angles are within a particular range.
TORSIONS_MATRIX Calculate the matrix of torsions between two vectors of molecules
TORSION_VECTOR Calculate multiple torsional angles.
TRANSPOSE Calculate the transpose of a matrix
UWALLS Add lower walls to a vector of quantities
VORONOI Do a voronoi analysis
VSTACK Create a matrix by stacking vectors together
XDISTANCES Calculate the x components of the vectors connecting one or many pairs of atoms.You can then calculate functions of the distribution of values such as the minimum, the number less than a certain quantity and so on.
YDISTANCES Calculate the y components of the vectors connecting one or many pairs of atoms.You can then calculate functions of the distribution of values such as the minimum, the number less than a certain quantity and so on.
ZDISTANCES Calculate the z components of the vectors connecting one or many pairs of atoms.You can then calculate functions of the distribution of values such as the minimum, the number less than a certain quantity and so on.

To instruct PLUMED to calculate a multicolvar you give an instruction that looks something like this:

NAME <atoms involved> <parameters> <what am I calculating> TOL=0.001 LABEL=label

Oftentimes the simplest way to specify the atoms involved is to use multiple instances of the ATOMS keyword i.e. ATOMS1, ATOMS2, ATOMS3,... Separate instances of the quantity specified by NAME are then calculated for each of the sets of atoms. For example if the command issued contains the following:

Click on the labels of the actions for more information on what each action computes
tested on master
DISTANCES 
ATOMS1
the pairs of atoms that you would like to calculate the angles for.
=1,2
ATOMS2
the pairs of atoms that you would like to calculate the angles for.
=3,4
ATOMS3
the pairs of atoms that you would like to calculate the angles for.
=5,6

The distances between atoms 1 and 2, atoms 3 and 4, and atoms 5 and 6 are calculated. Obviously, generating this sort of input is rather tedious so short cuts are also available many of the collective variables. These are described on the manual pages for the actions.

After specifying the atoms involved you sometimes need to specify some parameters that required in the calculation. For instance, for COORDINATIONNUMBER - the number of atoms in the first coordination sphere of each of the atoms in the system - you need to specify the parameters for a switchingfunction that will tell us whether or not an atom is in the first coordination sphere. Details as to how to do this are provided on the manual pages.

One of the most important keywords for multicolvars is the TOL keyword. This specifies that terms in sums that contribute less than a certain value can be ignored. In addition, it is assumed that the derivative with respect to these terms are essentially zero. By increasing the TOL parameter you can increase the speed of the calculation. Be aware, however, that this increase in speed is only possible because you are lowering the accuracy with which you are computing the quantity of interest.

Once you have specified the base quantities that are to be calculated from the atoms involved and any parameters you need to specify what function of these base quantities is to be calculated. For most multicolvars you can calculate the minimum, the number less than a target value, the number within a certain range, the number more than a target value and the average value directly.

MultiColvar functions

It is possible to use multicolvars to calculate complicated collective variables by exploiting the fact that the output from one multicolvar can be used as input to a second multicolvar. One simple way of exploiting this functionality is to filter the atoms based on the value they have for a symmetry function. For example you might want to consider only those atoms that with a COORDINATIONNUMBER higher that a certain threshold when calculating some particularly expensive symmetry function such as Q6. The following methods can thus all be used to filter the values of multicolvars in this way:

An alternative way of filtering atoms is to consider only those atoms in a particular part of the simulation box. This can be done by exploiting the following methods

AROUND This quantity can be used to calculate functions of the distribution of collective variables for the atoms that lie in a particular, user-specified part of of the cell.
CAVITY This quantity can be used to calculate functions of the distribution of collective variables for the atoms that lie in a box defined by the positions of four atoms.
INCYLINDER This quantity can be used to calculate functions of the distribution of collective variables for the atoms that lie in a particular, user-specified part of of the cell.
INENVELOPE This quantity can be used to calculate functions of the distribution of collective variables for the atoms that lie in a region where the density of a certain type of atom is high.
INENVELOPE_CALC This quantity can be used to calculate functions of the distribution of collective variables for the atoms that lie in a region where the density of a certain type of atom is high.
INSPHERE This quantity can be used to calculate functions of the distribution of collective variables for the atoms that lie in a particular, user-specified part of of the cell.
TETRAHEDRALPORE This quantity can be used to calculate functions of the distribution of collective variables for the atoms lie that lie in a box defined by the positions of four atoms at the corners of a tetrahedron.

The idea with these methods is that function of the form:

\[ s = \sum_i w(\{X\}_i) g[f(\{X\}_i)] \]

can be evaluated where once again \(g\) is a function with one argument and \(g\) is a function of a set of atomic positions.
The difference from the more general function described earlier is that we now have a weight \(w\) which is again a function of the atomic positions. This weight varies between zero and one and it is this weight that is calculated in the list of filtering methods and volume methods described in the lists above.

In addition to these volume and filtering methods it is also possible to calculate the local average of a quantities in the manner described in [65] using the LOCAL_AVERAGE method. Furthermore, in many cases Q6, MOLECULES and PLANES the symmetry function being evaluated is a vector. You can thus construct a variety of novel collective variables by taking dot products of vectors on adjacent atoms as described below:

LOCAL_AVERAGE Calculate averages over spherical regions centered on atoms
LOCAL_Q1 Calculate the local degree of order around an atoms by taking the average dot product between the q_1 vector on the central atom and the q_3 vector on the atoms in the first coordination sphere.
LOCAL_Q3 Calculate the local degree of order around an atoms by taking the average dot product between the q_3 vector on the central atom and the q_3 vector on the atoms in the first coordination sphere.
LOCAL_Q4 Calculate the local degree of order around an atoms by taking the average dot product between the q_4 vector on the central atom and the q_4 vector on the atoms in the first coordination sphere.
LOCAL_Q6 Calculate the local degree of order around an atoms by taking the average dot product between the q_6 vector on the central atom and the q_6 vector on the atoms in the first coordination sphere.
PAMM Probabilistic analysis of molecular motifs.

The final set of functions that you can apply on multicolvars are functions that transform all the colvars calculated using a multicolvar using a function. This can be useful if you are calculating some complicated derived quantity of some simpler quantity. It is also useful if you are calculating a Willard Chandler surface or a histogram. The actions that you can use to perform these transforms are:

MultiColvar bias

There may be occasions when you want add restraints on many collective variables. For instance if you are studying a cluster you might want to add a wall on the distances between each of the atoms and the center of mass of the cluster in order to prevent the cluster subliming. Alternatively, you may wish to insist that a particular set of atoms in your system all have a coordination number greater than 2. You can add these sorts of restraints by employing the following biases, which all act on the set of collective variable values calculated by a multicolvar. So for example the following set of commands:

Click on the labels of the actions for more information on what each action computes
tested on master