IMP logo
IMP Reference Guide  2.7.0
The Integrative Modeling Platform
score_functor/HarmonicUpperBound.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/HarmonicUpperBound.h
3  * \brief A harmonic score on the positive directed distance between
4  * a pair of particles. The score equals zero for
5  * non-positive directed distances.
6  *
7  * Copyright 2007-2017 IMP Inventors. All rights reserved.
8  */
9 
10 #ifndef IMPSCORE_FUNCTOR_HARMONIC_UPPER_BOUND_H
11 #define IMPSCORE_FUNCTOR_HARMONIC_UPPER_BOUND_H
12 
13 #include <IMP/score_functor/score_functor_config.h>
14 #include "Score.h"
15 #include <IMP/algebra/utility.h>
16 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
17 
18 /** A harmonic score on the positive directed distance between
19  a pair of particles. The score equals zero for
20  non-positive directed distances.
21 */
22 class HarmonicUpperBound : public Score {
23  double k_;
24 
25  public:
26  HarmonicUpperBound(double k) : k_(k) {}
27  template <unsigned int D>
28  double get_score(Model *,
30  double distance) const {
31  if (distance < 0)
32  return 0;
33  else
34  return .5 * k_ * algebra::get_squared(distance);
35  }
36  template <unsigned int D>
37  DerivativePair get_score_and_derivative(
38  Model *m, const Array<D, ParticleIndex> &p,
39  double distance) const {
40  if (distance < 0)
41  return DerivativePair(0, 0);
42  else
43  return DerivativePair(get_score(m, p, distance), k_ * (distance));
44  }
45 };
46 
47 IMPSCOREFUNCTOR_END_NAMESPACE
48 
49 #endif /* IMPSCORE_FUNCTOR_HARMONIC_UPPER_BOUND_H */
A class to store an fixed array of same-typed values.
Definition: Array.h:33
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Functions to deal with very common math operations.
A Score on the distance between a pair of particles.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:23
A functor for computing a distance based score for two particles.
Definition: Score.h:20