struct smooth::RationalSwitch#

Overview#

PLUMED RATIONAL switching function times a C2 taper. More…

#include <src/include/internal/smooth_cv.hpp>
 
struct RationalSwitch {
    // fields
 
    double r0 = 1.0;
    double d0 = 0.0;
    int n = 6;
    int m = 12;
    double dOn = 0.0;
    double dMax = 1.0;
 
    // methods
 
    void validate() const;
    double operator()(double r, double& dsdr) const;
};

Detailed Documentation#

PLUMED RATIONAL switching function times a C2 taper.

For x = (r - d0) / r0 the rational part is (1 - x^n) / (1 - x^m), evaluated as the ratio of the geometric sums 1 + x + … + x^(n-1) and 1 + x + … + x^(m-1), which has no removable singularity at x = 1, and above x = 1 as y^(m-n) times the same ratio in y = 1 / x. It is 1 for r at or below d0. The taper is 1 below dOn, 0 at and beyond dMax, and 1 - u^3 (10 - 15 u + 6 u^2) with u = (r - dOn) / (dMax - dOn) in between, so the product and its first two derivatives vanish at dMax. Near d0 the rational part is 1 - x^n + O(x^m), so s is C^(n-1) and not C^n at d0 > 0; at d0 = 0 and n = 1, s of the length of v has a cone at v = 0.

Methods#

void validate() const

Throws std::invalid_argument unless r0 > 0, n >= 1, m > n, n and m are at most kMaxSwitchExponent, 0 <= d0 <= dOn < dMax and every value is finite. m == 0 is read as 2n by makeSwitch before this check, and 2n must also be at most kMaxSwitchExponent.

double operator()(double r, double& dsdr) const

s(r), finite and not negative; dsdr receives ds/dr, the right derivative at r = d0. No power of x above 1 is formed, so only dsdr can leave double range, when r0 or dMax - dOn is near the smallest doubles.