DISTANCES
 This is part of the multicolvar module

Calculate the distances between one or many pairs of atoms. You can then calculate functions of the distribution of distances such as the minimum, the number less than a certain quantity and so on.

Examples

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

Click on the labels of the actions for more information on what each action computes
d1: DISTANCES ATOMS1the atoms involved in each of the distances you wish to calculate. =3,5 ATOMS2the atoms involved in each of the distances you wish to calculate. =1,2 MINcalculate the minimum value. ={BETA=0.1}
PRINT ARGthe input for this action is the scalar output from one or more other actions. =d1.min


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
d1: DISTANCES ATOMS1the atoms involved in each of the distances you wish to calculate. =3,5 ATOMS2the atoms involved in each of the distances you wish to calculate. =1,2 LESS_THANcalculate the number of variables less than a certain target value. ={RATIONAL R_0=0.1}
PRINT ARGthe input for this action is the scalar output from one or more other actions. =d1.lessthan


The following input tells plumed to calculate all the 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.

Click on the labels of the actions for more information on what each action computes
d1: DISTANCES GROUPCalculate the distance between each distinct pair of atoms in the group =1-3 MEANtake the mean of these variables.
PRINT ARGthe input for this action is the scalar output from one or more other actions. =d1.mean


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
d1: DISTANCES 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 more than a certain target value. ={RATIONAL R_0=0.1}
PRINT ARGthe input for this action is the scalar output from one or more other actions. =d1.morethan


Calculating minimum distances

To calculate and print the minimum distance between two groups of atoms you use the following commands

Click on the labels of the actions for more information on what each action computes
d1: DISTANCES 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.}
PRINT ARGthe input for this action is the scalar output from one or more other actions. =d1.min FILEthe name of the file on which to output these quantities =colvar STRIDEcompulsory keyword ( default=1 )
the frequency with which the quantities of interest should be output =10


(see DISTANCES and PRINT)

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

$s = \frac{\beta}{ \log \sum_i \exp\left( \frac{\beta}{s_i} \right) }$

where $$\beta$$ 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.

This new way of calculating mindist is part of plumed 2's multicolvar functionality. These special actions allow 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 and the number of distances between 1.0 and 2.0 by using the following command:

Click on the labels of the actions for more information on what each action computes
d1: DISTANCES ...
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 less than a certain target value. ={RATIONAL R_0=1.0}
MORE_THANcalculate the number of variables more than a certain target value. ={RATIONAL R_0=2.0}
BETWEENcalculate the number of values that are within a certain range. ={GAUSSIAN LOWER=1.0 UPPER=2.0}
MINcalculate the minimum value. ={BETA=500.}
...
PRINT ARGthe input for this action is the scalar output from one or more other actions. =d1.lessthan,d1.morethan,d1.between,d1.min FILEthe name of the file on which to output these quantities =colvar STRIDEcompulsory keyword ( default=1 )
the frequency with which the quantities of interest should be output =10


(see DISTANCES and PRINT)

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. Furthermore, it can be made faster by using the TOL keyword to discard those distance that make only a small contributions to the final values together with the NL_STRIDE keyword, which ensures that the distances that make only a small contribution to the final values aren't calculated at every step.

Glossary of keywords and components
Description of components

When the label of this action is used as the input for a second you are not referring to a scalar quantity as you are in regular collective variables. The label is used to reference the full set of quantities calculated by the action. This is usual when using MultiColvar functions. Generally when doing this the previously calculated multicolvar will be referenced using the DATA keyword rather than ARG.

This Action can be used to calculate the following scalar quantities directly. These quantities are calculated by employing the keywords listed below. These quantities can then be referenced elsewhere in the input file by using this Action's label followed by a dot and the name of the quantity. Some of them can be calculated multiple times with different parameters. In this case the quantities calculated can be referenced elsewhere in the input by using the name of the quantity followed by a numerical identifier e.g. label.lessthan-1, label.lessthan-2 etc. When doing this and, for clarity we have made it so that the user can set a particular label for each of the components. As such by using the LABEL keyword in the description of the keyword input you can customize the component name

 Quantity Keyword Description altmin ALT_MIN the minimum value. This is calculated using the formula described in the description of the keyword so as to make it continuous. between BETWEEN the number/fraction of values within a certain range. This is calculated using one of the formula described in the description of the keyword so as to make it continuous. You can calculate this quantity multiple times using different parameters. highest HIGHEST the highest of the quantities calculated by this action lessthan LESS_THAN the number of values less than a target value. This is calculated using one of the formula described in the description of the keyword so as to make it continuous. You can calculate this quantity multiple times using different parameters. lowest LOWEST the lowest of the quantities calculated by this action max MAX the maximum value. This is calculated using the formula described in the description of the keyword so as to make it continuous. mean MEAN the mean value. The output component can be referred to elsewhere in the input file by using the label.mean min MIN the minimum value. This is calculated using the formula described in the description of the keyword so as to make it continuous. moment MOMENTS the central moments of the distribution of values. The second moment would be referenced elsewhere in the input file using label.moment-2, the third as label.moment-3, etc. morethan MORE_THAN the number of values more than a target value. This is calculated using one of the formula described in the description of the keyword so as to make it continuous. You can calculate this quantity multiple times using different parameters.
The atoms involved can be specified using
 ATOMS the atoms involved in each of the distances you wish to calculate. Keywords like ATOMS1, ATOMS2, ATOMS3,... should be listed and one distance will be calculated for each ATOM keyword you specify (all ATOM keywords should specify the indices of two atoms). The eventual number of quantities calculated by this action will depend on what functions of the distribution you choose to calculate. You can use multiple instances of this keyword i.e. ATOMS1, ATOMS2, ATOMS3...
Or alternatively by using
 GROUP Calculate the distance between each distinct pair of atoms in the group
Or alternatively by using
 GROUPA Calculate the distances between all the atoms in GROUPA and all the atoms in GROUPB. This must be used in conjunction with GROUPB. GROUPB Calculate the distances between all the atoms in GROUPA and all the atoms in GROUPB. This must be used in conjunction with GROUPA.
Options
 NUMERICAL_DERIVATIVES ( default=off ) calculate the derivatives for these quantities numerically NOPBC ( default=off ) ignore the periodic boundary conditions when calculating distances SERIAL ( default=off ) do the calculation in serial. Do not use MPI LOWMEM ( default=off ) lower the memory requirements TIMINGS ( default=off ) output information on the timings of the various parts of the calculation ALT_MIN calculate the minimum value. To make this quantity continuous the minimum is calculated using $$\textrm{min} = -\frac{1}{\beta} \log \sum_i \exp\left( -\beta s_i \right)$$ The value of $$\beta$$ in this function is specified using (BETA= $$\beta$$). The final value can be referenced using label.altmin. You can use multiple instances of this keyword i.e. ALT_MIN1, ALT_MIN2, ALT_MIN3... The corresponding values are then referenced using label.altmin-1, label.altmin-2, label.altmin-3... LOWEST this flag allows you to recover the lowest of these variables. The final value can be referenced using label.lowest HIGHEST this flag allows you to recover the highest of these variables. The final value can be referenced using label.highest MEAN take the mean of these variables. The final value can be referenced using label.mean. You can use multiple instances of this keyword i.e. MEAN1, MEAN2, MEAN3... The corresponding values are then referenced using label.mean-1, label.mean-2, label.mean-3... MIN calculate the minimum value. To make this quantity continuous the minimum is calculated using $$\textrm{min} = \frac{\beta}{ \log \sum_i \exp\left( \frac{\beta}{s_i} \right) }$$ The value of $$\beta$$ in this function is specified using (BETA= $$\beta$$) The final value can be referenced using label.min. You can use multiple instances of this keyword i.e. MIN1, MIN2, MIN3... The corresponding values are then referenced using label.min-1, label.min-2, label.min-3... MAX calculate the maximum value. To make this quantity continuous the maximum is calculated using $$\textrm{max} = \beta \log \sum_i \exp\left( \frac{s_i}{\beta}\right)$$ The value of $$\beta$$ in this function is specified using (BETA= $$\beta$$) The final value can be referenced using label.max. You can use multiple instances of this keyword i.e. MAX1, MAX2, MAX3... The corresponding values are then referenced using label.max-1, label.max-2, label.max-3... LESS_THAN calculate the number of variables less than a certain target value. This quantity is calculated using $$\sum_i \sigma(s_i)$$, where $$\sigma(s)$$ is a switchingfunction. The final value can be referenced using label.lessthan. You can use multiple instances of this keyword i.e. LESS_THAN1, LESS_THAN2, LESS_THAN3... The corresponding values are then referenced using label.lessthan-1, label.lessthan-2, label.lessthan-3... MORE_THAN calculate the number of variables more than a certain target value. This quantity is calculated using $$\sum_i 1.0 - \sigma(s_i)$$, where $$\sigma(s)$$ is a switchingfunction. The final value can be referenced using label.morethan. You can use multiple instances of this keyword i.e. MORE_THAN1, MORE_THAN2, MORE_THAN3... The corresponding values are then referenced using label.morethan-1, label.morethan-2, label.morethan-3... BETWEEN calculate the number of values that are within a certain range. These quantities are calculated using kernel density estimation as described on histogrambead. The final value can be referenced using label.between. You can use multiple instances of this keyword i.e. BETWEEN1, BETWEEN2, BETWEEN3... The corresponding values are then referenced using label.between-1, label.between-2, label.between-3... HISTOGRAM calculate how many of the values fall in each of the bins of a histogram. This shortcut allows you to calculates NBIN quantities like BETWEEN. The final value can be referenced using label.histogram. You can use multiple instances of this keyword i.e. HISTOGRAM1, HISTOGRAM2, HISTOGRAM3... The corresponding values are then referenced using label.histogram-1, label.histogram-2, label.histogram-3... MOMENTS calculate the moments of the distribution of collective variables. The mth moment of a distribution is calculated using $$\frac{1}{N} \sum_{i=1}^N ( s_i - \overline{s} )^m$$, where $$\overline{s}$$ is the average for the distribution. The moments keyword takes a lists of integers as input or a range. Each integer is a value of $$m$$. The final calculated values can be referenced using moment- $$m$$. You can use the COMPONENT keyword in this action but the syntax is slightly different. If you would like the second and third moments of the third component you would use MOMENTS={COMPONENT=3 MOMENTS=2-3}. The moments would then be referred to using the labels moment-3-2 and moment-3-3. This syntax is also required if you are using numbered MOMENT keywords i.e. MOMENTS1, MOMENTS2...