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;
75 double min_distance_, max_distance_;
76 double value_prefactor_, deriv_prefactor_;
78 inline double get_value(
double distance)
const {
79 if (distance <= min_distance_) {
81 }
else if (distance > max_distance_) {
84 double d = max_distance_ - distance;
85 return value_prefactor_ * d * d *
86 (max_distance_ + 2.0 * distance - 3.0 * min_distance_);
90 inline double get_deriv(
double distance)
const {
91 if (distance <= min_distance_ || distance > max_distance_) {
94 return deriv_prefactor_ * (max_distance_ - distance) *
95 (min_distance_ - distance);
100 ForceSwitch(
double min_distance,
double max_distance)
101 : min_distance_(min_distance), max_distance_(max_distance) {
103 "max_distance should be greater than min_distance");
104 double dist_dif = max_distance - min_distance;
105 value_prefactor_ = 1.0 / (dist_dif * dist_dif * dist_dif);
106 deriv_prefactor_ = 6.0 * value_prefactor_;
110 double factor = get_value(distance);
111 return score * factor;
115 double factor = get_value(distance);
116 double deriv_factor = get_deriv(distance);
117 return std::make_pair(score * factor,
118 score * deriv_factor + deriv * factor);
124 IMPATOM_END_NAMESPACE
Various general useful macros for IMP.
Import IMP/kernel/base_types.h in the namespace.
#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.
double operator()(double score, double distance) const
Smooth the score at a given distance.
Common base class for heavy weight IMP objects.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
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).
DerivativePair operator()(double score, double deriv, double distance) const
Smooth the score and its first derivative at a given distance.