8 #ifndef IMPATOM_SMOOTHING_FUNCTIONS_H
9 #define IMPATOM_SMOOTHING_FUNCTIONS_H
11 #include <IMP/atom/atom_config.h>
17 IMPATOM_BEGIN_NAMESPACE
40 virtual double operator()(
double score,
double distance)
const = 0;
47 double distance)
const = 0;
73 double min_distance_, max_distance_;
74 double value_prefactor_, deriv_prefactor_;
76 inline double get_value(
double distance)
const {
77 if (distance <= min_distance_) {
79 }
else if (distance > max_distance_) {
82 double d = max_distance_ - distance;
83 return value_prefactor_ * d * d *
84 (max_distance_ + 2.0 * distance - 3.0 * min_distance_);
88 inline double get_deriv(
double distance)
const {
89 if (distance <= min_distance_ || distance > max_distance_) {
92 return deriv_prefactor_ * (max_distance_ - distance) *
93 (min_distance_ - distance);
98 ForceSwitch(
double min_distance,
double max_distance)
99 : min_distance_(min_distance), max_distance_(max_distance) {
101 "max_distance should be greater than min_distance");
102 double dist_dif = max_distance - min_distance;
103 value_prefactor_ = 1.0 / (dist_dif * dist_dif * dist_dif);
104 deriv_prefactor_ = 6.0 * value_prefactor_;
107 double operator()(
double score,
double distance)
const override {
108 double factor = get_value(distance);
109 return score * factor;
113 double distance)
const override {
114 double factor = get_value(distance);
115 double deriv_factor = get_deriv(distance);
116 return std::make_pair(score * factor,
117 score * deriv_factor + deriv * factor);
123 IMPATOM_END_NAMESPACE
Helper macros for implementing IMP Objects.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
Ref counted objects should have private destructors.
Common base class for heavy weight IMP objects.
DerivativePair operator()(double score, double deriv, double distance) const override
Smooth the score and its first derivative at a given distance.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
double operator()(double score, double distance) const override
Smooth the score at a given distance.
A shared base class to help in debugging and things.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Base class for smoothing nonbonded interactions as a function of distance.
Smooth interaction scores by switching the derivatives (force switch).