8 #ifndef IMPCORE_DISTANCE_PAIR_SCORE_H
9 #define IMPCORE_DISTANCE_PAIR_SCORE_H
11 #include "core_config.h"
18 IMPCORE_BEGIN_NAMESPACE
29 std::string name=
"DistancePairScore %1%");
44 std::string name=
"HarmonicDistancePairScore %1%");
45 double get_rest_length()
const {
48 double get_stiffness()
const {
58 inline double HarmonicDistancePairScore
59 ::evaluate_index(
Model *m,
60 const ParticleIndexPair &p,
63 IMP_LOG(VERBOSE,
"Evaluating distance between "
64 << m->get_particle(p[0])->get_name()
65 <<
" and " << m->get_particle(p[1])->get_name()
66 <<
" at " << m->get_sphere(p[0])
67 <<
" and " << m->get_sphere(p[1]) << std::endl);
69 - m->get_sphere(p[1]).get_center();
70 static const double MIN_DISTANCE = .00001;
71 double distance2= delta.get_squared_magnitude();
72 double distance=std::sqrt(distance2);
73 double shifted_distance = distance- x0_;
74 double score= .5*k_*square(shifted_distance);
75 if (da && distance > MIN_DISTANCE) {
76 double deriv= k_*shifted_distance;
78 m->add_to_coordinate_derivatives(p[0], uv*deriv, *da);
79 m->add_to_coordinate_derivatives(p[1], -uv*deriv, *da);