| TYPE | FUNCTION | EXAMPLE INPUT | DEFAULT PARAMETERS |
| RATIONAL |
\f$
s(r)=\frac{ 1 - \left(\frac{ r - d_0 }{ r_0 }\right)^{n} }{ 1 - \left(\frac{ r - d_0 }{ r_0 }\right)^{m} }
\f$
|
{RATIONAL R_0=\f$r_0\f$ D_0=\f$d_0\f$ NN=\f$n\f$ MM=\f$m\f$}
| \f$d_0=0.0\f$, \f$n=6\f$, \f$m=2n\f$ |
| EXP |
\f$
s(r)=\exp\left(-\frac{ r - d_0 }{ r_0 }\right)
\f$
|
{EXP R_0=\f$r_0\f$ D_0=\f$d_0\f$}
| \f$d_0=0.0\f$ |
| GAUSSIAN |
\f$
s(r)=\exp\left(-\frac{ (r - d_0)^2 }{ 2r_0^2 }\right)
\f$
|
{GAUSSIAN R_0=\f$r_0\f$ D_0=\f$d_0\f$}
| \f$d_0=0.0\f$ |
| SMAP |
\f$
s(r) = \left[ 1 + ( 2^{a/b} -1 )\left( \frac{r-d_0}{r_0} \right)^a \right]^{-b/a}
\f$
|
{SMAP R_0=\f$r_0\f$ D_0=\f$d_0\f$ A=\f$a\f$ B=\f$b\f$}
| \f$d_0=0.0\f$ |
| Q |
\f$
s(r) = \frac{1}{1 + \exp(\beta(r_{ij} - \lambda r_{ij}^0))}
\f$
|
{Q REF=\f$r_{ij}^0\f$ BETA=\f$\beta\f$ LAMBDA=\f$\lambda\f$ }
| \f$\lambda=1.8\f$, \f$\beta=50 nm^-1\f$ (all-atom) \f$\lambda=1.5\f$, \f$\beta=50 nm^-1\f$ (coarse-grained) |
| CUBIC |
\f$
s(r) = (y-1)^2(1+2y) \qquad \textrm{where} \quad y = \frac{r - r_1}{r_0-r_1}
\f$
|
{CUBIC D_0=\f$r_1\f$ D_MAX=\f$r_0\f$}
| |
| TANH |
\f$
s(r) = 1 - \tanh\left( \frac{ r - d_0 }{ r_0 } \right)
\f$
|
{TANH R_0=\f$r_0\f$ D_0=\f$d_0\f$}
| |
| COSINUS |
\f$s(r) =\left\{\begin{array}{ll}
1 & \mathrm{if } r \leq d_0 \\
0.5 \left( \cos ( \frac{ r - d_0 }{ r_0 } \pi ) + 1 \right) & \mathrm{if } d_0 < r\leq d_0 + r_0 \\
0 & \mathrm{if } r < d_0 + r_0
\end{array}\right.
\f$
|
{COSINUS R_0=\f$r_0\f$ D_0=\f$d_0\f$}
| |
| CUSTOM |
\f$
s(r) = FUNC
\f$
|
{CUSTOM FUNC=1/(1+x^6) R_0=\f$r_0\f$ D_0=\f$d_0\f$}
| |
Notice that most commonly used rational functions are better optimized and might run faster.
Notice that for backward compatibility we allow using `MATHEVAL` instead of `CUSTOM`.
Also notice that if the a `CUSTOM` switching function only depends on even powers of `x` it can be
made faster by using `x2` as a variable. For instance
\verbatim
{CUSTOM FUNC=1/(1+x2^3) R_0=0.3}
\endverbatim
is equivalent to
\verbatim
{CUSTOM FUNC=1/(1+x^6) R_0=0.3}
\endverbatim
but runs faster. The reason is that there is an expensive square root calculation that can be optimized out.
\attention
With the default implementation CUSTOM is slower than other functions
(e.g., it is slower than an equivalent RATIONAL function by approximately a factor 2).
Checkout page \ref Lepton to see how to improve its performance.
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 \f$r>d_{\textrm{max}}\f$ the switching function can be assumed equal to zero.
In this case the function is brought smoothly to zero by stretching and shifting it.
\verbatim
KEYWORD={RATIONAL R_0=1 D_MAX=3}
\endverbatim
the resulting switching function will be
\f$
s(r) = \frac{s'(r)-s'(d_{max})}{s'(0)-s'(d_{max})}
\f$
where
\f$
s'(r)=\frac{1-r^6}{1-r^{12}}
\f$
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.
*/
//+ENDPLUMEDOC
namespace switchContainers {
baseSwitch::baseSwitch(double D0,double DMAX, double R0, std::string_view name)
: d0(D0),
dmax(DMAX),
dmax_2([](const double d) {
if(d