IMP  2.0.0
The Integrative Modeling Platform
BerendsenThermostatOptimizerState.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/BerendsenThermostatOptimizerState.h
3  * \brief Maintains temperature during molecular dynamics using a
4  * Berendsen thermostat.
5  *
6  * Copyright 2007-2013 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPATOM_BERENDSEN_THERMOSTAT_OPTIMIZER_STATE_H
11 #define IMPATOM_BERENDSEN_THERMOSTAT_OPTIMIZER_STATE_H
12 
13 #include <IMP/atom/atom_config.h>
14 #include <IMP/Particle.h>
15 #include <IMP/base_types.h>
16 #include <IMP/OptimizerState.h>
18 
19 IMPATOM_BEGIN_NAMESPACE
20 
21 //! Maintains temperature during molecular dynamics.
22 /** The thermostat scales velocities using the algorithm described
23  in H. J. C. Berendsen, J. P. M. Postma,
24  W. F. van Gunsteren, A. DiNola, and J. R. Haak "Molecular dynamics
25  with coupling to an external bath", Journal of Chemical Physics 81
26  pp. 3684-3690 (1984).
27 
28  At each update, velocities are rescaled by \f[
29  \lambda = \left[1 + \frac{\Delta t}{\tau_T}
30  \left( \frac{T}{T_k} -1\right)\right]^{1/2}
31  \f]
32  where \f$\Delta t\f$ is the molecular dynamics timestep, \f$\tau_T\f$
33  is the coupling constant (in fs) of the thermostat, \f$T\f$ is the
34  thermostat temperature, and \f$T_k\f$ is the instantaneous (kinetic)
35  temperature of the dynamics. (This is equation 11 from the reference above.)
36  */
38 {
39  public:
40  BerendsenThermostatOptimizerState(const Particles &pis,
41  double temperature,
42  double tau);
43 
44 
45  //! Set the particles to use.
46  void set_particles(const Particles &pis) {
47  pis_=pis;
48  }
49 
50  double get_temperature() {
51  return temperature_;
52  }
53 
54  double get_tau() {
55  return tau_;
56  }
57 
58  void set_temperature(double temperature) {
59  temperature_ = temperature;
60  }
61 
62  void set_tau(double tau) {
63  tau_ = tau;
64  }
65 
66  //! Rescale the velocities now
67  void rescale_velocities() const;
68 
69  IMP_OPTIMIZER_STATE(BerendsenThermostatOptimizerState);
70 
71 private:
72  Particles pis_;
73  double temperature_;
74  double tau_;
75 
76  //! Keys of the xyz velocities
77  FloatKey vs_[3];
78 };
79 
80 IMP_OBJECTS(BerendsenThermostatOptimizerState,
82 
83 IMPATOM_END_NAMESPACE
84 
85 #endif /* IMPATOM_BERENDSEN_THERMOSTAT_OPTIMIZER_STATE_H */