Skip to content

Shortcut: MORE_THAN

Module function
Description Usage
Use a switching function to determine how many of the input variables are more than a certain cutoff. used in 4 tutorialsused in 2 eggs
output value type
a function that is one if the if the input is more than a threshold scalar/vector/matrix

Details and examples

Use a switching function to determine how many of the input variables are more than a certain cutoff.

This action takes one argument, and evaluates the following function:

In this equation is one of the switching functions described in the documentation for the action LESS_THAN. The output value is thus a number between 0 and 1 that tells you if the input value is greater than some cutoff. Furthermore, the value of smoothly from zero to one as the input value crosses the threshold of interest so any function of this value is differentiable.

The following example, shows how we can apply the function above on the instantaneous value of the distance between atom 1 and 2. The MORE_THAN action here is used to determine whether the input distance is greater than 0.2 nm.

Click on the labels of the actions for more information on what each action computes
tested on2.11
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2
b: MORE_THANUse a switching function to determine how many of the input variables are more than a certain cutoff. More details ARGthe values input to this function=d R_0The r_0 parameter of the switching function=0.2 D_0 The d_0 parameter of the switching function=0.0 NN The n parameter of the switching function =6 MM The m parameter of the switching function; 0 implies 2*NN=12

In the above input the rational switching function that is described in the documentation for LESS_THAN is used to transform the input distance. However, we would recommend using the following syntax rather than the one above:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2
b: MORE_THANUse a switching function to determine how many of the input variables are more than a certain cutoff. More details ARGthe values input to this function=d SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL R_0=0.2}

as this syntax allows you to use all the switching function options described in the documentation for LESS_THAN here in place of RATIONAL.

Transforming the square

If you have computed the square of the distance you can use the flag SQUARED to indicate that the input quantity is the square of the distance as indicated below:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d: DISTANCECalculate the distance/s between pairs of atoms. More details COMPONENTS calculate the x, y and z components of the distance separately and store them as label ATOMSthe pair of atom that we are calculating the distance between=1,2
dm: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=d.x,d.y,d.z FUNCthe function you wish to evaluate=x*x+y*y+z*z PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
s: MORE_THANUse a switching function to determine how many of the input variables are more than a certain cutoff. More details ARGthe values input to this function=dm SQUARED is the input quantity the square of the value that you would like to apply the switching function to SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL R_0=0.2}

This option can be useful for improving performance by removing the expensive square root operations.

Non rank zero arguments

Instead of passing a single scalar in the input to the MORE_THAN action you can pass a single vector as shown here:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d: 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 ATOMS4the pair of atom that we are calculating the distance between=7,8
b: MORE_THANUse a switching function to determine how many of the input variables are more than a certain cutoff. More details ARGthe values input to this function=d SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL R_0=0.2}

The input to the MORE_THAN action here is a vector with four elements. The output from the action b is similarly a vector with four elements. In calculating the elements of this vector PLUMED applies the function described in the previous section on each of the distances in turn. The first element of b thus tells you if the distance between atoms 1 and 2 is between greater than 0.2 nm, the second element tells you if the distance between atoms 3 and 4 is greater than 0.2 nm and so on.

You can use the commands in the above example input to evaluate the number of distances that greater than a threshold as follows:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d: 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 ATOMS4the pair of atom that we are calculating the distance between=7,8
b: MORE_THANUse a switching function to determine how many of the input variables are more than a certain cutoff. More details ARGthe values input to this function=d SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL R_0=0.2}
s: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=b 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=s FILEthe name of the file on which to output these quantities=colvar

The final scalar that is output here is evaluated using the following summation:

where the sum over here runs over the four distances in the above expression. This scalar tells you the number of distances that are more than 0.2 nm.

Notice that you can do something similar with a matrix as input as shown below:

Click on the labels of the actions for more information on what each action computes
tested on2.11
d: DISTANCE_MATRIXCalculate a matrix of distances between atoms. This action has hidden defaults. More details GROUPAwhen you are calculating the adjacency matrix between two sets of atoms this keyword is used to specify the atoms along with the keyword GROUPB=1-10 GROUPBwhen you are calculating the adjacency matrix between two sets of atoms this keyword is used to specify the atoms along with the keyword GROUPA=11-20
b: MORE_THANUse a switching function to determine how many of the input variables are more than a certain cutoff. More details ARGthe values input to this function=d SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL R_0=0.2}
s: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=b 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=s FILEthe name of the file on which to output these quantities=colvar

This input tells PLUMED to calculate the 100 distances between the atoms in the two input groups. The final value that is printed to the colvar file then tells you how many of these distances are greater than 0.2 nm.

The MASK keyword

Consider the following input:

Click on the labels of the actions for more information on what each action computes
tested on2.11
# Fixed virtual atom which serves as the probe volume's center (pos. in nm)
center: FIXEDATOMAdd a virtual atom in a fixed position. This action has hidden defaults. More details ATcoordinates of the virtual atom=2.5,2.5,2.5
# Vector in which element i is one if atom i is in sphere of interest and zero otherwise
sphere: INSPHEREThis 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. More details ATOMSthe group of atoms that you would like to investigate=1-400 CENTERthe atom whose vicinity we are interested in examining=center RADIUSthe switching function that tells us the extent of the sphereical region of interest. Options for this keyword are explained in the documentation for LESS_THAN.={GAUSSIAN D_0=0.5 R_0=0.01 D_MAX=0.52}
# Compute the coordination numbers
adj: CONTACT_MATRIXAdjacency matrix in which two atoms are adjacent if they are within a certain cutoff. More details GROUPspecifies the list of atoms that should be assumed indistinguishable=1-400 SWITCHthe input for the switching function that acts upon the distance between each pair of atoms. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL R_0=0.3 D_MAX=1.0} MASKa vector that is used to used to determine which rows of the adjancency matrix to compute=sphere
ones: ONESCreate a constant vector with all elements equal to one This action is a shortcut. More details SIZEthe number of ones that you would like to create=400
coord: MATRIX_VECTOR_PRODUCTCalculate the product of the matrix and the vector More details ARGthe label for the matrix and the vector/scalar that are being multiplied=adj,ones
# Determine if coordination numbers are more than 4 or not
lt: MORE_THANUse a switching function to determine how many of the input variables are more than a certain cutoff. More details ARGthe values input to this function=coord MASKthe label for a sparse vector/matrix that should be used to determine which elements of the vector/matrix should be computed=sphere SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL R_0=4.0}
# And calculate how many atoms in the region of interst have a coordination number that is less than four
ltsphere: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=lt,sphere FUNCthe function you wish to evaluate=x*y PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
cv: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=ltsphere 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=cv FILEthe name of the file on which to output these quantities=colvar

This input calculates the total number of atoms that are within a spherical region that is centered on the point and have a coordination number that is more than 4. Notice that to reduce the computational expense we use the MASK keyword in the input to CONTACT_MATRIX so PLUMED knows to not bother calculating the coordination numbers of atoms that are not within the spherical region of interest. Further notice that we have also used this MASK keyword in the input to MORE_THAN to prevent PLUMED from transforming the coordination numbers that have not been calculated with the switching function to get a further speed up.

Using the MASK keyword in this way is necessary if the input argument is a vector. If the input argument is a matrix then you should never need to use the MASK keyword. PLUMED will use the sparsity pattern for the input matrix to reduce the number of transformations that are performed within MORE_THAN.

Input

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

Keyword Type Description
ARG scalar/vector/matrix the values input to this function
MASK vector/matrix the label for a sparse vector/matrix that should be used to determine which elements of the vector/matrix should be computed

Full list of keywords

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

Keyword Type Default Description
ARG input none the values input to this function
MASK input none the label for a sparse vector/matrix that should be used to determine which elements of the vector/matrix should be computed
NN compulsory 6 The n parameter of the switching function
MM compulsory 0 The m parameter of the switching function; 0 implies 2*NN
D_0 compulsory 0.0 The d_0 parameter of the switching function
R_0 compulsory none The r_0 parameter of the switching function
SWITCH optional not used This keyword is used if you want to employ an alternative to the continuous swiching function defined above
SQUARED optional false is the input quantity the square of the value that you would like to apply the switching function to