Action: OUTER_PRODUCT
Module | matrixtools |
---|---|
Description | Usage |
Calculate the outer product matrix of two vectors | |
output value | type |
a matrix containing the outer product of the two input vectors that was obtained using the function that was input | matrix |
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 | vector | the labels of the two vectors from which the outer product is being computed |
Further details and examples
Calculate the outer product matrix of two vectors
This action can be used to calculate the outer product of two vectors. As a (useless) example of what can be done with this action consider the following simple input:
d1DISTANCECalculate 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 d2 : DISTANCECalculate the distance/s between pairs of atoms. More details ATOMS1the pair of atom that we are calculating the distance between=5,6 ATOMS2the pair of atom that we are calculating the distance between=7,8 ATOMS3the pair of atom that we are calculating the distance between=9,10 ppOUTER_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=d1,d2 : PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=pp FILEthe name of the file on which to output these quantities=colvar:
This input outputs a 2×3 matrix. If we call the 2 dimensional vector output by the first DISTANCE action
d and the 3 dimensional vector output by the second DISTANCE action h then the (i,j) element of the matrix
output by the action with the label pp
is given by:
pij=dihj
These outer product matrices are useful if you are trying to calculate an adjacency matrix that says atoms are connected if they are within a certain distance of each other and if they satisfy a certain criterion. For example, consider the following input:
# Determine if atoms are within 5.3 nm of each other c1 : 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-100 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.={GAUSSIAN D_0=5.29 R_0=0.01 D_MAX=5.3} # Calculate the coordination numbers onesONESCreate 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=100 : cc : 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=c1,ones # Now use MORE_THAN to work out which atoms have a coordination number that is bigger than six cf : 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=cc SWITCHThis keyword is used if you want to employ an alternative to the continuous swiching function defined above={RATIONAL D_0=5.5 R_0=0.5} # Now recalculate the contact matrix above as first step towards calculating adjacency matrix that measures if # atoms are close to each other and both have a coordination number that is bigger than six c2 : 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-100 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.={GAUSSIAN D_0=5.29 R_0=0.01 D_MAX=5.3} # Now make a matrix in which element i,j is one if atom i and atom j both have a coordination number that is greater than 6 cfmOUTER_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=cf,cf : # And multiply this by our contact matrix to determine the desired adjacency matrix m : CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=c2,cfm 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 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=m FILEthe name of the file on which to output these quantities=colvar
This input calculates a adjacency matrix which has element (i,j) equal to one if atoms i and j have coordination numbers that are greater than 6 and if they are within 5.3 nm of each other.
Notice that you can specify the function of the two input vectors that is to be calculated by using the FUNC
keyword which accepts
mathematical expressions of x and y. In other words, the elements of the outer product are calculated using the lepton library
that is used in the CUSTOM action. In addition, you can set FUNC=min
or FUNC=max
to set the elements of the outer product equal to
the minimum of the two input variables or the maximum respectively.
Syntax
The following table describes the keywords and options that can be used with this action
Keyword | Type | Default | Description |
---|---|---|---|
ARG | input | none | the labels of the two vectors from which the outer product is being computed |
FUNC | compulsory | x*y | the function of the input vectors that should be put in the elements of the outer product |
SERIAL | optional | false | do the calculation in serial |
ELEMENTS_ON_DIAGONAL_ARE_ZERO | optional | false | set all diagonal elements to zero |