IMP  2.1.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/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 optimizer.
27 /** The particles to be optimized must have optimizable x,y,z attributes
28  and a non-optimizable "Stokes radius"; this optimizer assumes
29  the score to be energy in kcal/mol, the xyz coordinates to be in
30  angstroms and the diffusion coefficent be in cm^2/s
31 
32  kernel::Particles without optimized x,y,z and nonoptimized D are skipped.
33 
34  Rigid bodies are supported.
35 
36  BrownianDynamics uses a SimulationParameters particle to store the
37  parameters of the simulation. Such a particle must be passed on
38  creation. The BrownianDynamics object will at least see updates
39  to the SimulationParamters particle which occur before the
40  call to BrownianDynamics::optimize() or BrownianDynamics::simulate(),
41  changing the the parameters during optimization has undefined
42  results.
43 
44  The optimizer can either automatically determine which particles
45  to use from the model or be passed a SingletonContainer for the
46  particles. If such a container is passed, particles added to it
47  during optimization state updates are handled properly.
48 
49  \see Diffusion
50  */
51 class IMPATOMEXPORT BrownianDynamics : public Simulator {
52  public:
53  //! Create the optimizer
54  /** If sc is not null, that container will be used to find particles
55  to move, otherwise the model will be searched.
56  @param m model associated with bd
57  @param name name of bd object
58  @param wave_factor for wave step function, see Simulator object,
59  if >1.001 or so, creates a wave of time steps
60  that are larger by up to wave_factor from
61  formal maximal time step
62 
63  @note wave_factor is an advanced feature - if you're not sure, just use
64  its default, see also Simulator::simulate_wave()
65  */
66  BrownianDynamics(kernel::Model *m, std::string name = "BrownianDynamics%1%",
67  double wave_factor = 1.0);
68  void set_maximum_move(double ms) { max_step_ = ms; }
69  void set_use_stochastic_runge_kutta(bool tf) { srk_ = tf; }
70 
72 
73  private:
74  virtual void setup(const kernel::ParticleIndexes &ps) IMP_OVERRIDE;
75  virtual double do_step(const kernel::ParticleIndexes &sc,
76  double dt) IMP_OVERRIDE;
78  IMP_OVERRIDE;
79 
80  private:
81  void advance_chunk(double dtfs, double ikt, const kernel::ParticleIndexes &ps,
82  unsigned int begin, unsigned int end);
83  void advance_coordinates_1(kernel::ParticleIndex pi, unsigned int i,
84  double dtfs, double ikT);
85  void advance_coordinates_0(kernel::ParticleIndex pi, unsigned int i,
86  double dtfs, double ikT);
87  void advance_orientation_0(kernel::ParticleIndex pi, double dtfs, double ikT);
88 
89  double max_step_;
90  bool srk_;
92 };
93 
94 /** Repeatedly run the current model with brownian dynamics at different time
95  steps to try to find the maximum time step that can be used without
96  the model exploding.
97 */
98 IMPATOMEXPORT double get_maximum_time_step_estimate(BrownianDynamics *bd);
99 
100 #ifndef IMP_DOXYGEN
101 IMPATOMEXPORT double get_harmonic_sigma(double D, double f);
102 #endif
103 IMPATOM_END_NAMESPACE
104 
105 #endif /* IMPATOM_BROWNIAN_DYNAMICS_H */
The base class for simulators.
Definition: Simulator.h:34
A decorator for a diffusing particle.
Import IMP/kernel/Optimizer.h in the namespace.
Simple Brownian dynamics optimizer.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Simple molecular dynamics optimizer.
Classes to handle individual model particles.
virtual bool get_is_simulation_particle(kernel::ParticleIndex p) const =0
Various important macros for implementing decorators.
virtual void setup(const kernel::ParticleIndexes &)
Definition: Simulator.h:141
Simple 3D vector class.
virtual double do_step(const kernel::ParticleIndexes &sc, double dt)=0
double get_maximum_time_step_estimate(BrownianDynamics *bd)
Class for storing model, its restraints, constraints, and particles.