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,
96 unsigned int upper_bound)
const override;
102 double max,
unsigned int lower_bound,
103 unsigned int upper_bound)
const override
106 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
108 if (ret > max)
return std::numeric_limits<double>::max();
129 LinearSoftSpherePairScore::evaluate_index
138 s0.get_center() - s1.get_center();
139 double delta_length_2 =
140 delta.get_squared_magnitude();
142 s0.get_radius() + s1.get_radius();
143 double x0_2 = x0 * x0;
144 bool not_penetrating = delta_length_2 > x0_2;
145 if (not_penetrating)
return 0;
147 double delta_length = std::sqrt(delta_length_2);
149 delta, delta_length, x0, -k_);
155 LinearSoftSpherePairScore::evaluate_index
164 m->access_sphere_derivatives_data();
167 return evaluate_index(s0, s1, ds0, ds1, da);
173 LinearSoftSpherePairScore::evaluate_indexes
176 DerivativeAccumulator *da,
177 unsigned int lower_bound,
178 unsigned int upper_bound )
const
182 m->access_spheres_data();
184 m->access_sphere_derivatives_data();
186 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
189 ret += evaluate_index( xyzrs[i0], xyzrs[i1],
190 d_xyzrs[i0], d_xyzrs[i1],
212 double particles_delta_squared;
214 double sum_particles_radii;
254 std::string name =
"LinearIDPairScore%1%");
281 unsigned int lower_bound,
282 unsigned int upper_bound)
const override;
286 unsigned int lower_bound,
287 unsigned int upper_bound)
const {
289 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
291 if (ret > max)
return std::numeric_limits<double>::max();
326 LinearInteractionPairScore::evaluate_index
334 double &delta_length_2 = cache_.particles_delta_squared;
335 double &x0 = cache_.sum_particles_radii;
337 s0.get_center() - s1.get_center();
338 delta_length_2 = delta.get_squared_magnitude();
340 "LinearInteractionPairScore cached delta2 "
341 << cache_.particles_delta_squared << std::endl);
342 x0 = s0.get_radius() + s1.get_radius();
345 if (delta_length_2 > std::pow(x0 + range_attr_, 2))
return 0;
346 double offset = -range_attr_ * k_attr_;
347 double delta_length = std::sqrt(delta_length_2);
348 if (delta_length > x0) {
351 delta, delta_length, x0, k_attr_) +
355 delta, delta_length, x0, -k_rep_) +
361 LinearInteractionPairScore::evaluate_index
363 const ParticleIndexPair &pp,
364 DerivativeAccumulator *da)
const
370 m->access_sphere_derivatives_data();
373 return evaluate_index(s0, s1, ds0, ds1, da);
377 LinearInteractionPairScore::evaluate_indexes
380 DerivativeAccumulator *da,
381 unsigned int lower_bound,
382 unsigned int upper_bound)
const
386 m->access_spheres_data();
388 m->access_sphere_derivatives_data();
390 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
393 ret += evaluate_index( xyzrs[i0], xyzrs[i1],
394 d_xyzrs[i0], d_xyzrs[i1],
409 double rest_length_factor_, k_;
423 std::string name =
"LinearIDPairScore%1%");
425 void set_rest_length_factor(
double rest_length_factor)
426 { rest_length_factor_ = rest_length_factor; }
427 double get_rest_length_factor()
const {
return rest_length_factor_; }
430 double get_k() {
return k_; }
442 LinearWellPairScore::evaluate_index
451 m->access_sphere_derivatives_data();
454 double x0 = (s0.get_radius() + s1.get_radius()) * rest_length_factor_;
456 double delta_length_2 = delta.get_squared_magnitude();
457 double delta_length = std::sqrt(delta_length_2);
458 if (delta_length > x0) {
461 delta, delta_length, x0, k_);
465 delta, delta_length, x0, -k_);
473 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.
Class for adding derivatives from restraints to the model.
double get_k() const
returns the k for sphere-sphere repulsion