Shortcut: EUCLIDEAN_DISTANCE
Module |
refdist |
Description |
Usage |
Calculate the euclidean distance between two vectors of arguments |
  |
output value |
type |
the euclidean distances between the input vectors |
scalar/vector |
Further details and examples
Calculate the euclidean distance between two vectors of arguments
If we have two n-dimensional vectors u and v we can calculate the
Euclidean distance between the two points as
d=√n∑i=1(ui−vi)2
which can be expressed in matrix form as:
d2=(u−v)T(u−v)
The inputs below shows an example where this is used to calculate the Euclidean distance
between the instaneous values of some torsional angles and some reference values
for these torsion. In this first example the input values are vectors:
Click on the labels of the actions for more information on what each action computes
cThe CONSTANT action with label c calculates the following quantities: Quantity | Type | Description |
c | vector | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=1,2,3
c: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUESthe numbers that are in your constant value=1,2,3 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
dThe DISTANCE action with label d calculates the following quantities: Quantity | Type | Description |
d | vector | the DISTANCE for each set of specified atoms |
: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMS1the pair of atom that we are calculating the distance between=1,2 ATOMS2the pair of atom that we are calculating the distance between=3,4 ATOMS3the pair of atom that we are calculating the distance between=5,6
ddThe EUCLIDEAN_DISTANCE action with label dd calculates the following quantities: Quantity | Type | Description |
dd | scalar | the euclidean distances between the input vectors |
: EUCLIDEAN_DISTANCECalculate the euclidean distance between two vectors of arguments This action is a shortcut. More details ARG1The poin that we are calculating the distance from=c ARG2The point that we are calculating the distance to=d
# dd: EUCLIDEAN_DISTANCE ARG1=c ARG2=d
dd_diffThe TRANSPOSE action with label dd_diff calculates the following quantities: Quantity | Type | Description |
dd_diff | matrix | the transpose of the input matrix |
: DISPLACEMENTCalculate the displacement vector between the pair of input vectors More details ARG1The point that we are calculating the distance from=c ARG2The point that we are calculating the distance to=d
dd_diffTThe TRANSPOSE action with label dd_diffT calculates the following quantities: Quantity | Type | Description |
dd_diffT | vector | the transpose of the input matrix |
: TRANSPOSECalculate the transpose of a matrix More details ARGthe label of the vector or matrix that should be transposed=dd_diff
dd_2The MATRIX_PRODUCT_DIAGONAL action with label dd_2 calculates the following quantities: Quantity | Type | Description |
dd_2 | scalar | a vector containing the diagonal elements of the matrix that obtaned by multiplying the two input matrices together |
: MATRIX_PRODUCT_DIAGONALCalculate the product of two matrices and return a vector that contains the diagonal elements of the ouptut vector More details ARGthe two vectors/matrices whose product are to be taken=dd_diff,dd_diffT
ddThe CUSTOM action with label dd calculates the following quantities: Quantity | Type | Description |
dd | scalar | an arbitrary function |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=dd_2 FUNCthe function you wish to evaluate=sqrt(x) PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
# --- End of included input --- PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=dd FILEthe name of the file on which to output these quantities=colvar
while this second example does the same thing but uses scalars in input.
Click on the labels of the actions for more information on what each action computes
c1The CONSTANT action with label c1 calculates the following quantities: Quantity | Type | Description |
c1 | scalar | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUEthe single number that you would like to store=1
c1: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUEthe single number that you would like to store=1 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
d1The DISTANCE action with label d1 calculates the following quantities: Quantity | Type | Description |
d1 | scalar | the DISTANCE between this pair of atoms |
: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2
c2The CONSTANT action with label c2 calculates the following quantities: Quantity | Type | Description |
c2 | scalar | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUEthe single number that you would like to store=2
c2: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUEthe single number that you would like to store=2 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
d2The DISTANCE action with label d2 calculates the following quantities: Quantity | Type | Description |
d2 | scalar | the DISTANCE between this pair of atoms |
: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=3,4
c3The CONSTANT action with label c3 calculates the following quantities: Quantity | Type | Description |
c3 | scalar | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUEthe single number that you would like to store=3
c3: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUEthe single number that you would like to store=3 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
d3The DISTANCE action with label d3 calculates the following quantities: Quantity | Type | Description |
d3 | scalar | the DISTANCE between this pair of atoms |
: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=5,6
ddThe EUCLIDEAN_DISTANCE action with label dd calculates the following quantities: Quantity | Type | Description |
dd | scalar | the euclidean distances between the input vectors |
: EUCLIDEAN_DISTANCECalculate the euclidean distance between two vectors of arguments This action is a shortcut. More details ARG1The poin that we are calculating the distance from=c1,c2,c3 ARG2The point that we are calculating the distance to=d1,d2,d3
# dd: EUCLIDEAN_DISTANCE ARG1=c1,c2,c3 ARG2=d1,d2,d3
dd_diffThe VSTACK action with label dd_diff calculates the following quantities: Quantity | Type | Description |
dd_diff | matrix | a matrix that contains the input vectors in its columns |
: DISPLACEMENTCalculate the displacement vector between the pair of input vectors More details ARG1The point that we are calculating the distance from=c1,c2,c3 ARG2The point that we are calculating the distance to=d1,d2,d3
dd_diffTThe TRANSPOSE action with label dd_diffT calculates the following quantities: Quantity | Type | Description |
dd_diffT | vector | the transpose of the input matrix |
: TRANSPOSECalculate the transpose of a matrix More details ARGthe label of the vector or matrix that should be transposed=dd_diff
dd_2The MATRIX_PRODUCT_DIAGONAL action with label dd_2 calculates the following quantities: Quantity | Type | Description |
dd_2 | scalar | a vector containing the diagonal elements of the matrix that obtaned by multiplying the two input matrices together |
: MATRIX_PRODUCT_DIAGONALCalculate the product of two matrices and return a vector that contains the diagonal elements of the ouptut vector More details ARGthe two vectors/matrices whose product are to be taken=dd_diff,dd_diffT
ddThe CUSTOM action with label dd calculates the following quantities: Quantity | Type | Description |
dd | scalar | an arbitrary function |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=dd_2 FUNCthe function you wish to evaluate=sqrt(x) PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
# --- End of included input --- PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=dd FILEthe name of the file on which to output these quantities=colvar
Calculating multiple distances
Suppose that we now have m reference configurations we can define the following m distances
from these reference configurations:
d2j=(u−vj)T(u−vj)
Lets suppose that we put the m, n-dimensional (u−vj) vectors in this expression into a
n×m matrix, A, by using the DISPLACEMENT command. It is then
straightforward to show that the d2j values in the above expression are then the diagonal
elements of the matrix product ATA.
We can use this idea to calculate multiple EUCLIDEAN_DISTANCE values in the following inputs.
This first example calculates the three distances between the instaneoues values of two torsions
and three reference configurations.
Click on the labels of the actions for more information on what each action computes
ref_psiThe CONSTANT action with label ref_psi calculates the following quantities: Quantity | Type | Description |
ref_psi | vector | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=2.25,1.3,-1.5
ref_psi: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUESthe numbers that are in your constant value=2.25,1.3,-1.5 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
ref_phiThe CONSTANT action with label ref_phi calculates the following quantities: Quantity | Type | Description |
ref_phi | vector | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=-1.91,-0.6,2.4
ref_phi: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUESthe numbers that are in your constant value=-1.91,-0.6,2.4 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
psiThe TORSION action with label psi calculates the following quantities: Quantity | Type | Description |
psi | scalar | the TORSION involving these atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4
phiThe TORSION action with label phi calculates the following quantities: Quantity | Type | Description |
phi | scalar | the TORSION involving these atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=13,14,15,16
ddThe EUCLIDEAN_DISTANCE action with label dd calculates the following quantities: Quantity | Type | Description |
dd | vector | the euclidean distances between the input vectors |
: EUCLIDEAN_DISTANCECalculate the euclidean distance between two vectors of arguments This action is a shortcut. More details ARG1The poin that we are calculating the distance from=psi,phi ARG2The point that we are calculating the distance to=ref_psi,ref_phi
# dd: EUCLIDEAN_DISTANCE ARG1=psi,phi ARG2=ref_psi,ref_phi
dd_diffThe VSTACK action with label dd_diff calculates the following quantities: Quantity | Type | Description |
dd_diff | matrix | a matrix that contains the input vectors in its columns |
: DISPLACEMENTCalculate the displacement vector between the pair of input vectors More details ARG1The point that we are calculating the distance from=psi,phi ARG2The point that we are calculating the distance to=ref_psi,ref_phi
dd_diffTThe TRANSPOSE action with label dd_diffT calculates the following quantities: Quantity | Type | Description |
dd_diffT | matrix | the transpose of the input matrix |
: TRANSPOSECalculate the transpose of a matrix More details ARGthe label of the vector or matrix that should be transposed=dd_diff
dd_2The MATRIX_PRODUCT_DIAGONAL action with label dd_2 calculates the following quantities: Quantity | Type | Description |
dd_2 | vector | a vector containing the diagonal elements of the matrix that obtaned by multiplying the two input matrices together |
: MATRIX_PRODUCT_DIAGONALCalculate the product of two matrices and return a vector that contains the diagonal elements of the ouptut vector More details ARGthe two vectors/matrices whose product are to be taken=dd_diff,dd_diffT
ddThe CUSTOM action with label dd calculates the following quantities: Quantity | Type | Description |
dd | vector | the vector obtained by doing an element-wise application of an arbitrary function to the input vectors |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=dd_2 FUNCthe function you wish to evaluate=sqrt(x) PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
# --- End of included input --- PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=dd FILEthe name of the file on which to output these quantities=colvar
This section example calculates the three distances between a single reference value for the two
torsions and three instances of this pair of torsions.
Click on the labels of the actions for more information on what each action computes
ref_psiThe CONSTANT action with label ref_psi calculates the following quantities: Quantity | Type | Description |
ref_psi | scalar | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=2.25
ref_psi: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUESthe numbers that are in your constant value=2.25 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
ref_phiThe CONSTANT action with label ref_phi calculates the following quantities: Quantity | Type | Description |
ref_phi | scalar | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=-1.91
ref_phi: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUESthe numbers that are in your constant value=-1.91 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
psiThe TORSION action with label psi calculates the following quantities: Quantity | Type | Description |
psi | vector | the TORSION for each set of specified atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMS1the four atoms involved in the torsional angle=1,2,3,4 ATOMS2the four atoms involved in the torsional angle=5,6,7,8 ATOMS3the four atoms involved in the torsional angle=9,10,11,12
phiThe TORSION action with label phi calculates the following quantities: Quantity | Type | Description |
phi | vector | the TORSION for each set of specified atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMS1the four atoms involved in the torsional angle=13,14,15,16 ATOMS2the four atoms involved in the torsional angle=17,18,19,20 ATOMS3the four atoms involved in the torsional angle=21,22,23,24
ddThe EUCLIDEAN_DISTANCE action with label dd calculates the following quantities: Quantity | Type | Description |
dd | vector | the euclidean distances between the input vectors |
: EUCLIDEAN_DISTANCECalculate the euclidean distance between two vectors of arguments This action is a shortcut. More details ARG1The poin that we are calculating the distance from=psi,phi ARG2The point that we are calculating the distance to=ref_psi,ref_phi
# dd: EUCLIDEAN_DISTANCE ARG1=psi,phi ARG2=ref_psi,ref_phi
dd_diffThe VSTACK action with label dd_diff calculates the following quantities: Quantity | Type | Description |
dd_diff | matrix | a matrix that contains the input vectors in its columns |
: DISPLACEMENTCalculate the displacement vector between the pair of input vectors More details ARG1The point that we are calculating the distance from=psi,phi ARG2The point that we are calculating the distance to=ref_psi,ref_phi
dd_diffTThe TRANSPOSE action with label dd_diffT calculates the following quantities: Quantity | Type | Description |
dd_diffT | matrix | the transpose of the input matrix |
: TRANSPOSECalculate the transpose of a matrix More details ARGthe label of the vector or matrix that should be transposed=dd_diff
dd_2The MATRIX_PRODUCT_DIAGONAL action with label dd_2 calculates the following quantities: Quantity | Type | Description |
dd_2 | vector | a vector containing the diagonal elements of the matrix that obtaned by multiplying the two input matrices together |
: MATRIX_PRODUCT_DIAGONALCalculate the product of two matrices and return a vector that contains the diagonal elements of the ouptut vector More details ARGthe two vectors/matrices whose product are to be taken=dd_diff,dd_diffT
ddThe CUSTOM action with label dd calculates the following quantities: Quantity | Type | Description |
dd | vector | the vector obtained by doing an element-wise application of an arbitrary function to the input vectors |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=dd_2 FUNCthe function you wish to evaluate=sqrt(x) PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
# --- End of included input --- PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=dd FILEthe name of the file on which to output these quantities=colvar
This final example then computes three distances between three pairs of torsional angles and threee
reference values for these three values.
Click on the labels of the actions for more information on what each action computes
ref_psiThe CONSTANT action with label ref_psi calculates the following quantities: Quantity | Type | Description |
ref_psi | vector | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=2.25,1.3,-1.5
ref_psi: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUESthe numbers that are in your constant value=2.25,1.3,-1.5 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
ref_phiThe CONSTANT action with label ref_phi calculates the following quantities: Quantity | Type | Description |
ref_phi | vector | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=-1.91,-0.6,2.4
ref_phi: CONSTANTCreate a constant value that can be passed to actions This action uses the defaults shown here. More details VALUESthe numbers that are in your constant value=-1.91,-0.6,2.4 NROWS the number of rows in your input matrix=0 NCOLS the number of columns in your matrix=0
psiThe TORSION action with label psi calculates the following quantities: Quantity | Type | Description |
psi | vector | the TORSION for each set of specified atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMS1the four atoms involved in the torsional angle=1,2,3,4 ATOMS2the four atoms involved in the torsional angle=5,6,7,8 ATOMS3the four atoms involved in the torsional angle=9,10,11,12
phiThe TORSION action with label phi calculates the following quantities: Quantity | Type | Description |
phi | vector | the TORSION for each set of specified atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMS1the four atoms involved in the torsional angle=13,14,15,16 ATOMS2the four atoms involved in the torsional angle=17,18,19,20 ATOMS3the four atoms involved in the torsional angle=21,22,23,24
ddThe EUCLIDEAN_DISTANCE action with label dd calculates the following quantities: Quantity | Type | Description |
dd | vector | the euclidean distances between the input vectors |
: EUCLIDEAN_DISTANCECalculate the euclidean distance between two vectors of arguments This action is a shortcut. More details ARG1The poin that we are calculating the distance from=psi,phi ARG2The point that we are calculating the distance to=ref_psi,ref_phi
# dd: EUCLIDEAN_DISTANCE ARG1=psi,phi ARG2=ref_psi,ref_phi
dd_diffThe VSTACK action with label dd_diff calculates the following quantities: Quantity | Type | Description |
dd_diff | matrix | a matrix that contains the input vectors in its columns |
: DISPLACEMENTCalculate the displacement vector between the pair of input vectors More details ARG1The point that we are calculating the distance from=psi,phi ARG2The point that we are calculating the distance to=ref_psi,ref_phi
dd_diffTThe TRANSPOSE action with label dd_diffT calculates the following quantities: Quantity | Type | Description |
dd_diffT | matrix | the transpose of the input matrix |
: TRANSPOSECalculate the transpose of a matrix More details ARGthe label of the vector or matrix that should be transposed=dd_diff
dd_2The MATRIX_PRODUCT_DIAGONAL action with label dd_2 calculates the following quantities: Quantity | Type | Description |
dd_2 | vector | a vector containing the diagonal elements of the matrix that obtaned by multiplying the two input matrices together |
: MATRIX_PRODUCT_DIAGONALCalculate the product of two matrices and return a vector that contains the diagonal elements of the ouptut vector More details ARGthe two vectors/matrices whose product are to be taken=dd_diff,dd_diffT
ddThe CUSTOM action with label dd calculates the following quantities: Quantity | Type | Description |
dd | vector | the vector obtained by doing an element-wise application of an arbitrary function to the input vectors |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=dd_2 FUNCthe function you wish to evaluate=sqrt(x) PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
# --- End of included input --- PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=dd FILEthe name of the file on which to output these quantities=colvar
Syntax
The following table describes the keywords and options that can be used with this action
Keyword |
Type |
Default |
Description |
ARG1 |
compulsory |
none |
The poin that we are calculating the distance from |
ARG2 |
compulsory |
none |
The point that we are calculating the distance to |
SQUARED |
optional |
false |
The squared distance should be calculated |