IMP  2.3.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-2014 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/kernel/Particle.h>
17 #include <IMP/Optimizer.h>
18 #include <IMP/kernel/internal/units.h>
19 #include <IMP/algebra/Vector3D.h>
20 
21 IMPATOM_BEGIN_NAMESPACE
22 
23 // for swig
24 class SimulationParameters;
25 
26 //! Simple Brownian dynamics simulator.
27 /** This is an implementation of a Brownian Dynamics simulator.
28 
29  _Input particles and score_
30 
31  Each optimized particle must have x,y,z attributes
32  that are optimizable. In addition, each optimized particle must be
33  decorated with the Diffusion decorator. Optionally, the
34  RigidBodyDiffusion decorator can be used to specify a rotational
35  diffusion coefficient for core::RigidBody particles. The
36  optimizer assumes the scoring function to be energy in kcal/mol, and the xyz
37  coordinates to be in angstroms and the diffusion coefficient of
38  each particle be in \f$A^2/fs\f$ (or \f$Radian^2/fs\f$ for rotational
39  diffusion coefficient). kernel::Particles without optimized x,y,z
40  and nonoptimized D are skipped.
41 
42  The optimizer can either automatically determine which particles
43  to use from the model or be passed a SingletonContainer for the
44  particles. If such a container is passed, particles added to it
45  during optimization state updates are handled properly.
46 
47  _Simulation_
48 
49  At each simulation time step, each particle is translated in the
50  direction of the sum of a random diffusion vector and the gradient
51  of the scoring function (force field) at the particle
52  coordinates. The translation is proportional to the particle
53  diffusion coefficient, the time step size, and the inverse of kT.
54  Note that particles masses are not considered, only their
55  diffusion coefficients.
56 
57  Similarly, rigid bodies are rotated by the sum of a random torque and a
58  force field torque, proportionally to the rotational diffusion
59  coefficient, the time step size, and inversely proportional kT.
60 
61  If the skt (stochastic Runge Kutta) flag is true, the simulation is
62  altered slightly to apply the SKT scheme.
63 
64  \see Diffusion
65  \see RigidBodyDiffusion
66  */
67 class IMPATOMEXPORT BrownianDynamics : public Simulator {
68  public:
69  //! Create the optimizer
70  /** If sc is not null, that container will be used to find particles
71  to move, otherwise the model will be searched.
72  @param m model associated with bd
73  @param name name of bd object
74  @param wave_factor for wave step function, see Simulator object,
75  if >1.001 or so, creates a wave of time steps
76  that are larger by up to wave_factor from
77  formal maximal time step
78 
79  @note wave_factor is an advanced feature - if you're not sure, just use
80  its default, see also Simulator::simulate_wave()
81  */
82  BrownianDynamics(kernel::Model *m, std::string name = "BrownianDynamics%1%",
83  double wave_factor = 1.0);
84  void set_maximum_move(double ms) { max_step_ = ms; }
85  void set_use_stochastic_runge_kutta(bool tf) { srk_ = tf; }
86 
88 
89  private:
90  virtual void setup(const kernel::ParticleIndexes &ps) IMP_OVERRIDE;
91  virtual double do_step(const kernel::ParticleIndexes &sc,
92  double dt) IMP_OVERRIDE;
95 
96  private:
97  void advance_chunk(double dtfs, double ikt, const kernel::ParticleIndexes &ps,
98  unsigned int begin, unsigned int end);
99  void advance_coordinates_1(kernel::ParticleIndex pi, unsigned int i,
100  double dtfs, double ikT);
101  void advance_coordinates_0(kernel::ParticleIndex pi, unsigned int i,
102  double dtfs, double ikT);
103  void advance_orientation_0(kernel::ParticleIndex pi, double dtfs, double ikT);
104 
105  double max_step_;
106  bool srk_;
108 };
109 
110 /** Repeatedly run the current model with Brownian dynamics at different time
111  steps to try to find the maximum time step that can be used without
112  the model exploding.
113 */
114 IMPATOMEXPORT double get_maximum_time_step_estimate(BrownianDynamics *bd);
115 
116 #ifndef IMP_DOXYGEN
117 IMPATOMEXPORT double get_harmonic_sigma(double D, double f);
118 #endif
119 IMPATOM_END_NAMESPACE
120 
121 #endif /* IMPATOM_BROWNIAN_DYNAMICS_H */
The base class for simulators.
Definition: Simulator.h:34
A decorator for a diffusing particle.
#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.
Simple Brownian dynamics simulator.
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.
Various important macros for implementing decorators.
virtual void setup(const kernel::ParticleIndexes &)
Definition: Simulator.h:157
Simple 3D vector class.
virtual double do_step(const kernel::ParticleIndexes &sc, double dt)=0
Perform a single time step.
double get_maximum_time_step_estimate(BrownianDynamics *bd)
#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