IMP logo
BrownianDynamics.h
Go to the documentation of this file.
1 /**
2  * \file atom/BrownianDynamics.h
3  * \brief Simple molecular dynamics optimizer.
4  *
5  * Copyright 2007-2012 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_BROWNIAN_DYNAMICS_H
10 #define IMPATOM_BROWNIAN_DYNAMICS_H
11 
12 #include "atom_config.h"
13 #include "Diffusion.h"
14 #include "Simulator.h"
15 #include "atom_macros.h"
16 #include <IMP/random.h>
17 #include <IMP/Particle.h>
18 #include <IMP/Optimizer.h>
19 #include <IMP/internal/units.h>
20 #include <IMP/algebra/Vector3D.h>
21 
22 IMPATOM_BEGIN_NAMESPACE
23 
24 // for swig
25 class SimulationParameters;
26 
27 //! Simple Brownian dynamics optimizer.
28 /** The particles to be optimized must have optimizable x,y,z attributes
29  and a non-optimizable "Stokes radius"; this optimizer assumes
30  the score to be energy in kcal/mol, the xyz coordinates to be in
31  angstroms and the diffusion coefficent be in cm^2/s
32 
33  Particles without optimized x,y,z and nonoptimized D are skipped.
34 
35  Rigid bodies are supported.
36 
37  BrownianDynamics uses a SimulationParameters particle to store the
38  parameters of the simulation. Such a particle must be passed on
39  creation. The BrownianDynamics object will at least see updates
40  to the SimulationParamters particle which occur before the
41  call to BrownianDynamics::optimize() or BrownianDynamics::simulate(),
42  changing the the parameters during optimization has undefined
43  results.
44 
45  The optimizer can either automatically determine which particles
46  to use from the model or be passed a SingletonContainer for the
47  particles. If such a container is passed, particles added to it
48  during optimization state updates are handled properly.
49 
50  \see Diffusion
51  */
52 class IMPATOMEXPORT BrownianDynamics : public Simulator
53 {
54 public:
55  //! Create the optimizer
56  /** If sc is not null, that container will be used to find particles
57  to move, otherwise the model will be searched.*/
59  void set_maximum_move(double ms) {
60  max_step_=ms;
61  }
62  void set_use_stochastic_runge_kutta(bool tf) {
63  srk_=tf;
64  }
66  private:
67  typedef unit::Divide<unit::Femtosecond,
68  unit::Femtojoule>::type DTIKT;
69  void advance_ball_1(ParticleIndex pi,
70  unsigned int i,
71  unit::Femtosecond dtfs,
72  DTIKT dtikt);
73  void advance_ball_0(ParticleIndex pi, unsigned int i,
74  unit::Femtosecond dtfs,
75  unit::Divide<unit::Femtosecond,
76  unit::Femtojoule>::type dtikt);
77  void advance_rigid_body_0(ParticleIndex pi, unsigned int i,
78  unit::Femtosecond dtfs,
79  DTIKT dtikt);
80 
81  typedef boost::variate_generator<RandomNumberGenerator&,
82  boost::normal_distribution<double> > RNG;
83  double max_step_;
84  bool srk_;
86 };
87 
88 /** Repeatedly run the current model with brownian dynamics at different time
89  steps to try to find the maximum time step that can be used without
90  the model exploding.
91 */
92 IMPATOMEXPORT double get_maximum_time_step_estimate(BrownianDynamics *bd);
93 
94 #ifndef IMP_DOXYGEN
95 IMPATOMEXPORT double get_harmonic_sigma(double D, double f);
96 #endif
97 IMPATOM_END_NAMESPACE
98 
99 #endif /* IMPATOM_BROWNIAN_DYNAMICS_H */

Generated on Tue May 22 2012 23:33:12 for IMP by doxygen 1.8.1