IMP logo
IMP Reference Guide  2.19.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-2022 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 #include <cereal/access.hpp>
17 
18 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
19 
20 /** A harmonic score on the positive directed distance between
21  a pair of particles. The score equals zero for
22  non-positive directed distances.
23 */
24 class HarmonicUpperBound : public Score {
25  double k_;
26 
27  friend class cereal::access;
28  template<class Archive> void serialize(Archive &ar) {
29  ar(k_);
30  }
31  public:
32  HarmonicUpperBound(double k) : k_(k) {}
34  template <unsigned int D>
35  double get_score(Model *,
37  double distance) const {
38  if (distance < 0)
39  return 0;
40  else
41  return .5 * k_ * algebra::get_squared(distance);
42  }
43  template <unsigned int D>
44  DerivativePair get_score_and_derivative(
45  Model *m, const Array<D, ParticleIndex> &p,
46  double distance) const {
47  if (distance < 0)
48  return DerivativePair(0, 0);
49  else
50  return DerivativePair(get_score(m, p, distance), k_ * (distance));
51  }
52 };
53 
54 IMPSCOREFUNCTOR_END_NAMESPACE
55 
56 #endif /* IMPSCORE_FUNCTOR_HARMONIC_UPPER_BOUND_H */
A class to store a fixed array of same-typed values.
Definition: Array.h:35
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
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:22
A functor for computing a distance based score for D particles.
Definition: Score.h:20