00001 /** 00002 * \file atom/MolecularDynamics.h 00003 * \brief Simple molecular dynamics optimizer. 00004 * 00005 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00006 * 00007 */ 00008 00009 #ifndef IMPATOM_MOLECULAR_DYNAMICS_H 00010 #define IMPATOM_MOLECULAR_DYNAMICS_H 00011 00012 #include "atom_config.h" 00013 00014 #include <IMP/Particle.h> 00015 #include <IMP/Optimizer.h> 00016 00017 IMPATOM_BEGIN_NAMESPACE 00018 00019 //! Simple molecular dynamics optimizer. 00020 /** The particles to be optimized must have optimizable x,y,z attributes 00021 and a non-optimizable mass attribute; this optimizer assumes the score 00022 to be energy in kcal/mol, the xyz coordinates to be in angstroms, and 00023 the mass to be in AMU (g/mol). 00024 00025 Particles without optimized x,y,z and nonoptimized mass are skipped. 00026 \see VelocityScalingOptimizerState 00027 */ 00028 class IMPATOMEXPORT MolecularDynamics : public Optimizer 00029 { 00030 public: 00031 /** */ 00032 MolecularDynamics(); 00033 00034 //! \return the current kinetic energy of the system, in kcal/mol 00035 Float get_kinetic_energy() const; 00036 00037 //! \return the current kinetic temperature of the system 00038 /** \param[in] ekinetic kinetic energy, e.g. from get_kinetic_energy() 00039 */ 00040 Float get_kinetic_temperature(Float ekinetic) const; 00041 00042 IMP_OPTIMIZER(MolecularDynamics); 00043 00044 //! Set time step in fs 00045 void set_time_step(Float t) { time_step_ = t; } 00046 00047 //! Set maximum velocity in A/fs 00048 /** At each dynamics time step, the absolute value of each velocity 00049 component is capped at this value. This prevents spurious strong forces 00050 (occasionally encountered with frustrated conformations) from causing 00051 large oscillations in the system. 00052 */ 00053 void set_velocity_cap(Float velocity_cap) { velocity_cap_ = velocity_cap; } 00054 00055 //! Assign velocities representative of the given temperature 00056 void assign_velocities(Float temperature); 00057 00058 IMP_LIST(private, Particle, particle, Particle*, Particles); 00059 00060 private: 00061 //! Perform a single dynamics step. 00062 virtual void step(); 00063 00064 //! Get the set of particles to use in this optimization. 00065 /** Scans for particles which have the necessary attributes to be 00066 optimized. Particles without optimized x,y,z and nonoptimized 00067 mass are skipped. 00068 */ 00069 void setup_particles(); 00070 00071 //! Cap a velocity component to the maximum value. 00072 inline void cap_velocity_component(Float &vel) { 00073 if (vel >= 0.0) { 00074 vel = std::min(vel, velocity_cap_); 00075 } else { 00076 vel = std::max(vel, -velocity_cap_); 00077 } 00078 } 00079 00080 //! Time step in fs 00081 Float time_step_; 00082 00083 //! Keys of the xyz coordinates 00084 FloatKey cs_[3]; 00085 00086 //! Key of the mass attribute 00087 FloatKey masskey_; 00088 00089 //! Keys of the xyz velocities 00090 FloatKey vs_[3]; 00091 00092 //! Number of degrees of freedom in the system 00093 int degrees_of_freedom_; 00094 00095 //! Maximum absolute value of a single velocity component 00096 Float velocity_cap_; 00097 }; 00098 00099 IMPATOM_END_NAMESPACE 00100 00101 #endif /* IMPATOM_MOLECULAR_DYNAMICS_H */