Skip to content

Shortcut: DISTANCES

Module multicolvar
Description Usage
Calculate the distances between multiple piars of atoms used in 3 tutorialsused in 28 eggs
output value type
the DISTANCES between the each pair of atoms that were specified vector

Deprecated

This action has been deprecated and is no longer supported. Use DISTANCE instead.

Details and examples

Calculate the distances between multiple piars of atoms

This shortcut action allows you to calculate function of the distribution of distances and reproduces the syntax in older PLUMED versions. We think that the syntax in newer versions is more flexible and easier to use and that you should try to avoid using this old syntax. If you look at the example inputs below you can see how the new syntax can be used to replace this old one. We would strongly encourage you to use the newer syntax.

The following input tells plumed to calculate the distances between atoms 3 and 5 and between atoms 1 and 2 and to print the shorter of these two distances.

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details ATOMS1the pairs of atoms that you would like to calculate the angles for=3,5 ATOMS2the pairs of atoms that you would like to calculate the angles for=1,2 LOWEST this flag allows you to recover the lowest of these variables
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.lowest

The following input tells plumed to calculate the distances between atoms 3 and 5 and between atoms 1 and 2 and then to calculate the number of these distances that are less than 0.1 nm. The number of distances less than 0.1nm is then printed to a file.

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details ATOMS1the pairs of atoms that you would like to calculate the angles for=3,5 ATOMS2the pairs of atoms that you would like to calculate the angles for=1,2 LESS_THANcalculate the number of variables that are less than a certain target value. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL R_0=0.1}
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.lessthan

The following input tells plumed to calculate all 3 distances between atoms 1, 2 and 3 (i.e. the distances between atoms 1 and 2, atoms 1 and 3 and atoms 2 and 3). The average of these distances is then calculated in two ways.

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details GROUPCalculate the distance between each distinct pair of atoms in the group=1-3 MEAN calculate the mean of all the quantities SUM calculate the sum of all the quantities
d1mean: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=d1.sum FUNCthe function you wish to evaluate=x/3 PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.mean,d1mean

The following input tells plumed to calculate all the distances between the atoms in GROUPA and the atoms in GROUPB. In other words the distances between atoms 1 and 2 and the distance between atoms 1 and 3. The number of distances more than 0.1 is then printed to a file.

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details GROUPACalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=1 GROUPBCalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=2,3 MORE_THANcalculate the number of variables that are more than a certain target value. Options for this keyword are explained in the documentation for MORE_THAN.={RATIONAL R_0=0.1}
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.morethan

Calculating minimum distances

There are various way for calculating the minimum distance between two groups of atoms. The simplest one is the one we saw above; namely:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details GROUPACalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=1-10 GROUPBCalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=11-20 LOWEST this flag allows you to recover the lowest of these variables
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.lowest

A disadvantage of this approach is that the derivatives of the resulting value are not continuous. To be clear, the value of the shortest distance is continuous when you use this approach so you will likely be fine if you use the quantity output by the command above as an input in a bias. However, if you would like to use a quantity with continuous derivatives for the minimum distance you can use the following input:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details GROUPACalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=1-10 GROUPBCalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=11-20 MINcalculate the minimum value={BETA=500.}
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.min FILEthe name of the file on which to output these quantities=colvar STRIDE the frequency with which the quantities of interest should be output=10

In order to ensure that the minimum value has continuous derivatives we use the following function:

where is a user specified parameter.

This input is used rather than a separate MINDIST colvar so that the same routine and the same input style can be used to calculate minimum coordination numbers (see COORDINATIONNUMBER), minimum angles (see ANGLES) and many other variables. If you expand the input above you will notice that the DISTANCES command is a shortcut. By expanding this shortcut you can see how PLUMED calculates the minimum distance.

An alternative implementation of the minimum distance is provided through the ALT_MIN keyword that is demonstrated below:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details GROUPACalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=1-10 GROUPBCalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=11-20 ALT_MINcalculate the minimum value={BETA=500.}
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.altmin FILEthe name of the file on which to output these quantities=colvar STRIDE the frequency with which the quantities of interest should be output=10

The minimum value output by this command also has continuous derivatives and is evaluated using the following function:

Calculating maximum distances

There are two ways for calculating the maximum distance between two groups of atom. The simplest one is:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details GROUPACalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=1-10 GROUPBCalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=11-20 HIGHEST this flag allows you to recover the highest of these variables
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.highest

As with LOWEST above a disadvantage of this approach is that the derivatives of the resulting value are not continuous. If you would like to use a quantity with continuous derivatives for the maximum distance you can use the following input:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details GROUPACalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=1-10 GROUPBCalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=11-20 MAXcalculate the maximum value={BETA=500.}
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.max

The maximum value output by this command is evaluated using the following function:

Other parts of the old multicolvar syntax

The ways of calculating the minimum and maximum distance described above are part of plumed 2's multicolvar functionality. In older versions of PLUMED these special actions allowed you to calculate multiple functions of a distribution of simple collective variables. As an example you can calculate the number of distances less than 1.0, the minimum distance, the number of distances more than 2.0, the number of distances between 1.0 and 2.0 and histogram that esimates the distribution of distances by using the following command:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d1: DISTANCESCalculate the distances between multiple piars of atoms This action is a shortcut. More details ...
 GROUPACalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=1-10 GROUPBCalculate the distances between all the atoms in GROUPA and all the atoms in GROUPB=11-20
 LESS_THANcalculate the number of variables that are less than a certain target value. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL R_0=1.0}
 MORE_THANcalculate the number of variables that are more than a certain target value. Options for this keyword are explained in the documentation for MORE_THAN.={RATIONAL R_0=2.0}
 BETWEENcalculate the number of values that are within a certain range. Options for this keyword are explained in the documentation for BETWEEN.={GAUSSIAN LOWER=1.0 UPPER=2.0}
 HISTOGRAMcalculate a discretized histogram of the distribution of values={GAUSSIAN LOWER=0.0 UPPER=4.0 NBINS=10}
 MINcalculate the minimum value={BETA=500.}
...
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1.* FILEthe name of the file on which to output these quantities=colvar STRIDE the frequency with which the quantities of interest should be output=10

A calculation performed this way is fast because the expensive part of the calculation - the calculation of all the distances - is only done once per step. If you expand the shortcut in the input above you can see how this result is achieved using a combination of many actions. We recommend you use these combinations of actions rather than the shortcut when using newer versions of PLUMED as you will have a more control over what you are doing. This newer input syntax is easier to understand especially when you start evaluating more complicated CVs.

Input

The atoms that serve as the input for this action are specified using one or more of the keywords in the following table.

Keyword Type Description
GROUP atoms Calculate the distance between each distinct pair of atoms in the group
GROUPA atoms Calculate the distances between all the atoms in GROUPA and all the atoms in GROUPB
GROUPB atoms Calculate the distances between all the atoms in GROUPA and all the atoms in GROUPB
ATOMS atoms the pairs of atoms that you would like to calculate the angles for
ORIGIN atoms calculate the distance of all the atoms specified using the ATOMS keyword from this point
LOCATION atoms the location at which the CV is assumed to be in space

Output components

This action can calculate the values in the following table when the associated keyword is included in the input for the action. These values can be referenced elsewhere in the input by using this Action's label followed by a dot and the name of the value required from the list below.

Name Type Keyword Description
lessthan scalar LESS_THAN the number of colvars that have a value less than a threshold
morethan scalar MORE_THAN the number of colvars that have a value more than a threshold
altmin scalar ALT_MIN the minimum value of the cv
min scalar MIN the minimum colvar
max scalar MAX the maximum colvar
between scalar BETWEEN the number of colvars that have a value that lies in a particular interval
highest scalar HIGHEST the largest of the colvars
lowest scalar LOWEST the smallest of the colvars
sum scalar SUM the sum of the colvars
mean scalar MEAN the mean of the colvars
x vector COMPONENTS the x-components of the distance vectors
y vector COMPONENTS the y-components of the distance vectors
z vector COMPONENTS the z-components of the distance vectors

Full list of keywords

The following table describes the keywords and options that can be used with this action

Keyword Type Default Description
GROUP input none Calculate the distance between each distinct pair of atoms in the group
GROUPA input none Calculate the distances between all the atoms in GROUPA and all the atoms in GROUPB
GROUPB input none Calculate the distances between all the atoms in GROUPA and all the atoms in GROUPB
ATOMS input none the pairs of atoms that you would like to calculate the angles for
ORIGIN input none calculate the distance of all the atoms specified using the ATOMS keyword from this point
LOCATION input none the location at which the CV is assumed to be in space
NOPBC optional false ignore the periodic boundary conditions when calculating distances
COMPONENTS optional false calculate the x, y and z components of the distance separately and store them as label
SCALED_COMPONENTS optional false calculate the a, b and c scaled components of the distance separately and store them as label
LOWMEM optional not used Including this keyword in the input to this action makes no difference to the calculation performed it was used in older versions of PLUMED and is provided here for back compatibility only
LESS_THAN optional not used calculate the number of variables that are less than a certain target value. Options for this keyword are explained in the documentation for LESS_THAN.
MORE_THAN optional not used calculate the number of variables that are more than a certain target value. Options for this keyword are explained in the documentation for MORE_THAN.
ALT_MIN optional not used calculate the minimum value
MIN optional not used calculate the minimum value
MAX optional not used calculate the maximum value
BETWEEN optional not used calculate the number of values that are within a certain range. Options for this keyword are explained in the documentation for BETWEEN.
HIGHEST optional not used this flag allows you to recover the highest of these variables
HISTOGRAM optional not used calculate a discretized histogram of the distribution of values
LOWEST optional not used this flag allows you to recover the lowest of these variables
SUM optional not used calculate the sum of all the quantities
MEAN optional not used calculate the mean of all the quantities