Shortcut: EVALUATE_FUNCTION_FROM_GRID
| Module | gridtools |
|---|---|
| Description | Usage |
| Calculate the function stored on the input grid at an arbitrary point | |
| output value | type |
| interpolation of the input grid to get the value of the function at the input arguments | scalar |
Details and examples
Calculate the function stored on the input grid at an arbitrary point
This action can be used to evaluate a function that is stored on a grid at an arbitrary point in space via interpolation. For example, the following input illustrates how you can use this action to evaulate the square of the distance between atom 1 and atom 2
d2: REFERENCE_GRIDSetup a constant grid by either reading values from a file or definining a function in input More details GRID_MIN the lower bounds for the grid=0 GRID_MAX the upper bounds for the grid=10 GRID_BINthe number of bins for the grid=20 FUNCthe function to compute on the grid=d1*d1 VARthe names to give each of the grid directions in the function=d1 PERIODICare the grid directions periodic=NO d1: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 ff: EVALUATE_FUNCTION_FROM_GRIDCalculate the function stored on the input grid at an arbitrary point More details GRIDthe name of the grid that we are using to evaluate the function=d2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1,ff FILEthe name of the file on which to output these quantities=colvar
You can perform the same calculation using CUSTOM, which will do the calculation exactly and not perform any interpolation. However, if for some reaon you only have the values of the function at a grid of point EVALUATE_FUNCTION_FROM_GRID may be a useful alternative as you can use REFERENCE_GRID to read in the values of the function at your grid of point from a file as shown below:
#SETTINGS INPUTFILES=regtest/gridtools/rt-weights-integral/kde.grid
ff: REFERENCE_GRIDSetup a constant grid by either reading values from a file or definining a function in input More details FILEthe name of the file that contains the reference data=regtest/gridtools/rt-weights-integral/kde.gridClick here to see an extract from this file.VALUEthe name of the value that should be read from the grid=h aa: ANGLECalculate one or multiple angle/s. More details ATOMSthe list of atoms involved in this collective variable (either 3 or 4 atoms)=1,2,3 tt: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4 val: EVALUATE_FUNCTION_FROM_GRIDCalculate the function stored on the input grid at an arbitrary point More details ... GRIDthe name of the grid that we are using to evaluate the function=ff INTERPOLATION_TYPE the method to use for interpolation=spline ZERO_OUTSIDE_GRID_RANGE if we are asked to evaluate the function for a number that is outside the range of the grid set it to zero ... PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=aa,tt,val FILEthe name of the file on which to output these quantities=colvar
Notice that the ARG command does not need to be used with the EVALUATE_FUNCTION_FROM_GRID command to specify the labels of the input arguments at which you
would like the function to be evaluated. Instead, you only specify the GRID that is being used as input for the interpolation. The reason that it is not
necessary to specify the arguments is that PLUMED stores labels for each coordinate axis of a grid. These labels appear at the top of the
columns that contain the grid points when you output grids using DUMPGRID. Furthermore, in the first of the inputs above the labels of these
input arguments are specified using the VAR option for REFERENCE_GRID. Meanwhile, for the second the titles of the columsn are
read in from the input file. Consequently, PLUMED searches for a value named d1 when evaluating ff in the first input. For the second input it searches
for values labelled aa and tt and evaluates val from them. You can, however, also use an ARG keyword in the input file as illustrated below if this helps
you to remember what precisely is being evluated:
d2: REFERENCE_GRIDSetup a constant grid by either reading values from a file or definining a function in input More details GRID_MIN the lower bounds for the grid=0 GRID_MAX the upper bounds for the grid=10 GRID_BINthe number of bins for the grid=20 FUNCthe function to compute on the grid=d1*d1 VARthe names to give each of the grid directions in the function=d1 PERIODICare the grid directions periodic=NO d1: DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 ff: EVALUATE_FUNCTION_FROM_GRIDCalculate the function stored on the input grid at an arbitrary point More details GRIDthe name of the grid that we are using to evaluate the function=d2 ARGthe arguments that you would like to use when evaluating the function=d1 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=d1,ff FILEthe name of the file on which to output these quantities=colvar
Notice that input the inputs above the input values are scalars. The output from EVALUATE_FUNCTION_FROM_GRID is thus also a scalar. If, however, one uses an input such as the one shown below:
#SETTINGS INPUTFILES=regtest/gridtools/rt-weights-integral/kde.grid
ff: REFERENCE_GRIDSetup a constant grid by either reading values from a file or definining a function in input More details FILEthe name of the file that contains the reference data=regtest/gridtools/rt-weights-integral/kde.gridClick here to see an extract from this file.VALUEthe name of the value that should be read from the grid=h aa: ANGLECalculate one or multiple angle/s. More details ATOMS1the list of atoms involved in this collective variable (either 3 or 4 atoms)=1,2,3 ATOMS2the list of atoms involved in this collective variable (either 3 or 4 atoms)=4,5,6 ATOMS3the list of atoms involved in this collective variable (either 3 or 4 atoms)=7,8,9 tt: 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 val: EVALUATE_FUNCTION_FROM_GRIDCalculate the function stored on the input grid at an arbitrary point More details GRIDthe name of the grid that we are using to evaluate the function=ff PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=aa,tt,val FILEthe name of the file on which to output these quantities=colvar
The value, val, that is output by the EVALUATE_FUNCTION_FROM_GRID action will be a vector. In other words, in the same way you can use scalars, vectors, matrices and even
functions on grids in the input to the CUSTOM command you can also use scalars, vectors, matrices and functions on grid in the input to the EVALUATE_FUNCTION_FROM_GRID
command.
The MASK keyword
If the input to this action is a vector you can use the MASK keyword as illustrated below:
#SETTINGS INPUTFILES=regtest/gridtools/rt-weights-integral/kde.grid
ff: REFERENCE_GRIDSetup a constant grid by either reading values from a file or definining a function in input More details FILEthe name of the file that contains the reference data=regtest/gridtools/rt-weights-integral/kde.gridClick here to see an extract from this file.VALUEthe name of the value that should be read from the grid=h 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=4,5 ATOMS3the pair of atom that we are calculating the distance between=7,8 m: LESS_THANUse a switching function to determine how many of the input variables are less 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={CUSTOM R_0=1 FUNC=step(0.1-x)} aa: ANGLECalculate one or multiple angle/s. More details ATOMS1the list of atoms involved in this collective variable (either 3 or 4 atoms)=1,2,3 ATOMS2the list of atoms involved in this collective variable (either 3 or 4 atoms)=4,5,6 ATOMS3the list of atoms involved in this collective variable (either 3 or 4 atoms)=7,8,9 tt: 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 val: EVALUATE_FUNCTION_FROM_GRIDCalculate the function stored on the input grid at an arbitrary point More details GRIDthe name of the grid that we are using to evaluate the function=ff MASKthe label for a sparse vector/matrix that should be used to determine which elements of the vector/matrix should be computed=m prod: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=m,val 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: 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 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=sum FILEthe name of the file on which to output these quantities=colvar
This input calculates the function of the angles and torsions that is provided in the input grid file for the three pairs of input angles and torsions. The sum of these quantities
is then computed. Importantly, however, each of the evaluated values of the function is only added to the final sum if the corresponding distance that is calculated by the DISTANCE
action with label d is less than 0.1 nm.
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 |
|---|---|---|
| GRID | grid | the name of the grid that we are using to evaluate the function |
| ARG | scalar/vector | the arguments that you would like to use when evaluating the 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 |
|---|---|---|---|
| GRID | input | none | the name of the grid that we are using to evaluate the function |
| ARG | input | none | the arguments that you would like to use when evaluating the 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 |
| INTERPOLATION_TYPE | compulsory | spline | the method to use for interpolation |
| ZERO_OUTSIDE_GRID_RANGE | optional | false | if we are asked to evaluate the function for a number that is outside the range of the grid set it to zero |