switchingfunction

Functions that measure whether values are less than a certain quantity. Functions that measure whether values are less than a certain quantity.

Switching functions \(s(r)\) take a minimum of one input parameter \(d_0\). For \(r \le d_0 \quad s(r)=1.0\) while for \(r > d_0\) the function decays smoothly to 0. The various switching functions available in plumed differ in terms of how this decay is performed.

Where there is an accepted convention in the literature (e.g. COORDINATION) on the form of the switching function we use the convention as the default. However, the flexibility to use different switching functions is always present generally through a single keyword. This keyword generally takes an input with the following form:

KEYWORD={TYPE <list of parameters>}

The following table contains a list of the various switching functions that are available in plumed 2 together with an example input.

TYPE FUNCTION EXAMPLE INPUT DEFAULT PARAMETERS
RATIONAL \( s(r)=\frac{ 1 - \left(\frac{ r - d_0 }{ r_0 }\right)^{n} }{ 1 - \left(\frac{ r - d_0 }{ r_0 }\right)^{m} } \) {RATIONAL R_0= \(r_0\) D_0= \(d_0\) NN= \(n\) MM= \(m\)} \(d_0=0.0\), \(n=6\), \(m=2n\)
EXP \( s(r)=\exp\left(-\frac{ r - d_0 }{ r_0 }\right) \) {EXP R_0= \(r_0\) D_0= \(d_0\)} \(d_0=0.0\)
GAUSSIAN \( s(r)=\exp\left(-\frac{ (r - d_0)^2 }{ 2r_0^2 }\right) \) {GAUSSIAN R_0= \(r_0\) D_0= \(d_0\)} \(d_0=0.0\)
SMAP \( s(r) = \left[ 1 + ( 2^{a/b} -1 )\left( \frac{r-d_0}{r_0} \right)^a \right]^{-b/a} \) {SMAP R_0= \(r_0\) D_0= \(d_0\) A= \(a\) B= \(b\)} \(d_0=0.0\)
Q \( s(r) = \frac{1}{1 + \exp(\beta(r_{ij} - \lambda r_{ij}^0))} \) {Q REF= \(r_{ij}^0\) BETA= \(\beta\) LAMBDA= \(\lambda\) } \(\lambda=1.8\), \(\beta=50 nm^-1\) (all-atom)
\(\lambda=1.5\), \(\beta=50 nm^-1\) (coarse-grained)
CUBIC \( s(r) = (y-1)^2(1+2y) \qquad \textrm{where} \quad y = \frac{r - r_1}{r_0-r_1} \) {CUBIC D_0= \(r_1\) D_MAX= \(r_0\)}
TANH \( s(r) = 1 - \tanh\left( \frac{ r - d_0 }{ r_0 } \right) \) {TANH R_0= \(r_0\) D_0= \(d_0\)}
MATHEVAL \( s(r) = FUNC \) {MATHEVAL FUNC=1/(1+x^6) R_0= \(r_0\) D_0= \(d_0\)}
Attention
Similarly to the MATHEVAL function, the MATHEVAL switching function only works if one of these two conditions is satisfied: (a) libmatheval is installed on the system and PLUMED has been linked to it or (b) the environment variable PLUMED_USE_LEPTON is set equal to yes at runtime (in this case, the internal lepton library will be used). Notice that in version v2.5 the internal lepton library will be used by default. Also notice that using MATHEVAL is much slower than using e.g. RATIONAL. Thus, the MATHEVAL switching function is useful to perform quick tests on switching functions with arbitrary form before proceeding to their implementation in C++.

For all the switching functions in the above table one can also specify a further (optional) parameter using the parameter keyword D_MAX to assert that for \(r>d_{\textrm{max}}\) the switching function can be assumed equal to zero. In this case the function is brought smoothly to zero by stretching and shifting it.

KEYWORD={RATIONAL R_0=1 D_MAX=3}

the resulting switching function will be \( s(r) = \frac{s'(r)-s'(d_{max})}{s'(0)-s'(d_{max})} \) where \( s'(r)=\frac{1-r^6}{1-r^{12}} \) Since PLUMED 2.2 this is the default. The old behavior (no stretching) can be obtained with the NOSTRETCH flag. The NOSTRETCH keyword is only provided for backward compatibility and might be removed in the future. Similarly, the STRETCH keyword is still allowed but has no effect.

Notice that switching functions defined with the simplified syntax are never stretched for backward compatibility. This might change in the future.