Loading...
Searching...
No Matches
gpr::PairCutoff Class Reference

#include <gpr/auxiliary/PairCutoff.h>

Public Member Functions

 PairCutoff (double radius, double width=0.0)
RadialPairFeature operator() (double radius) const

Detailed Description

Compact inverse distance with matching value, slope, and curvature at both ends of a quintic switching shell. A zero cutoff is unbounded.

Definition at line 28 of file PairCutoff.h.

Constructor & Destructor Documentation

◆ PairCutoff()

gpr::PairCutoff::PairCutoff ( double radius,
double width = 0.0 )
inlineexplicit

Definition at line 30 of file PairCutoff.h.

31 : radius_(radius), width_(width)
32 {
33 if (!std::isfinite(radius_) || radius_ < 0.0 ||
34 !std::isfinite(width_) || width_ < 0.0)
35 throw std::invalid_argument(
36 "pair cutoff and width must be finite and nonnegative");
37 if (radius_ == 0.0) return;
38 if (width_ == 0.0) width_ = std::min(1.0, 0.2 * radius_);
39 if (!(width_ > 0.0) || width_ >= radius_)
40 throw std::invalid_argument(
41 "pair cutoff width must lie between zero and the cutoff");
42 }

Member Function Documentation

◆ operator()()

RadialPairFeature gpr::PairCutoff::operator() ( double radius) const
inlinenodiscard

Definition at line 44 of file PairCutoff.h.

45 {
46 if (!(radius > 0.0) || !std::isfinite(radius))
47 throw std::invalid_argument(
48 "pair distance must be finite and positive");
49 if (radius_ > 0.0 && radius >= radius_) return {0.0, 0.0, 0.0};
50 const double inverse = 1.0 / radius;
51 if (radius_ == 0.0 || radius <= radius_ - width_)
52 return {inverse, -inverse * inverse,
53 2.0 * inverse * inverse * inverse};
54 const double u = (radius_ - radius) / width_;
55 const double v = 1.0 - u;
56 const double value =
57 u * u * u * std::fma(v, std::fma(6.0, v, 3.0), 1.0);
58 const double first = -30.0 * u * u * v * v / width_;
59 const double second = 60.0 * u * v * (v - u) / (width_ * width_);
60 return {
61 value * inverse, (first - value * inverse) * inverse,
62 (second - 2.0 * first * inverse + 2.0 * value * inverse * inverse) *
63 inverse};
64 }

The documentation for this class was generated from the following file: