Shortcut: LOCAL_AVERAGE
| Module | symfunc |
|---|---|
| Description | Usage |
| Calculate averages over spherical regions centered on atoms | |
| output value | type |
| the values of the local averages | vector |
Details and examples
Calculate averages over spherical regions centered on atoms
As is explained in this video certain PLUMED actions calculate one scalar quantity or one vector for each of the atoms in the system. For example COORDINATIONNUMBER measures the coordination number of each of the atoms in the system and Q4 measures the 4th order Steinhardt parameter for each of the atoms in the system. These quantities provide tell us something about the disposition of the atoms in the first coordination sphere of each of the atoms of interest. In the paper in the bibliography Lechner and Dellago have suggested that one can probe local order in a system by taking the average value of such symmetry functions over the atoms within a spherical cutoff of each of these atoms in the systems. When this is done with Steinhardt parameters they claim this gives a coordinate that is better able to distinguish solid and liquid configurations of Lennard-Jones atoms.
You can calculate such locally averaged quantities within plumed by using the LOCAL_AVERAGE command. This command calculates the following atom-centered quantities:
where the and values can be any vector of symmetry functions that can be calculated using plumed multicolvars. The function is a switching function that acts on the distance between atoms and . Lechner and Dellago suggest that the parameters of this function should be set so that it the function is equal to one when atom is in the first coordination sphere of atom and is zero otherwise.
To see how this works in practice consider the following example input.
d1: COORDINATIONNUMBERCalculate the coordination numbers of atoms so that you can then calculate functions of the distribution of This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=1-64 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} la: LOCAL_AVERAGECalculate averages over spherical regions centered on atoms This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=d1 D_0 The d_0 parameter of the switching function=1.3 R_0The r_0 parameter of the switching function=0.2 NN The n parameter of the switching function =6 MM The m parameter of the switching function; 0 implies 2*NN=12 mtf: 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=la SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL R_0=4} la_morethan: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=mtf 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=la_morethan FILEthe name of the file on which to output these quantities=colvar
This input calculates the coordination numbers for all the atoms in the system. These coordination numbers are then averaged over spherical regions. The number of averaged coordination numbers that are greater than 4 is then output to a file. Furthermore, if you expand the input above you can see how the LOCAL_AVERAGE command is a shortcut action that expands to a longer input that you should be able to interpret.
In the input above we use a rational switching function with the parameters above. We would recommend using SWITCH syntax rather than the syntax above when giving the parameters for the switching function as you can then use any of the switching functions described in the documentation for LESS_THAN. More importantly, however, using this syntax allows you to set the D_MAX parameter for the switching function as demonstrated below:
d1: COORDINATIONNUMBERCalculate the coordination numbers of atoms so that you can then calculate functions of the distribution of This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=1-64 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} la: LOCAL_AVERAGECalculate averages over spherical regions centered on atoms This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=d1 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} mtf: 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=la SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL R_0=4} la_morethan: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=mtf 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=la_morethan FILEthe name of the file on which to output these quantities=colvar
Setting the D_MAX can substantially improve PLUMED performance as it turns on the linked list algorithm that is discussed in the optimisation details part
of the documentation for CONTACT_MATRIX.
Locally averaged Steinhardt Parameters
What Lechner and Dellago did in their paper was a little more complicated than the example in the previous section. To reproduce what they did you would use an input something like this:
q4: Q4Calculate fourth order Steinhardt parameters. This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=1-64 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2} la: LOCAL_AVERAGECalculate averages over spherical regions centered on atoms This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=q4 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2} la_mean: MEANCalculate the arithmetic mean of the elements in a vector More details ARGthe vector/matrix/grid whose elements shuld be added together=la 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=la_mean FILEthe name of the file on which to output these quantities=colvar
This example input calculates the Q4 vectors for each of the atoms in the system. These vectors are then averaged component by component over a spherical region. The average value for this quantity is then outputeed to a file. If you want to understand more about the shortcut that is used here you can read this page.
Using SPECIESA/SPECIESB
If you only want to calculate the local averages for a subset of the atoms you might use an input like the one shown below:
# Calculate the coordination numbers for the two types of atom d1a: COORDINATIONNUMBERCalculate the coordination numbers of atoms so that you can then calculate functions of the distribution of This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=1-5 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} d1b: COORDINATIONNUMBERCalculate the coordination numbers of atoms so that you can then calculate functions of the distribution of This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=1-64 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} # Now compute the local average la: LOCAL_AVERAGECalculate averages over spherical regions centered on atoms This action is a shortcut. More details SPECIESAthe list of atoms for which the symmetry function is being calculated=d1a SPECIESBthe list of atoms that can be in the environments of each of the atoms for which the symmetry function is being calculated=d1b SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} DUMPATOMSDump selected atoms on a file. More details ARGthe labels of vectors that should be output in the xyz file=la ATOMSthe atom indices whose positions you would like to print out=1-5 FILEfile on which to output coordinates; extension is automatically detected=atoms.xyz
In the input above the local averages are computed for atoms 1-5 only. However, to calculate these local averages we still need to calculate the coordination numbers of all the atoms in the system.
The MASK keyword
You can use the MASK keyword with this action in the same way that it is used with COORDINATIONNUMBER. This keyword thus expects a vector in input, which tells PLUMED the atoms for which you do not need to calculate the function. As illustrated below, this is useful if you are using functionality from the volumes module to calculate the average value of the local averages for only those atoms that lie in a certain part of the simulation box.
# Calculate the coordination number for all the atoms cc: COORDINATIONNUMBERCalculate the coordination numbers of atoms so that you can then calculate functions of the distribution of This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=1-400 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} # 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} # Calculate the local average lcc: LOCAL_AVERAGECalculate averages over spherical regions centered on atoms This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=cc SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} MASKthe label for a vector that is used to determine which rows of the matrix are computed=sphere # Multiply local averages parameters numbers by sphere vector prod: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=lcc,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 # Sum of coordination numbers for atoms that are in the sphere of interest numer: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=prod PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO # Number of atoms that are in sphere of interest denom: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=sphere PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO # Average coordination number for atoms in sphere of interest av: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=numer,denom 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 # And print out final CV to a file PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=av FILEthe name of the file on which to output these quantities=colvar STRIDE the frequency with which the quantities of interest should be output=1
This input calculates the average value of the local average for those atoms that are within a spherical region that is centered on the point .
By including the MASK keyword in the LOCAL_AVERAGE line we reduce the number of local averages that are computed. These quantities are only calculated for those
atoms that are within the spherical region of interest. However, we are still asking PLUMED to calculate the coordination numbers for many atoms that
will not contribute to the final averaged quantity in the COORDINATIONNUMBER commmand with label cc. If you use an input like the one shown below you can ensure
that only those coordiantion numbers that compute to the final average are computed.
# 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} 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 # Calculate a elements of adjacency matrix for those elements that are inside the sphere vol_cmap: 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 D_0=1.3 R_0=0.2 D_MAX=3.0} MASKa vector that is used to used to determine which rows of the adjancency matrix to compute=sphere # Create a matrix that for the sphere stuff sphere_mat: OUTER_PRODUCTCalculate the outer product matrix of two vectors This action has hidden defaults. More details ARGthe labels of the two vectors from which the outer product is being computed=sphere,ones MASKa matrix that is used to used to determine which elements of the output matrix to compute=vol_cmap # Multiply this contact matrix by the map bonds_mat: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=vol_cmap,sphere_mat 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 # Transpose the above matrix bonds_matT: TRANSPOSECalculate the transpose of a matrix More details ARGthe label of the vector or matrix that should be transposed=bonds_mat # And multiply by the volume bonds: 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=bonds_matT,sphere # And make sure we calculate the coordination numbers for the atoms in the volume too mask: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=bonds,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 # Calculate the coordination number for all the atoms cc: COORDINATIONNUMBERCalculate the coordination numbers of atoms so that you can then calculate functions of the distribution of This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=1-400 SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} MASKthe label for a vector that is used to determine which rows of the matrix are computed=mask # Calculate the local average lcc: LOCAL_AVERAGECalculate averages over spherical regions centered on atoms This action is a shortcut. More details SPECIESthe list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments=cc SWITCHthe switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN.={RATIONAL D_0=1.3 R_0=0.2 D_MAX=3.0} MASKthe label for a vector that is used to determine which rows of the matrix are computed=sphere # Multiply local averages parameters numbers by sphere vector prod: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=lcc,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 # Sum of coordination numbers for atoms that are in the sphere of interest numer: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=prod PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO # Number of atoms that are in sphere of interest denom: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=sphere PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO # Average coordination number for atoms in sphere of interest av: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=numer,denom 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 # And print out final CV to a file PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=av FILEthe name of the file on which to output these quantities=colvar STRIDE the frequency with which the quantities of interest should be output=1
In the above input the only elements of the CONTACT_MATRIX with label vol_cmap that are non-zero are those that are bonded to one of the atoms
in the sphere of interest. By transposing this matrix and multiplying by a vector of ones we thus get a vector with a length equal to total number of coordination
numbers in the system. The only elements in this vector that are non-zero are those that are bonded to atoms that are within the sphere of interest. Consequently,
if we add the vector sphere to this we can a vector in which element is only non-zero if we have to calculate that coordination number to evaluate the final
quantity of interest.
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 |
|---|---|---|
| SPECIES | atoms | the list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments |
| SPECIESA | atoms | the list of atoms for which the symmetry function is being calculated |
| SPECIESB | atoms | the list of atoms that can be in the environments of each of the atoms for which the symmetry function is being calculated |
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 |
Full list of keywords
The following table describes the keywords and options that can be used with this action
| Keyword | Type | Default | Description |
|---|---|---|---|
| SPECIES | input | none | the list of atoms for which the symmetry function is being calculated and the atoms that can be in the environments |
| SPECIESA | input | none | the list of atoms for which the symmetry function is being calculated |
| SPECIESB | input | none | the list of atoms that can be in the environments of each of the atoms for which the symmetry function is being calculated |
| 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 | the switching function that it used in the construction of the contact matrix. Options for this keyword are explained in the documentation for LESS_THAN. |
| MASK | optional | not used | the label for a vector that is used to determine which rows of the matrix are computed |
| USEGPUThis keyword do not have examples | optional | false | run part of this calculation on the GPU |
deprecated keywords
The keywords in the following table can still be used with this action but have been deprecated
| Keyword | Description |
|---|---|
| LESS_THAN | calculate the number of variables that are less than a certain target value |
| MORE_THAN | calculate the number of variables that are more than a certain target value |
| ALT_MIN | calculate the minimum value |
| MIN | calculate the minimum value |
| MAX | calculate the maximum value |
| BETWEEN | calculate the number of values that are within a certain range |
| HIGHEST | this flag allows you to recover the highest of these variables |
| HISTOGRAM | calculate a discretized histogram of the distribution of values |
| LOWEST | this flag allows you to recover the lowest of these variables |
| SUM | calculate the sum of all the quantities |
| MEAN | calculate the mean of all the quantities |
References
More information about how this action can be used is available in the following articles:
- A. D. White, G. A. Voth, Efficient and Minimal Method to Bias Molecular Simulations with Experimental Data. Journal of Chemical Theory and Computation. 10, 3023–3030 (2014)
- W. Lechner, C. Dellago, Accurate determination of crystal structures based on averaged local bond order parameters. The Journal of Chemical Physics. 129 (2008)