IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
score_functor/HarmonicLowerBound.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/HarmonicLowerBound.h
3  * \brief A harmonic score on the negative directed distance between
4  * a pair of particles. The score equals zero for
5  * non-negative directed distances.
6  *
7  * Copyright 2007-2022 IMP Inventors. All rights reserved.
8  */
9 
10 #ifndef IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H
11 #define IMPSCORE_FUNCTOR_HARMONIC_LOWER_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 negative directed distance between
21  a pair of particles. The score equals zero for
22  non-negative directed distances.
23 */
24 class HarmonicLowerBound : public Score {
25  double k_;
26 
27  friend class cereal::access;
28  template<class Archive> void serialize(Archive &ar) {
29  ar(k_);
30  }
31 
32  public:
33  HarmonicLowerBound(double k) : k_(k) {}
35  template <unsigned int D>
36  double get_score(Model *,
38  double distance) const {
39  if (distance > 0) return 0;
40  return .5 * k_ * algebra::get_squared(distance);
41  }
42  template <unsigned int D>
43  DerivativePair get_score_and_derivative(
44  Model *m, const Array<D, ParticleIndex> &p,
45  double distance) const {
46  if (distance > 0) return DerivativePair(0, 0);
47  return DerivativePair(get_score(m, p, distance), k_ * (distance));
48  }
49  template <unsigned int D>
50  double get_maximum_range(
51  Model *, const Array<D, ParticleIndex> &) const {
52  return 0;
53  }
54  template <unsigned int D>
55  bool get_is_trivially_zero(Model *,
57  double squared_distance) const {
58  return squared_distance > 0;
59  }
60 };
61 
62 IMPSCOREFUNCTOR_END_NAMESPACE
63 
64 #endif /* IMPSCORE_FUNCTOR_HARMONIC_LOWER_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