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>
21IMPNPCTRANSPORT_BEGIN_NAMESPACE
29:
public SingletonScore
54 std::string name =
"HarmonicSpringSingletonScore%1%");
94HarmonicSpringSingletonScore
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);
139 algebra::Vector3D deriv0( delta_1_to_0 * (fParticles / delta_length) );
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);
155IMPNPCTRANSPORT_END_NAMESPACE
a spring between two diffusing particles whose resting length is relaxing towards some equilibrium va...
Decorator for a sphere-like particle.
Functions to deal with very common math operations.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Class for adding derivatives from restraints to the model.
Class for storing model, its restraints, constraints, and particles.
HarmonicSpringSingletonScore(double k1, double k2, std::string name="HarmonicSpringSingletonScore%1%")
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the inputs.
virtual double evaluate_index(Model *m, ParticleIndex pi, DerivativeAccumulator *da) const override
Compute the score and the derivative if needed.
A decorator for a spring particle connecting two diffusing particles.
Various compiler workarounds.
#define IMP_OBJECT_LOG
Set the log level to the object's log level.
SphereD< 3 > Sphere3D
Typedef for Python.
IMP::Vector< IMP::Pointer< HarmonicSpringSingletonScore > > HarmonicSpringSingletonScores
Index< ParticleIndexTag > ParticleIndex
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
@ TERSE
Output a line or two per evaluation call.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Macros for various classes.
#define IMP_SINGLETON_SCORE_METHODS(Name)