IMP logo
IMP Reference Guide  2.6.2
The Integrative Modeling Platform
Diffusion.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Diffusion.h
3  * \brief A decorator for a diffusing particle.
4  *
5  * Copyright 2007-2016 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_DIFFUSION_H
10 #define IMPATOM_DIFFUSION_H
11 
12 #include <IMP/atom/atom_config.h>
13 
14 #include <IMP/core/XYZR.h>
15 #include <IMP/algebra/Vector3D.h>
16 #include <IMP/internal/constants.h>
17 
18 #include <vector>
19 #include <limits>
20 
21 IMPATOM_BEGIN_NAMESPACE
22 
23 //! A decorator for a diffusing particle with a diffusion coefficient.
24 /** \ingroup helper
25  \ingroup decorators
26  \see BrownianDynamics
27  \unstable{Diffusion} The name really should be fixed.
28 
29  Diffusion is used to decorate diffusing particle with a diffusion
30  coefficient D. D is assumed to be in units of \f$A^2/fs\f$.
31 
32  \see RigidBodyDiffusion
33  */
34 class IMPATOMEXPORT Diffusion : public IMP::core::XYZ {
35  static void do_setup_particle(Model *m, ParticleIndex pi,
36  Float D) {
37  IMP_USAGE_CHECK(XYZ::get_is_setup(m, pi),
38  "Particle must already be an XYZ particle");
39  m->add_attribute(get_diffusion_coefficient_key(), pi, D);
40  }
41  static void do_setup_particle(Model *m, ParticleIndex pi,
42  const algebra::Vector3D &v, Float D) {
43  XYZ::setup_particle(m, pi, v);
44  do_setup_particle(m, pi, D);
45  }
46  static void do_setup_particle(Model *m, ParticleIndex pi);
47 
48  public:
52  /** Assume particle is already a core::XYZR particle. */
54 
55  //! Return true if the particle is an instance of an Diffusion
56  static bool get_is_setup(Model *m, ParticleIndex p) {
57  return m->get_has_attribute(get_diffusion_coefficient_key(), p);
58  }
59  void set_diffusion_coefficient(double d) {
60  get_particle()->set_value(get_diffusion_coefficient_key(), d);
61  }
62  double get_diffusion_coefficient() const {
63  return get_model()->get_attribute(get_diffusion_coefficient_key(),
65  }
66  //! Get the D key
67  static FloatKey get_diffusion_coefficient_key();
68 };
69 
70 IMPATOMEXPORT double get_diffusion_coefficient_from_cm2_per_second(double din);
71 
72 IMP_DECORATORS(Diffusion, Diffusions, core::XYZs);
73 
74 /** A rigid body that is diffusing, so it also has a rotation diffusion
75  coefficient. The units on the rotational coefficient are
76  \f$radians^2/fs\f$.*/
77 class IMPATOMEXPORT RigidBodyDiffusion : public Diffusion {
78  static void do_setup_particle(Model *m, ParticleIndex pi);
79 
80  public:
82  /** All diffusion coefficients are determined from the radius */
84 
86  return get_model()->get_attribute
87  (get_rotational_diffusion_coefficient_key(),
89  }
90  void set_rotational_diffusion_coefficient(double d) const {
91  return get_particle()->set_value(get_rotational_diffusion_coefficient_key(),
92  d);
93  }
94 
95  //! Return true if the particle is an instance of an Diffusion
96  static bool get_is_setup(Model *m, ParticleIndex p) {
97  return m->get_has_attribute(get_rotational_diffusion_coefficient_key(), p);
98  }
99 
100  //! Get the D key
101  static FloatKey get_rotational_diffusion_coefficient_key();
102 };
103 
104 IMP_DECORATORS(RigidBodyDiffusion, RigidBodyDiffusions, Diffusions);
105 
106 IMPATOM_END_NAMESPACE
107 
108 #endif /* IMPATOM_DIFFUSION_H */
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:188
static bool get_is_setup(Model *m, ParticleIndex p)
Return true if the particle is an instance of an Diffusion.
Definition: Diffusion.h:96
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:191
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition: XYZ.h:51
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
double get_rotational_diffusion_coefficient(const algebra::Rotation3Ds &displacements, double dt)
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name)
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
Definition: base_types.h:32
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
#define IMP_DECORATOR_SETUP_0(Name)
static bool get_is_setup(Model *m, ParticleIndex p)
Return true if the particle is an instance of an Diffusion.
Definition: Diffusion.h:56
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:171
#define IMP_DECORATOR_METHODS(Name, Parent)
VectorD< 3 > Vector3D
Definition: VectorD.h:395
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Simple 3D vector class.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
double get_diffusion_coefficient(const algebra::Vector3Ds &displacements, double dt)
A decorator for a diffusing particle with a diffusion coefficient.
Definition: Diffusion.h:34
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
Decorator for a sphere-like particle.