Shortcut: COMBINE
| Module | function |
|---|---|
| Description | Usage |
| Calculate a polynomial combination of a set of other variables. | |
| output value | type |
| a linear combination | scalar/vector/matrix |
Details and examples
Calculate a polynomial combination of a set of other variables.
This action takes in arguments () and computes the following function of them:
The , and values in this expression are provided through the COEFFICIENTS, PARAMETERS and POWERS keywords respectively. The following example illustrates how this action can be used to calculate and print the square of the distance between atom 1 and atom 2.
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 COMPONENTS calculate the x, y and z components of the distance separately and store them as label c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=d.x,d.y,d.z COEFFICIENTS the coefficients of the arguments in your function=1,1,1 PARAMETERS the parameters of the arguments in your function=0,0,0 POWERS the powers to which you are raising each of the arguments in your function=2,2,2 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=c FILEthe name of the file on which to output these quantities=colvar
Notice that if the COEFFICIENTS keyword is absent all the values are set equal to 1. Furthermore, if the PARAMETERS keyword is absent all the values are set equal to 0. We can thus make use of these defaults and rewrite the input above as:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 COMPONENTS calculate the x, y and z components of the distance separately and store them as label c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=d.x,d.y,d.z POWERS the powers to which you are raising each of the arguments in your function=2,2,2 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=c FILEthe name of the file on which to output these quantities=colvar
Notice that we cannot remove the POWERS keyword here as if it is absent all the values are set equal to 1.
The NORMALIZE flag
Using the NORAMALIZE flag in the input below ensures that the coefficients of the three input scalars are all set equal to one:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 COMPONENTS calculate the x, y and z components of the distance separately and store them as label c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=d.x,d.y,d.z NORMALIZE normalize all the coefficients so that in total they are equal to one 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=c FILEthe name of the file on which to output these quantities=colvar
Notice that you can use this flag together with the coefficient keyword as shown below:
d: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 COMPONENTS calculate the x, y and z components of the distance separately and store them as label c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=d.x,d.y,d.z NORMALIZE normalize all the coefficients so that in total they are equal to one COEFFICIENTS the coefficients of the arguments in your function=2,1,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=c FILEthe name of the file on which to output these quantities=colvar
The coefficients of d.x, d.y and d.z for this input are 1/3, 1/6 and 1/2 respectively.
Periodic arguments
The COMBINE action is not able to predict the periodic domain for the function that is computed from the arguments automatically. The user is thus forced to specify it explicitly. Use PERIODIC=NO if the resulting variable is not periodic, and PERIODIC=A,B where A and B are the two boundaries for the periodic domain if the resulting variable is periodic. The following provides an example where the output from combine has a periodic domain. In this input we are taking the cube of a dihedral angle. The dihedral angle has a periodic domain that runs from to . The cube of this variable thus has a periodic domain that runs from to as indicated in the following input.
t: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,3,5,7 #c: COMBINE ARG=t POWERS=3 PERIODIC=-31.0062766802998,31.0062766802998 c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=t POWERS the powers to which you are raising each of the arguments in your function=3 PERIODICif the output of your function is periodic then you should specify the periodicity of the function=-pi^3,pi^3 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=c FILEthe name of the file on which to output these quantities=colvar
Vector arguments
The two examples in the previous section demonstrate how to use the COMBINE action with scalar arguments. However, you can also pass arguments to this action that have a rank greater than zero. For example, in the example below COMBINE accepts three vectors with 4 elements in input:
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 COMPONENTS calculate the x, y and z components of the distance separately and store them as label c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=d.x,d.y,d.z POWERS the powers to which you are raising each of the arguments in your function=2,2,2 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=c FILEthe name of the file on which to output these quantities=colvar
The output from the COMBINE action here is also a vector with four elements. The first element of this vector is the square of the distance betwen atoms 1 and 2, the second is the square of the distance between atoms 3 and 4 and so on.
The COMBINE action can also take a mixture of scalars and vectors in input as long as the labels of vectors appear before the labels of scalars in the input to the ARG keyword. The following input illustrates an COMBINE action that takes vectors and scalars in input.
p: 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 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 c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=d,p COEFFICIENTS the coefficients of the arguments in your function=4,-1 POWERS the powers to which you are raising each of the arguments in your function=2.5,1 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=c FILEthe name of the file on which to output these quantities=colvar
The elements of the vector that is calculated by the COMBINE action here are given by:
The in this expression are the distances that were calculated by the DISTANCE action. The 2 comes
from the scalar p that passed to the ARG action in input. As a single scalar is passed the same number is
used when calculating all 4 elements of the output vector. In other words, the scalar behaves as if it is a
vector with four components that all have the same value.
Lastly, notice that if you pass a single vector in input to COMBINE as in the following example, the output is still a vector:
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 c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=d COEFFICIENTS the coefficients of the arguments in your function=4 POWERS the powers to which you are raising each of the arguments in your function=2.5 PARAMETERS the parameters of the arguments in your function=0.5 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=c FILEthe name of the file on which to output these quantities=colvar
To calculate the 4-dimensional output by the COMBINE action here we subtract 0.5 from each of the input distances, raise the result from this subtraction to the power 2.5 and then multiply the result by 4.
If you want to calculate a linear combination of the elements of a vector using the formula at the top of the page you should use the CUSTOM action to transform all the components of the input vector. You can then add all the results from these transformations together using SUM.
Matrix arguments
You can also use matrices in the input to the COMBINE action as illustrated below:
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,2 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=3,4,5 COMPONENTS also calculate the components of the vector connecting the atoms in the contact matrix c: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=d.x,d.y,d.z POWERS the powers to which you are raising each of the arguments in your function=2,2,2 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=c FILEthe name of the file on which to output these quantities=colvar
The input to the combine action here consists of three matrices. The output is thus a matrix that contains the squares of the distances between the atoms in GROUPA and the atoms in GROUPB. Notice that all the input matrices must have the same size as the elements of the final matrix are calculated by applying the formula in the first section of this input to each set of elements to the input matrices in turn.
The input to this action can be a combination of matrices and scalars as long as the labels of the matrices appear before the labels of the scalars in the input for the ARG keyword. If your input arguments are an matrix and a scalar the scalar is treated as if it is a matrix which has all its elements equal to the input scalar. You cannot use a mixture of vectors and matrices in the input to this action.
Furthermore, if you pass a single matrix to COMBINE the output is a matrix. To calculate a linear combination of all the elements in a matrix using the formula at the top of the page you should use the CUSTOM action to transform all the components of the input vector. You can then add all the results from these transformations together using SUM.
The MASK keyword
The example input below illustrates a way you can use the MASK keyword to improve PLUMED performance for inputs that use COMBINE actions that take arguments that are vectors:
# 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 ow: GROUPDefine a group of atoms so that a particular list of atoms can be referenced with a single label in definitions of CVs or virtual atoms. More details ATOMSthe numerical indexes for the set of atoms in the group=1-400 hw: GROUPDefine a group of atoms so that a particular list of atoms can be referenced with a single label in definitions of CVs or virtual atoms. More details ATOMSthe numerical indexes for the set of atoms in the group=401-1200 # 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=ow 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 coordination with oxygen atoms ow_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 ow_mat: 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=ow MASKa vector that is used to used to determine which rows of the adjancency matrix to compute=sphere 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=0.8} ow_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=ow_mat,ow_ones # Calculate the coordination with hydrogen atoms hw_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=800 hw_mat: CONTACT_MATRIXAdjacency matrix in which two atoms are adjacent if they are within a certain cutoff. 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=ow 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=hw MASKa vector that is used to used to determine which rows of the adjancency matrix to compute=sphere 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.1 D_MAX=0.5} hw_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=hw_mat,hw_ones # And do the linear combination of the transformed coordination numbers together prod: COMBINECalculate a polynomial combination of a set of other variables. More details ARGthe values input to this function=hw_coord,ow_coord COEFFICIENTS the coefficients of the arguments in your function=2,8 MASKthe label for a sparse vector/matrix that should be used to determine which elements of the vector/matrix should be computed=sphere 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 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 cv: 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=cv 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
The variable being computed is computed for the oxygen atoms in a spherical region centered on the point and is a linear combination of the coordination number of the atoms in this region with the oxygen atoms and the coordination number of the atoms in this region with the hydrogen atoms. The average value of this linear combination for the atoms that are within this region is output.
If the arguments input to the COMBINE action are matrices then the MASK keyword is used in the way that is described in the documentation for the CUSTOM.
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 |
| PERIODIC | compulsory | none | if the output of your function is periodic then you should specify the periodicity of the function |
| COEFFICIENTS | compulsory | 1.0 | the coefficients of the arguments in your function |
| PARAMETERS | compulsory | 0.0 | the parameters of the arguments in your function |
| POWERS | compulsory | 1.0 | the powers to which you are raising each of the arguments in your function |
| NORMALIZE | optional | false | normalize all the coefficients so that in total they are equal to one |