IMP logo
IMP Reference Guide  2.19.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  *
8  * Copyright 2007-2022 IMP Inventors. All rights reserved.
9  */
10 
11 #ifndef IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H
12 #define IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H
13 
14 #include <IMP/score_functor/score_functor_config.h>
15 #include "Score.h"
16 #include <IMP/algebra/utility.h>
17 #include <cereal/access.hpp>
18 
19 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
20 
21 /** A harmonic score on the negative directed distance between
22  a pair of particles. The score equals zero for
23  non-negative directed distances.
24 */
25 class HarmonicLowerBound : public Score {
26  double k_;
27 
28  friend class cereal::access;
29  template<class Archive> void serialize(Archive &ar) {
30  ar(k_);
31  }
32 
33  public:
34  HarmonicLowerBound(double k) : k_(k) {}
36  template <unsigned int D>
37  double get_score(Model *,
39  double distance) const {
40  if (distance > 0) return 0;
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) return DerivativePair(0, 0);
48  return DerivativePair(get_score(m, p, distance), k_ * (distance));
49  }
50  template <unsigned int D>
51  double get_maximum_range(
52  Model *, const Array<D, ParticleIndex> &) const {
53  return 0;
54  }
55  template <unsigned int D>
56  bool get_is_trivially_zero(Model *,
58  double squared_distance) const {
59  return squared_distance > 0;
60  }
61 };
62 
63 IMPSCOREFUNCTOR_END_NAMESPACE
64 
65 #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