IMP  2.3.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-2014 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/kernel/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  kernel::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  public:
36  /** Score based on the provided model */
38 
39  //! Return the current kinetic energy of the system, in kcal/mol
40  virtual Float get_kinetic_energy() const;
41 
42  //! Return the current kinetic temperature of the system
43  /** \param[in] ekinetic kinetic energy, e.g. from get_kinetic_energy()
44  */
45  Float get_kinetic_temperature(Float ekinetic) const;
46 
47  //! Set maximum velocity in A/fs
48  /** At each dynamics time step, the absolute value of each velocity
49  component is capped at this value. This prevents spurious strong forces
50  (occasionally encountered with frustrated conformations) from causing
51  large oscillations in the system.
52  By default, velocities are not capped.
53 
54  \note The actual velocities that are capped are the half-step velocities
55  in the velocity Verlet algorithm.
56  */
57  void set_velocity_cap(Float velocity_cap) { velocity_cap_ = velocity_cap; }
58 
59  //! Assign velocities representative of the given temperature
60  virtual void assign_velocities(Float temperature);
61  virtual void setup(const kernel::ParticleIndexes &ps) IMP_OVERRIDE;
62  virtual double do_step(const kernel::ParticleIndexes &sc,
63  double dt) IMP_OVERRIDE;
66 
68 
69  protected:
70  void initialize();
71 
72  virtual void setup_degrees_of_freedom(const kernel::ParticleIndexes &ps);
73 
74  //! First part of velocity Verlet (update coordinates and half-step velocity)
75  virtual void propagate_coordinates(const kernel::ParticleIndexes &ps,
76  double step_size);
77 
78  //! Second part of velocity Verlet (update velocity)
79  virtual void propagate_velocities(const kernel::ParticleIndexes &ps,
80  double step_size);
81 
82  //! Cap a velocity component to the maximum value.
83  inline void cap_velocity_component(Float &vel) {
84  if (vel >= 0.0) {
85  vel = std::min(vel, velocity_cap_);
86  } else {
87  vel = std::max(vel, -velocity_cap_);
88  }
89  }
90 
91  //! Keys of the xyz velocities
92  FloatKey vs_[3];
93 
94  //! Number of degrees of freedom in the system
96 
97  //! Maximum absolute value of a single velocity component
99 };
100 
101 IMPATOM_END_NAMESPACE
102 
103 #endif /* IMPATOM_MOLECULAR_DYNAMICS_H */
The base class for simulators.
Definition: Simulator.h:34
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Import IMP/kernel/Optimizer.h in the namespace.
void set_velocity_cap(Float velocity_cap)
Set maximum velocity in A/fs.
Simple molecular dynamics optimizer.
int degrees_of_freedom_
Number of degrees of freedom in the system.
Simple molecular dynamics optimizer.
Classes to handle individual model particles. (Note that implementation of inline functions in in int...
virtual bool get_is_simulation_particle(kernel::ParticleIndex p) const =0
Return true if the passed particle is appropriate for the simulation.
void cap_velocity_component(Float &vel)
Cap a velocity component to the maximum value.
Various important macros for implementing decorators.
Float velocity_cap_
Maximum absolute value of a single velocity component.
virtual void setup(const kernel::ParticleIndexes &)
Definition: Simulator.h:157
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
virtual double do_step(const kernel::ParticleIndexes &sc, double dt)=0
Perform a single time step.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73