IMP  2.0.1
The Integrative Modeling Platform
VelocityScalingOptimizerState.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/VelocityScalingOptimizerState.h
3  * \brief Maintains temperature during molecular dynamics by velocity scaling.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_VELOCITY_SCALING_OPTIMIZER_STATE_H
10 #define IMPATOM_VELOCITY_SCALING_OPTIMIZER_STATE_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include <IMP/Particle.h>
14 #include <IMP/base_types.h>
15 #include <IMP/OptimizerState.h>
17 
18 IMPATOM_BEGIN_NAMESPACE
19 
20 //! Maintains temperature during molecular dynamics by velocity scaling.
21 /** This OptimizerState, when used with the MolecularDynamics optimizer,
22  implements a simple thermostat by periodically rescaling the velocities.
23  (Note that this results in discontinuous dynamics.)
24  \see MolecularDynamics
25  */
26 class IMPATOMEXPORT VelocityScalingOptimizerState : public OptimizerState
27 {
28  public:
29  VelocityScalingOptimizerState(const Particles &pis, Float temperature,
30  unsigned skip_steps);
31 
32  //! Set the number of update calls to skip between rescaling.
33  void set_skip_steps(unsigned skip_steps) {
34  skip_steps_ = skip_steps;
35  }
36 
37  //! Set the particles to use.
38  void set_particles(const Particles &pis) {
39  pis_=pis;
40  }
41 
42  //! Set the temperature to use.
43  void set_temperature(Float temperature) {
44  temperature_ = temperature;
45  }
46 
47  //! Rescale the velocities now
48  void rescale_velocities() const;
49 
51 
52 private:
53  Particles pis_;
54  Float temperature_;
55  unsigned skip_steps_;
56  unsigned call_number_;
57 
58  //! Keys of the xyz velocities
59  FloatKey vs_[3];
60 };
61 
63 
64 IMPATOM_END_NAMESPACE
65 
66 #endif /* IMPATOM_VELOCITY_SCALING_OPTIMIZER_STATE_H */