IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
core/Harmonic.h
Go to the documentation of this file.
1
/**
2
* \file IMP/core/Harmonic.h \brief Harmonic function.
3
*
4
* Copyright 2007-2013 IMP Inventors. All rights reserved.
5
*/
6
7
#ifndef IMPCORE_HARMONIC_H
8
#define IMPCORE_HARMONIC_H
9
10
#include <IMP/core/core_config.h>
11
#include <
IMP/UnaryFunction.h
>
12
#include <
IMP/unary_function_macros.h
>
13
#include <
IMP/utility.h
>
14
15
IMPCORE_BEGIN_NAMESPACE
16
17
//! %Harmonic function (symmetric about the mean)
18
/** This is a simple score modeling an harmonic oscillator. The score is
19
0.5 * k * x * x, where k is the 'force constant' and x is the distance
20
from the mean.
21
\see TruncatedHarmonic
22
\see HarmonicUpperBound
23
\see HarmonicLowerBound
24
*/
25
class
Harmonic
:
public
UnaryFunction
26
{
27
public
:
28
/** Create with the given mean and the spring constant k */
29
Harmonic
(
Float
mean,
Float
k) : mean_(mean), k_(k) {}
30
31
virtual
DerivativePair
evaluate_with_derivative
(
double
feature)
const
{
32
return
DerivativePair
(0.5 * k_ * square(feature-mean_),
33
k_*(feature - mean_));
34
}
35
36
virtual
double
evaluate
(
double
feature)
const
{
37
return
0.5 * k_ * square(feature-mean_);
38
}
39
40
IMP_OBJECT_METHODS
(
Harmonic
);
41
42
//! \return the mean of this function
43
Float
get_mean
()
const
{
44
return
mean_;
45
}
46
47
//! \return the spring constant
48
Float
get_k
()
const
{
49
return
k_;
50
}
51
52
//! Set the mean of this function
53
void
set_mean
(
Float
mean) {
54
mean_ = mean;
55
}
56
57
//! Set the spring constant
58
void
set_k
(
Float
k) {
59
k_ = k;
60
}
61
62
63
//! Return the k to use for a given Gaussian standard deviation.
64
/** Given the standard deviation of a Gaussian distribution, get
65
the force constant of the harmonic score function that yields that
66
same distribution. For temperature in Kelvin, this assumes the score
67
function is energy in kcal/mol, and thus returns a force constant in
68
kcal/mol/A/A.
69
\param[in] sd Gaussian standard deviation, in angstroms
70
\param[in] t System temperature, in Kelvin
71
\return Force constant
72
*/
73
static
Float
get_k_from_standard_deviation
(
Float
sd,
Float
t=297.15) {
74
// Gas constant in kcal/mol K
75
const
static
Float
R = 8.31441 / 4186.8;
76
return
R * t / square(sd);
77
}
78
79
private
:
80
Float
mean_;
81
Float
k_;
82
};
83
84
IMPCORE_END_NAMESPACE
85
86
#endif
/* IMPCORE_HARMONIC_H */