8 #ifndef IMPNPCTRANSPORT_LINEAR_DISTANCE_PAIR_SCORES_H
9 #define IMPNPCTRANSPORT_LINEAR_DISTANCE_PAIR_SCORES_H
11 #include "npctransport_config.h"
16 #include "internal/sites.h"
18 #include <boost/array.hpp>
20 IMPNPCTRANSPORT_BEGIN_NAMESPACE
45 double delta_length,
double x0,
double k) {
46 double shifted_length = delta_length - x0;
47 double score = k * shifted_length;
48 static const double MIN_DISTANCE = .00001;
49 if (da && delta_length > MIN_DISTANCE) {
51 Model::add_to_coordinate_derivatives(d_xyzr0, deriv, *da);
52 Model::add_to_coordinate_derivatives(d_xyzr1, -deriv, *da);
53 IMP_LOG(
TERSE,
"Distance: " << shifted_length <<
"\nscore: " << score
54 <<
"\nderiv: " << deriv << std::endl);
57 IMP_LOG(
TERSE,
"Distance: " << shifted_length <<
"\nscore: " << score
87 std::string name =
"LinearSSPairScore%1%");
95 unsigned int lower_bound,
102 double max,
unsigned int lower_bound,
unsigned int upper_bound)
const
105 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
107 if (ret > max)
return std::numeric_limits<double>::max();
128 LinearSoftSpherePairScore::evaluate_index
137 s0.get_center() - s1.get_center();
138 double delta_length_2 =
139 delta.get_squared_magnitude();
141 s0.get_radius() + s1.get_radius();
142 double x0_2 = x0 * x0;
143 bool not_penetrating = delta_length_2 > x0_2;
144 if (not_penetrating)
return 0;
146 double delta_length = std::sqrt(delta_length_2);
148 delta, delta_length, x0, -k_);
154 LinearSoftSpherePairScore::evaluate_index
163 m->access_sphere_derivatives_data();
166 return evaluate_index(s0, s1, ds0, ds1, da);
172 LinearSoftSpherePairScore::evaluate_indexes
175 DerivativeAccumulator *da,
176 unsigned int lower_bound,
177 unsigned int upper_bound )
const
181 m->access_spheres_data();
183 m->access_sphere_derivatives_data();
185 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
188 ret += evaluate_index( xyzrs[i0], xyzrs[i1],
189 d_xyzrs[i0], d_xyzrs[i1],
211 double particles_delta_squared;
213 double sum_particles_radii;
253 std::string name =
"LinearIDPairScore%1%");
280 unsigned int lower_bound,
285 unsigned int lower_bound,
286 unsigned int upper_bound)
const {
288 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
290 if (ret > max)
return std::numeric_limits<double>::max();
325 LinearInteractionPairScore::evaluate_index
333 double &delta_length_2 = cache_.particles_delta_squared;
334 double &x0 = cache_.sum_particles_radii;
336 s0.get_center() - s1.get_center();
337 delta_length_2 = delta.get_squared_magnitude();
339 "LinearInteractionPairScore cached delta2 "
340 << cache_.particles_delta_squared << std::endl);
341 x0 = s0.get_radius() + s1.get_radius();
344 if (delta_length_2 > std::pow(x0 + range_attr_, 2))
return 0;
345 double offset = -range_attr_ * k_attr_;
346 double delta_length = std::sqrt(delta_length_2);
347 if (delta_length > x0) {
350 delta, delta_length, x0, k_attr_) +
354 delta, delta_length, x0, -k_rep_) +
360 LinearInteractionPairScore::evaluate_index
362 const ParticleIndexPair &pp,
363 DerivativeAccumulator *da)
const
369 m->access_sphere_derivatives_data();
372 return evaluate_index(s0, s1, ds0, ds1, da);
376 LinearInteractionPairScore::evaluate_indexes
379 DerivativeAccumulator *da,
380 unsigned int lower_bound,
381 unsigned int upper_bound)
const
385 m->access_spheres_data();
387 m->access_sphere_derivatives_data();
389 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
392 ret += evaluate_index( xyzrs[i0], xyzrs[i1],
393 d_xyzrs[i0], d_xyzrs[i1],
408 double rest_length_factor_, k_;
422 std::string name =
"LinearIDPairScore%1%");
424 void set_rest_length_factor(
double rest_length_factor)
425 { rest_length_factor_ = rest_length_factor; }
426 double get_rest_length_factor()
const {
return rest_length_factor_; }
429 double get_k() {
return k_; }
440 LinearWellPairScore::evaluate_index
449 m->access_sphere_derivatives_data();
452 double x0 = (s0.get_radius() + s1.get_radius()) * rest_length_factor_;
454 double delta_length_2 = delta.get_squared_magnitude();
455 double delta_length = std::sqrt(delta_length_2);
456 if (delta_length > x0) {
459 delta, delta_length, x0, k_);
463 delta, delta_length, x0, -k_);
471 IMPNPCTRANSPORT_END_NAMESPACE
#define IMP_IMPLEMENT_INLINE(signature, body)
void set_k_attraction(double k_attr)
set k for sphere-sphere attraction in kcal/mol/A units
Abstract class for scoring object(s) of type ParticleIndexPair.
SphereD< 3 > Sphere3D
Typedef for Python.
virtual double evaluate_if_good_indexes(Model *m, const ParticleIndexPairs &o, DerivativeAccumulator *da, double max, unsigned int lower_bound, unsigned int upper_bound) const
double get_range_attraction() const
returns the range for sphere-sphere attraction in A
Macros for various classes.
#define IMP_PAIR_SCORE_METHODS(Name)
IMP::Vector< ParticleIndexPair > ParticleIndexPairs
#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.
double get_k_attraction() const
returns the k for sphere-sphere attraction in kcal/mol/A units
#define IMP_IMPLEMENT(signature)
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Class for storing model, its restraints, constraints, and particles.
Functions to deal with very common math operations.
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
#define IMP_UNUSED(variable)
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
#define IMP_CHECK_CODE(expr)
Only compile the code if checks are enabled.
virtual double evaluate_indexes(Model *m, const ParticleIndexPairs &o, DerivativeAccumulator *da, unsigned int lower_bound, unsigned int upper_bound) const
Compute the score and the derivative if needed over a set.
void set_k_repulsion(double k_rep)
set k for sphere-sphere repulsion in kcal/mol/A units
Output a line or two per evaluation call.
virtual double evaluate_if_good_index(Model *m, const ParticleIndexPair &vt, DerivativeAccumulator *da, double max) const
Compute the score and the derivative if needed, only if "good".
Decorator for a sphere-like particle.
double do_evaluate_index(algebra::Sphere3D &d_xyzr0, algebra::Sphere3D &d_xyzr1, DerivativeAccumulator *da, const algebra::Vector3D &delta, double delta_length, double x0, double k)
double get_k_repulsion() const
returns the k for sphere-sphere repulsion in kcal/mol/A units
virtual double evaluate_index(Model *m, const ParticleIndexPair &vt, DerivativeAccumulator *da) const =0
Compute the score and the derivative if needed.
#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.
double get_k() const
returns the k for sphere-sphere repulsion