IMP  2.0.0
The Integrative Modeling Platform
BrownianDynamics.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/BrownianDynamics.h
3  * \brief Simple molecular dynamics optimizer.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_BROWNIAN_DYNAMICS_H
10 #define IMPATOM_BROWNIAN_DYNAMICS_H
11 
12 #include <IMP/atom/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.*/
58  BrownianDynamics(Model *m, std::string name = "BrownianDynamics%1%");
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  void advance_chunk(double dtfs, double ikt,
68  const ParticleIndexes &ps,
69  unsigned int begin,
70  unsigned int end);
71  void advance_coordinates_1(ParticleIndex pi,
72  unsigned int i,
73  double dtfs,
74  double ikT);
75  void advance_coordinates_0(ParticleIndex pi, unsigned int i,
76  double dtfs,
77  double ikT);
78  void advance_orientation_0(ParticleIndex pi,
79  double dtfs,
80  double ikT);
81 
82  typedef boost::variate_generator<RandomNumberGenerator&,
83  boost::normal_distribution<double> > RNG;
84  double max_step_;
85  bool srk_;
87 };
88 
89 /** Repeatedly run the current model with brownian dynamics at different time
90  steps to try to find the maximum time step that can be used without
91  the model exploding.
92 */
93 IMPATOMEXPORT double get_maximum_time_step_estimate(BrownianDynamics *bd);
94 
95 #ifndef IMP_DOXYGEN
96 IMPATOMEXPORT double get_harmonic_sigma(double D, double f);
97 #endif
98 IMPATOM_END_NAMESPACE
99 
100 #endif /* IMPATOM_BROWNIAN_DYNAMICS_H */