diff --git a/src/function/Custom.cpp b/src/function/Custom.cpp index 2d33f7b4c4..71b6a6d18f 100644 --- a/src/function/Custom.cpp +++ b/src/function/Custom.cpp @@ -249,7 +249,32 @@ PRINT ARG=onaxis,fromaxis ``` The equations in this input were also used to combine [RMSD](RMSD.md) values from different snapshots of a protein so as to define -progression (S) and distance (Z) variables in the paper that is cited in the bibliography. +progression (S) and distance (Z) variables in the paper that is cited in the bibliography. We can understand how these expressions +are derived by noting that $x$, $y$ and $z$ are the distances between atoms 1 and 3, 2 and 3 and 1 and 2 respectively. The projection +of the vector connecting atom 1 to atom 3 onto the vector connecting atom 1 to atom 2 is thus $x\cos(\theta)$, where theta is the angle +between the vector connecting atoms 1 and 3 and the vector connecting atoms 1 and 2. We can arrive at the following expression for $x\cos(\theta)$ +by rearranging the cosine rule: + +$$ +x\cos(\theta) = \frac{y^2 - x^2}{z} - \frac{z}{2} +$$ + +Notice that the value called `onaxis` in the above input is thus $o=x\cos(\theta) + \frac{z}{2}$. Adding the factor of $\frac{z}{2}$ ensures that the origin +is at the center of the bond connecting atom 1 to atom 2. + +The value `fromaxis` measures the square of the distance from the the line. It is calculated using pythagoras theorem as follows: + +$$ +f^2 = y^2 - x^2\cos^2(\theta) +$$ + +Inserting $x\cos(\theta) = o - \frac{z}{2}$ into this expression gives: + +$$ +f^2 = y^2 - (o -\frac{z}{2})^2 = y^2 - o^2 + oz - \frac{z^2}{4} +$$ + +Inserting the fact that $oz = \frac{y^2 - x^2}{2}$, which comes from the expression for $o$ that was used to calculate `onaxis`, gets us to the expression that is used to calculate `fromaxis`. ## CUSTOM with vector arguments @@ -326,8 +351,8 @@ PRINT ARG=angles FILE=colvar Notice that you can pass multiple $N\times M$ matrices in the input to a CUSTOM action as illustrated in the example below: ```plumed -c1: CUSTOM VALUES=2,3,4,5 NROWS=2 NCOLS=2 -c2: CUSTOM VALUES=1,0,0,1 NROWS=2 NCOLS=2 +c1: CONSTANT VALUES=2,3,4,5 NROWS=2 NCOLS=2 +c2: CONSTANT VALUES=1,0,0,1 NROWS=2 NCOLS=2 f: CUSTOM ARG=c1,c2 FUNC=x*y PERIODIC=NO PRINT ARG=f FILE=colvar ``` diff --git a/src/function/FunctionOfMatrix.h b/src/function/FunctionOfMatrix.h index 048942acc1..a954c53586 100644 --- a/src/function/FunctionOfMatrix.h +++ b/src/function/FunctionOfMatrix.h @@ -182,6 +182,11 @@ FunctionOfMatrix::FunctionOfMatrix(const ActionOptions&ao): } } } + bool allconstant=true; + for(unsigned i=argstart; iisConstant() ) { allconstant=false; break; } + } + if( allconstant ) done_in_chain=false; // Now setup the action in the chain if we can nderivatives = buildArgumentStore(myfunc.getArgStart()); } diff --git a/src/function/Highest.cpp b/src/function/Highest.cpp index 94653f74a5..9406365e49 100644 --- a/src/function/Highest.cpp +++ b/src/function/Highest.cpp @@ -93,7 +93,7 @@ Notice that you can also use a combination of scalars and vectors in the input t ```plumed c: CONSTANT VALUE=0.05 d: DISTANCE ATOMS1=1,2 ATOMS2=3,4 -h: HIGHEST ARG=c,d +h: HIGHEST ARG=d,c PRINT ARG=h FILE=colvar ``` @@ -187,7 +187,7 @@ Notice that you can also use a combination of scalars and vectors in the input t ```plumed c: CONSTANT VALUE=0.5 d: DISTANCE ATOMS1=1,2 ATOMS2=3,4 -h: LOWEST ARG=c,d +h: LOWEST ARG=d,c PRINT ARG=h FILE=colvar ``` diff --git a/src/function/Moments.cpp b/src/function/Moments.cpp index cb3991b3dc..d856f22fe4 100644 --- a/src/function/Moments.cpp +++ b/src/function/Moments.cpp @@ -56,7 +56,7 @@ Notice that you can also achieve the same result using the following input: ```plumed d: DISTANCE ATOMS1=1,2 ATOMS2=1,3 ATOMS3=1,4 ATOMS4=1,5 -sort: MOMENTS ARG=d POWERS=2,3 +mv: MOMENTS ARG=d POWERS=2,3 PRINT ARG=mv.moment-2,mv.moment-3 FILE=colvar ``` diff --git a/src/function/Sum.cpp b/src/function/Sum.cpp index bbc0b49054..5982a7ee2d 100644 --- a/src/function/Sum.cpp +++ b/src/function/Sum.cpp @@ -46,7 +46,7 @@ This example calculates and outputs the number of distances that are less than 0 You can do something similar by summing the elements of a matrix as shown below: ```plumed -c: CONTACT_MATRIX SPECIES=1-100 SWITCH={RATIONAL R_0=0.1} +c: CONTACT_MATRIX GROUP=1-100 SWITCH={RATIONAL R_0=0.1} s: SUM ARG=c PERIODIC=NO PRINT ARG=s FILE=colvar ```