Shortcut: PIECEWISE
Module | function |
---|---|
Description | Usage |
Compute a piece wise straight line through its arguments that passes through a set of ordered control points. |
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 |
Further details and examples
Compute a piece wise straight line through its arguments that passes through a set of ordered control points.
This action can be used to calculate a piecewise linear function of an input argument such as the one given below:
f(x)={10ifx<110+π−102−1(x−1)if1≤x<2π+10−π3−2(x−2)if2≤x≤310otherwise
The example shown below illustrates how one can use PLUMED to evaluate the function described above for the distance between atom 1 and atom 2.
dist1DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,10 pw : PIECEWISECompute a piece wise straight line through its arguments that passes through a set of ordered control points. More details POINT0This keyword is used to specify the various points in the function above=1,10 POINT1This keyword is used to specify the various points in the function above=2,PI POINT2This keyword is used to specify the various points in the function above=3,10 ARGthe values input to this function=dist1 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=pw FILEthe name of the file on which to output these quantities=colvar:
As you can see from the example above, the control points for the picewise function are passed using the POINT0=...
POINT1=...
syntax.
You can specify as many of these control points as you want. These control points then serce as the xi and yi values in the following expression.
For variables less than the first (greater than the last) point, the value of the first (last) point is used.
yi+1−yixi+1−xi(s−xi)+yi;ifxi<s<xi+1
If the input value of s is smaller than the lowest specified xi value then this action outputs the yi value that corresponds to the smallest of the input xi values. Similarly, if the input value of s is larger than the highest specified xi value the yi value that corresponds to the largest of the input xi values is output.
Using multiple scalars in input
The following example illustrates what happens when multiple scalar arguments are passed to this action:
dist1DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,10 dist2 : DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=2,11 ppww : PIECEWISECompute a piece wise straight line through its arguments that passes through a set of ordered control points. More details POINT0This keyword is used to specify the various points in the function above=1,10 POINT1This keyword is used to specify the various points in the function above=2,PI POINT2This keyword is used to specify the various points in the function above=3,10 ARGthe values input to this function=dist1,dist2 PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=ppww.dist1_pfunc,ppww.dist2_pfunc:
In essence the piecewise function is applied to each of the input arguments in turn. Hence, in the example above the PIECEWISE command outputs two values. The first of
these ppww.dist1_pfunc
is the result that is obtained when the piecewise function is applied to the argument dist1
. The second is then the result that is obtained when the
piecewise function is applied to the argument dist2
.
Non rank zero arguments
This argument currently cannot accept non-rank zero arguments. However, it would be extremely straightforward to add functionality to ensure that if a PIECEWISE command receives a vector, matrix or function on grid in input it will output a vector, matrix or function on grid that is obtained by applying the piecewise function elementwise to each of the elements of the input vector, matrix or function.
Syntax
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 |
POINT | compulsory | none | This keyword is used to specify the various points in the function above |