00001 /** 00002 * \file atom/VelocityScalingOptimizerState.h 00003 * \brief Maintains temperature during molecular dynamics by velocity scaling. 00004 * 00005 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00006 * 00007 */ 00008 00009 #ifndef IMPATOM_VELOCITY_SCALING_OPTIMIZER_STATE_H 00010 #define IMPATOM_VELOCITY_SCALING_OPTIMIZER_STATE_H 00011 00012 #include "atom_config.h" 00013 #include <IMP/Particle.h> 00014 #include <IMP/base_types.h> 00015 #include <IMP/OptimizerState.h> 00016 00017 IMPATOM_BEGIN_NAMESPACE 00018 00019 //! Maintains temperature during molecular dynamics by velocity scaling. 00020 /** This OptimizerState, when used with the MolecularDynamics optimizer, 00021 implements a simple thermostat by periodically rescaling the velocities. 00022 (Note that this results in discontinuous dynamics.) 00023 \see MolecularDynamics 00024 */ 00025 class IMPATOMEXPORT VelocityScalingOptimizerState : public OptimizerState 00026 { 00027 public: 00028 VelocityScalingOptimizerState(const Particles &pis, Float temperature, 00029 unsigned skip_steps); 00030 00031 //! Set the number of update calls to skip between rescaling. 00032 void set_skip_steps(unsigned skip_steps) { 00033 skip_steps_ = skip_steps; 00034 } 00035 00036 //! Set the particles to use. 00037 void set_particles(const Particles &pis) { 00038 pis_=pis; 00039 } 00040 00041 //! Set the temperature to use. 00042 void set_temperature(Float temperature) { 00043 temperature_ = temperature; 00044 } 00045 00046 //! Rescale the velocities now 00047 void rescale_velocities() const; 00048 00049 IMP_OPTIMIZER_STATE(VelocityScalingOptimizerState); 00050 00051 private: 00052 Particles pis_; 00053 Float temperature_; 00054 unsigned skip_steps_; 00055 unsigned call_number_; 00056 00057 //! Keys of the xyz velocities 00058 FloatKey vs_[3]; 00059 }; 00060 00061 IMPATOM_END_NAMESPACE 00062 00063 #endif /* IMPATOM_VELOCITY_SCALING_OPTIMIZER_STATE_H */