From 2d850bba41079d9d008897c03a68f509390f7e75 Mon Sep 17 00:00:00 2001 From: Gareth Aneurin Tribello Date: Fri, 22 Nov 2024 18:12:40 +0000 Subject: [PATCH] Fixed some mistakes in manual for functions --- src/function/Between.cpp | 5 ++++- src/function/Combine.cpp | 4 ++-- src/function/Custom.cpp | 18 +++++++++--------- src/function/FuncPathMSD.cpp | 6 +++--- src/function/Moments.cpp | 2 +- src/function/Sum.cpp | 2 +- src/generic/Constant.cpp | 2 +- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/function/Between.cpp b/src/function/Between.cpp index e06c347807..8fead2bb58 100644 --- a/src/function/Between.cpp +++ b/src/function/Between.cpp @@ -21,6 +21,7 @@ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #include "Between.h" #include "FunctionShortcut.h" +#include "FunctionOfScalar.h" #include "FunctionOfVector.h" #include "FunctionOfMatrix.h" #include "core/ActionRegister.h" @@ -66,7 +67,7 @@ The $\sigma$ values in the expressions above is calculated from the parameters $ Also note that the Kernel function $K$ that is used in the first example is a Gaussian. The actual integral that is evaluated is thus: $$ -w(s) = \frac{1}{\sqrt{2\pi}\sigma} \int_a^b \exp\left( -\frac{(x-s)^2}{2\sigma^2} \textrm{d}x +w(s) = \frac{1}{\sqrt{2\pi}\sigma} \int_a^b \exp\left( -\frac{(x-s)^2}{2\sigma^2}\right) \textrm{d}x $$ The Gaussian kernel in this expression can be replaced by a triangular Kernel by changing the input to: @@ -158,6 +159,8 @@ Transform all the elements of a matrix using a switching function that is oen wh typedef FunctionShortcut BetweenShortcut; PLUMED_REGISTER_ACTION(BetweenShortcut,"BETWEEN") +typedef FunctionOfScalar ScalarBetween; +PLUMED_REGISTER_ACTION(ScalarBetween,"BETWEEN_SCALAR") typedef FunctionOfVector VectorBetween; PLUMED_REGISTER_ACTION(VectorBetween,"BETWEEN_VECTOR") typedef FunctionOfMatrix MatrixBetween; diff --git a/src/function/Combine.cpp b/src/function/Combine.cpp index 500d692ba6..7ab212eafc 100644 --- a/src/function/Combine.cpp +++ b/src/function/Combine.cpp @@ -98,7 +98,7 @@ COMBINE action that takes vectors and scalars in input. ```plumed p: CONSTANT VALUE=2 d: DISTANCE ATOMS1=1,2 ATOMS2=3,4 ATOMS3=5,6 ATOMS4=7,8 -c: COMBINE ARG=d,p COEFFICIENTS=4,-1 POWERS=2.5,1 +c: COMBINE ARG=d,p COEFFICIENTS=4,-1 POWERS=2.5,1 PERIODIC=NO PRINT ARG=c FILE=colvar ``` @@ -117,7 +117,7 @@ Lastly, notice that if you pass a single vector in input to COMBINE as in the fo ```plumed d: DISTANCE ATOMS1=1,2 ATOMS2=3,4 ATOMS3=5,6 ATOMS4=7,8 -c: COMBINE ARG=d COEFFICIENTS=4 POWERS=2.5 PARAMETERS=0.5 +c: COMBINE ARG=d COEFFICIENTS=4 POWERS=2.5 PARAMETERS=0.5 PERIODIC=NO PRINT ARG=c FILE=colvar ``` diff --git a/src/function/Custom.cpp b/src/function/Custom.cpp index 367f24cc00..2d33f7b4c4 100644 --- a/src/function/Custom.cpp +++ b/src/function/Custom.cpp @@ -101,7 +101,7 @@ that you can use in in the input to the `FUNC` keyword for CUSTOM. | cos(x) | The cosine of x | | sec(x) | The reciprocal of the cosine of $x$. $\frac{1}{\cos(x)}$ | | csc(x) | The reciprocal of the sine of $x$. $\frac{1}{\sin(x)}$ | -| tan(x) | The tangent of x i.e. $\frac{\sin(x)}(\cos(x)}$ | +| tan(x) | The tangent of x i.e. $\frac{\sin(x)}{\cos(x)}$ | | cot(x) | The reciprocal of the tangent of $x$. $\frac{1}{\tan(x)}$ | | asin(x) | The principal arc sine of x. Returns $-\frac{\pi}{2} \le y \le \frac{\pi}{2}$ which gives $x = \sin(y)$ | | acos(x) | The principal arc cosine of x. Returns $0 \le y \le \pi$ which gives $x=\cos(y)$ | @@ -110,8 +110,8 @@ that you can use in in the input to the `FUNC` keyword for CUSTOM. | sinh(x) | The hyperbolic sine of $x$ | | cosh(x) | the hyperbolic cosine of $x$ | | tanh(x) | The hyperbolic tangent of $x$ | -| erf(x) | The [error function](https://en.wikipedia.org/wiki/Error_function) $\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2} \txtrm{d}t$ | -| erfc(x) | The complementary error function $1-\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2} \txtrm{d}t$ | +| erf(x) | The [error function](https://en.wikipedia.org/wiki/Error_function) $\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2} \textrm{d}t$ | +| erfc(x) | The complementary error function $1-\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2} \textrm{d}t$ | | step(x) | 1 if $x \ge 0$ and 0 otherwise | | delta(x) | inf if $x=0$ and 0 otherwise | | nandelta(x) | nan if $x=0$ and 0 otherwise | @@ -120,7 +120,7 @@ that you can use in in the input to the `FUNC` keyword for CUSTOM. | recip(x) | The reciprocal of x i.e. $\frac{1}{x}$ | | min(x,y) | If $xy$ this function returns $x$. If $y\ge x$ this function returns $y$ | -| abs(x) | The absolute value of x i.e. $|x|$ | +| abs(x) | The absolute value of x | | floor(x) | The largest integer that is less than $x$ | | ceil(x) | The smallest integer that is greater than $x$ | | select(x,y,z) | If $x==0$ this returns $z$ otherwise this returns $y$ | @@ -208,7 +208,7 @@ Notice that you can use CUSTOM to implement a [MOVINGRESTRAINT](MOVINGRESTRAINT. ```plumed t: TIME d: DISTANCE ATOMS=1,2 -f: CUSTOM ARG=d,t FUNC=100*(d-((0.2-0.1)*t/100))^2 PERIODIC=NO +f: CUSTOM ARG=d,t FUNC=100*(x-((0.2-0.1)*y/100))^2 PERIODIC=NO BIASVALUE ARG=f ``` @@ -310,9 +310,9 @@ d: DISTANCE COMPONENTS ATOMS1=1,2 ATOMS2=3,4 ATOMS3=5,6 ATOMS4=7,8 # Calculate the norm of these four vectors norm: CUSTOM ARG=d.x,d.y,d.z FUNC=sqrt(x*x+y*y+z*z) PERIODIC=NO # Now calculate the directors of the vectors -norm_x: CUSTOM ARG=d.x,norm FUNC=x/y PEROIDIC=NO -norm_y: CUSTOM ARG=d.y,norm FUNC=x/y PEROIDIC=NO -norm_z: CUSTOM ARG=d.z,norm FUNC=x/y PEROIDIC=NO +norm_x: CUSTOM ARG=d.x,norm FUNC=x/y PERIODIC=NO +norm_y: CUSTOM ARG=d.y,norm FUNC=x/y PERIODIC=NO +norm_z: CUSTOM ARG=d.z,norm FUNC=x/y PERIODIC=NO # And combine all these directors in a matrix stack: VSTACK ARG=norm_x,norm_y,norm_z # Now calculate the matrix of dot products between directors (these are the cosines of the angles) @@ -328,7 +328,7 @@ Notice that you can pass multiple $N\times M$ matrices in the input to a CUSTOM ```plumed c1: CUSTOM VALUES=2,3,4,5 NROWS=2 NCOLS=2 c2: CUSTOM VALUES=1,0,0,1 NROWS=2 NCOLS=2 -f: CUSTOM ARG=c1,c2 FUNC=x*y PEIRODIC=NO +f: CUSTOM ARG=c1,c2 FUNC=x*y PERIODIC=NO PRINT ARG=f FILE=colvar ``` diff --git a/src/function/FuncPathMSD.cpp b/src/function/FuncPathMSD.cpp index acce1172ed..156b84fd02 100644 --- a/src/function/FuncPathMSD.cpp +++ b/src/function/FuncPathMSD.cpp @@ -43,9 +43,9 @@ calculate the progress along the path and the distance from it in p1 ```plumed #SETTINGS INPUTFILES=regtest/trajectories/path_msd/frame_1.dat,regtest/trajectories/path_msd/frame_21.dat,regtest/trajectories/path_msd/frame_42.dat -t1: RMSD REFERENCE=regtest/trajectories/path_msd/frame_1.pdb TYPE=OPTIMAL SQUARED -t2: RMSD REFERENCE=regtest/trajectories/path_msd/frame_21.pdb TYPE=OPTIMAL SQUARED -t3: RMSD REFERENCE=regtest/trajectories/path_msd/frame_42.pdb TYPE=OPTIMAL SQUARED +t1: RMSD REFERENCE=regtest/trajectories/path_msd/frame_1.dat TYPE=OPTIMAL SQUARED +t2: RMSD REFERENCE=regtest/trajectories/path_msd/frame_21.dat TYPE=OPTIMAL SQUARED +t3: RMSD REFERENCE=regtest/trajectories/path_msd/frame_42.dat TYPE=OPTIMAL SQUARED p1: FUNCPATHMSD ARG=t1,t2,t3 LAMBDA=500.0 PRINT ARG=t1,t2,t3,p1.s,p1.z STRIDE=1 FILE=colvar FMT=%8.4f ``` diff --git a/src/function/Moments.cpp b/src/function/Moments.cpp index e0755b2411..cb3991b3dc 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: SORT ARG=d +sort: 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 7601e17afa..bbc0b49054 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_MAP SPECIES=1-100 SWITCH={RATIONAL R_0=0.1} +c: CONTACT_MATRIX SPECIES=1-100 SWITCH={RATIONAL R_0=0.1} s: SUM ARG=c PERIODIC=NO PRINT ARG=s FILE=colvar ``` diff --git a/src/generic/Constant.cpp b/src/generic/Constant.cpp index 479976aafc..133485036f 100644 --- a/src/generic/Constant.cpp +++ b/src/generic/Constant.cpp @@ -115,7 +115,7 @@ in the following input the values `d` and `f` are evaluated on every step. `c` p: CONSTANT VALUE=1.0 c: CUSTOM ARG=p FUNC=2*x+1 PERIODIC=NO d: DISTANCE ATOMS=1,2 -f: CUSTOM ARG=p,d FUNX=x*y PERIODIC=NO +f: CUSTOM ARG=p,d FUNC=x*y PERIODIC=NO PRINT ARG=f FILE=colvar STRIDE=1 ```