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,
 
   97                       bool all_indexes_checked=
false) 
const override;
 
  103       double max, 
unsigned int lower_bound,
 
  104       unsigned int upper_bound, 
bool all_indexes_checked=
false) 
const override 
  108     for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
 
  110       if (ret > max) 
return std::numeric_limits<double>::max();
 
  131 LinearSoftSpherePairScore::evaluate_index
 
  140       s0.get_center() - s1.get_center();
 
  141   double delta_length_2 =
 
  142       delta.get_squared_magnitude();  
 
  144       s0.get_radius() + s1.get_radius();
 
  145   double x0_2 = x0 * x0;
 
  146   bool not_penetrating = delta_length_2 > x0_2;
 
  147   if (not_penetrating) 
return 0;
 
  149   double delta_length = std::sqrt(delta_length_2);
 
  151                            delta, delta_length, x0, -k_);
 
  157 LinearSoftSpherePairScore::evaluate_index
 
  166     m->access_sphere_derivatives_data();
 
  169   return evaluate_index(s0, s1, ds0, ds1,  da);
 
  175 LinearSoftSpherePairScore::evaluate_indexes
 
  178   DerivativeAccumulator *da,
 
  179   unsigned int lower_bound,
 
  180   unsigned int upper_bound, 
bool)
 const 
  184       m->access_spheres_data();
 
  186     m->access_sphere_derivatives_data();
 
  188   for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
 
  191     ret += evaluate_index( xyzrs[i0], xyzrs[i1],
 
  192                            d_xyzrs[i0], d_xyzrs[i1],
 
  214     double particles_delta_squared;
 
  216     double sum_particles_radii;
 
  256                              std::string name = 
"LinearIDPairScore%1%");
 
  283                          unsigned int lower_bound,
 
  284                          unsigned int upper_bound,
 
  285                          bool all_indexes_checked=
false) 
const override;
 
  289                                 unsigned int lower_bound,
 
  290                                 unsigned int upper_bound)
 const {
 
  292     for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
 
  294       if (ret > max) 
return std::numeric_limits<double>::max();
 
  329 LinearInteractionPairScore::evaluate_index
 
  337   double &delta_length_2 = cache_.particles_delta_squared;
 
  338   double &x0 = cache_.sum_particles_radii;
 
  340       s0.get_center() - s1.get_center();
 
  341   delta_length_2 = delta.get_squared_magnitude();
 
  343           "LinearInteractionPairScore cached delta2 " 
  344           << cache_.particles_delta_squared << std::endl);
 
  345   x0 = s0.get_radius() + s1.get_radius();
 
  348   if (delta_length_2 > std::pow(x0 + range_attr_, 2)) 
return 0;
 
  349   double offset = -range_attr_ * k_attr_;
 
  350   double delta_length = std::sqrt(delta_length_2);
 
  351   if (delta_length > x0) {  
 
  354                          delta, delta_length, x0, k_attr_) +
 
  358                               delta, delta_length, x0, -k_rep_) +
 
  364 LinearInteractionPairScore::evaluate_index
 
  366   const ParticleIndexPair &pp,
 
  367   DerivativeAccumulator *da)
 const 
  373     m->access_sphere_derivatives_data();
 
  376   return evaluate_index(s0, s1, ds0, ds1, da);
 
  380 LinearInteractionPairScore::evaluate_indexes
 
  383   DerivativeAccumulator *da,
 
  384   unsigned int lower_bound,
 
  385   unsigned int upper_bound, 
bool)
 const 
  389       m->access_spheres_data();
 
  391     m->access_sphere_derivatives_data();
 
  393   for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
 
  396     ret += evaluate_index( xyzrs[i0], xyzrs[i1],
 
  397                            d_xyzrs[i0], d_xyzrs[i1],
 
  412   double rest_length_factor_, k_;
 
  426                       std::string name = 
"LinearIDPairScore%1%");
 
  428   void set_rest_length_factor(
double rest_length_factor)
 
  429   { rest_length_factor_ = rest_length_factor; }
 
  430   double get_rest_length_factor()
 const { 
return rest_length_factor_; }
 
  433   double get_k() { 
return k_; }
 
  445 LinearWellPairScore::evaluate_index
 
  454     m->access_sphere_derivatives_data();
 
  457   double x0 = (s0.get_radius() + s1.get_radius()) * rest_length_factor_;
 
  459   double delta_length_2 = delta.get_squared_magnitude();
 
  460   double delta_length = std::sqrt(delta_length_2);
 
  461   if (delta_length > x0) {  
 
  464                         delta, delta_length, x0, k_);
 
  468                         delta, delta_length, x0, -k_);
 
  476 IMPNPCTRANSPORT_END_NAMESPACE
 
IMP::Vector< ParticleIndexPair, std::allocator< ParticleIndexPair > > ParticleIndexPairs
 
#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. 
 
double get_range_attraction() const 
returns the range for sphere-sphere attraction in A 
 
Macros for various classes. 
 
#define IMP_PAIR_SCORE_METHODS(Name)
 
#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. 
 
virtual double evaluate_if_good_indexes(Model *m, const ParticleIndexPairs &o, DerivativeAccumulator *da, double max, unsigned int lower_bound, unsigned int upper_bound, bool all_indexes_checked=false) const 
 
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, bool all_indexes_checked=false) 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