8 #ifndef IMPNPCTRANSPORT_HARMONIC_SPRING_SINGLETON_SCORE_H
9 #define IMPNPCTRANSPORT_HARMONIC_SPRING_SINGLETON_SCORE_H
11 #include "npctransport_config.h"
19 #include <boost/array.hpp>
21 IMPNPCTRANSPORT_BEGIN_NAMESPACE
54 std::string name =
"HarmonicSpringSingletonScore%1%");
94 HarmonicSpringSingletonScore
101 "particle 0 is expected to be string in HarmonicSpringSingletonScore");
107 double rest_delta_length= s.get_rest_length();
109 double delta_length_2 = delta_1_to_0.get_squared_magnitude();
110 double delta_length = std::sqrt(delta_length_2);
111 double dDelta = delta_length - rest_delta_length;
112 double scoreDelta = 2 * 0.5 * k1_ * dDelta * dDelta;
113 double eq_rest_length= s.get_equilibrium_rest_length_factor()
114 * (s0.get_radius() + s1.get_radius());
115 double dEq= rest_delta_length - eq_rest_length;
116 double scoreEq = 0.5 * k2_ * dEq * dEq;
117 bool is_tiny_rest_length= (rest_delta_length<0.1*eq_rest_length && rest_delta_length<1.0);
118 if(IMP_UNLIKELY(is_tiny_rest_length)) {
119 double threshold=std::min(0.1*eq_rest_length, 1.0);
120 double dThreshold= threshold-rest_delta_length;
121 dEq+= std::pow(10.0 * k2_ * dThreshold / threshold, 4);
123 double score= scoreDelta + scoreEq;
124 IMP_LOG(
TERSE,
"dDelta: " << dDelta <<
" scoreDelta: " << scoreDelta
125 <<
" dEq: " << dEq <<
" scoreEq: " << scoreEq
126 <<
" total: " << score);
129 static const double MIN_DISTANCE = .00001;
130 if (IMP_LIKELY( da && delta_length > MIN_DISTANCE )) {
131 double fParticles= k1_*dDelta;
132 double fSpring= k2_*dEq - 2*fParticles;
133 if(IMP_UNLIKELY(is_tiny_rest_length)) {
134 double threshold=std::min(0.1*eq_rest_length, 1.0);
135 double dThreshold= threshold-rest_delta_length;
136 dEq+= 40 * k2_ * std::pow(10.0 * k2_ * dThreshold / threshold, 3);
138 s.add_to_rest_length_derivative(fSpring, *da);
140 m->add_to_coordinate_derivatives(pi0, deriv0, *da);
141 m->add_to_coordinate_derivatives(pi1, -deriv0, *da);
142 IMP_LOG(
TERSE,
"\nderiv on pi0: " << deriv0);
143 IMP_LOG(
TERSE,
"\nderiv on spring: " << -fSpring);
145 IMP_LOG(
TERSE, std::endl);
155 IMPNPCTRANSPORT_END_NAMESPACE
a spring between two diffusing particles whose resting length is relaxing towards some equilibrium va...
Macros for various classes.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
#define IMP_OBJECT_LOG
Set the log level to the object's log level.
A more IMP-like version of the std::vector.
Class for storing model, its restraints, constraints, and particles.
Functions to deal with very common math operations.
Abstract class for scoring object(s) of type ParticleIndex.
#define IMP_SINGLETON_SCORE_METHODS(Name)
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
A decorator for a spring particle connecting two diffusing particles.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
virtual double evaluate_index(Model *m, ParticleIndex vt, DerivativeAccumulator *da) const =0
Compute the score and the derivative if needed.
Various compiler workarounds.
Decorator for a sphere-like particle.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.