IMP  2.0.1
The Integrative Modeling Platform
atom/MolecularDynamics.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/MolecularDynamics.h
3  * \brief Simple molecular dynamics optimizer.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_MOLECULAR_DYNAMICS_H
10 #define IMPATOM_MOLECULAR_DYNAMICS_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include "Simulator.h"
14 #include "atom_macros.h"
15 #include <IMP/Particle.h>
16 #include <IMP/Optimizer.h>
17 
18 IMPATOM_BEGIN_NAMESPACE
19 
20 //! Simple molecular dynamics optimizer.
21 /** The particles to be optimized must have optimizable x,y,z attributes
22  and a non-optimizable mass attribute; this optimizer assumes the score
23  to be energy in kcal/mol, the xyz coordinates to be in angstroms, and
24  the mass to be in AMU (g/mol).
25 
26  \note RigidBody particles are not handled properly.
27 
28  Particles without optimized x,y,z and nonoptimized mass are skipped.
29  \see VelocityScalingOptimizerState
30  \see LangevinThermostatOptimizerState
31  \see BerendsenThermostatOptimizerState
32  \see RemoveRigidMotionOptimizerState
33  */
34 class IMPATOMEXPORT MolecularDynamics : public Simulator
35 {
36 public:
37  /** Score based on the provided model */
38  MolecularDynamics(Model *m=nullptr);
39 
40  //! \return the current kinetic energy of the system, in kcal/mol
41  virtual Float get_kinetic_energy() const;
42 
43  //! \return the current kinetic temperature of the system
44  /** \param[in] ekinetic kinetic energy, e.g. from get_kinetic_energy()
45  */
46  Float get_kinetic_temperature(Float ekinetic) const;
47 
48  //! Set maximum velocity in A/fs
49  /** At each dynamics time step, the absolute value of each velocity
50  component is capped at this value. This prevents spurious strong forces
51  (occasionally encountered with frustrated conformations) from causing
52  large oscillations in the system.
53  By default, velocities are not capped.
54 
55  \note The actual velocities that are capped are the half-step velocities
56  in the velocity Verlet algorithm.
57  */
58  void set_velocity_cap(Float velocity_cap) { velocity_cap_ = velocity_cap; }
59 
60  //! Assign velocities representative of the given temperature
61  virtual void assign_velocities(Float temperature);
63 protected:
64  void initialize();
65 
66  virtual void setup_degrees_of_freedom(const ParticleIndexes &ps);
67 
68  //! First part of velocity Verlet (update coordinates and half-step velocity)
69  virtual void propagate_coordinates(const ParticleIndexes &ps, double
70  step_size);
71 
72  //! Second part of velocity Verlet (update velocity)
73  virtual void propagate_velocities(const ParticleIndexes &ps, double
74  step_size);
75 
76  //! Cap a velocity component to the maximum value.
77  inline void cap_velocity_component(Float &vel) {
78  if (vel >= 0.0) {
79  vel = std::min(vel, velocity_cap_);
80  } else {
81  vel = std::max(vel, -velocity_cap_);
82  }
83  }
84 
85  //! Keys of the xyz velocities
86  FloatKey vs_[3];
87 
88  //! Number of degrees of freedom in the system
90 
91  //! Maximum absolute value of a single velocity component
93 };
94 
95 IMPATOM_END_NAMESPACE
96 
97 #endif /* IMPATOM_MOLECULAR_DYNAMICS_H */