IMP  2.0.1
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-2013 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.
24 /** \ingroup helper
25  \ingroup decorators
26  \see BrownianDynamics
27  \unstable{Diffusion} The name really should be fixed.
28 
29  D is assumed to be in \f$A^2/fs\f$
30  */
31 class IMPATOMEXPORT Diffusion:
32  public IMP::core::XYZ
33 {
34  public:
36 
37  /** Create a decorator with the passed coordinates and D.
38  */
40  const algebra::Vector3D &v,
41  Float D) {
42  XYZ::setup_particle(p, v);
43  p->add_attribute(get_diffusion_coefficient_key(), D);
44  return Diffusion(p);
45  }
46 
47  /** Create a decorator with the a given D.
48  The particle
49  is assumed to already have x,y,z attributes
50  */
52  Float D) {
53  IMP_USAGE_CHECK(XYZ::particle_is_instance(p),
54  "Particle must already be an XYZ particle");
55  p->add_attribute(get_diffusion_coefficient_key(), D);
56  return Diffusion(p);
57  }
58 
59  /** Create a decorator with the D determined from its
60  radius.
61  */
63 
64  //! Return true if the particle is an instance of an Diffusion
65  static bool particle_is_instance(Particle *p) {
66  return XYZ::particle_is_instance(p)
67  && p->has_attribute(get_diffusion_coefficient_key());
68  }
69 
70  //! Return true if the particle is an instance of an Diffusion
72  return m->get_has_attribute(get_diffusion_coefficient_key(), p);
73  }
74 #ifndef IMP_DOXYGEN
75  void set_d(double d) {
76  set_diffusion_coefficient(d);
77  }
78  double get_d() const {
80  }
81 #endif
82  void set_diffusion_coefficient(double d) {
83  get_particle()->set_value(get_diffusion_coefficient_key(), d);
84  }
85  double get_diffusion_coefficient() const {
86  return get_particle()->get_value(get_diffusion_coefficient_key());
87  }
88  //! Get the D key
89  static FloatKey get_diffusion_coefficient_key();
90 
91 };
92 
93 IMPATOMEXPORT double get_diffusion_coefficient_from_cm2_per_second(double din);
94 
95 IMP_DECORATORS(Diffusion, Diffusions, core::XYZs);
96 
97 
98 
99 
100 
101 
102 
103 /** A rigid body that is diffusing, so it also has a rotation diffusion
104  coefficient. The units on the rotational coefficient are radians^2/fs.*/
105 class IMPATOMEXPORT RigidBodyDiffusion: public Diffusion {
106  public:
108  /** All diffusion coefficients are determined from the radius */
110 
111  double get_rotational_diffusion_coefficient() const {
112  return get_particle()
113  ->get_value(get_rotational_diffusion_coefficient_key());
114  }
115  void set_rotational_diffusion_coefficient(double d) const {
116  return get_particle()
117  ->set_value(get_rotational_diffusion_coefficient_key(), d);
118  }
119 
120  //! Return true if the particle is an instance of an Diffusion
121  static bool particle_is_instance(Particle *p) {
122  return XYZ::particle_is_instance(p)
123  && p->has_attribute(get_rotational_diffusion_coefficient_key());
124  }
125 
126  //! Return true if the particle is an instance of an Diffusion
128  return m->get_has_attribute(get_rotational_diffusion_coefficient_key(), p);
129  }
130 
131  //! Get the D key
132  static FloatKey get_rotational_diffusion_coefficient_key();
133 };
134 
135 
136 IMP_DECORATORS(RigidBodyDiffusion, RigidBodyDiffusions, Diffusions);
137 
138 IMPATOM_END_NAMESPACE
139 
140 #endif /* IMPATOM_DIFFUSION_H */