IMP  2.1.0
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/kernel/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 : public IMP::core::XYZ {
32  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
33  Float D) {
34  IMP_USAGE_CHECK(XYZ::get_is_setup(m, pi),
35  "Particle must already be an XYZ particle");
36  m->add_attribute(get_diffusion_coefficient_key(), pi, D);
37  }
38  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
39  const algebra::Vector3D &v, Float D) {
40  XYZ::setup_particle(m, pi, v);
41  do_setup_particle(m, pi, D);
42  }
43  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi);
44 
45  public:
49  /** Assume particle is already a core::XYZR particle. */
51 
52  //! Return true if the particle is an instance of an Diffusion
54  return m->get_has_attribute(get_diffusion_coefficient_key(), p);
55  }
56  void set_diffusion_coefficient(double d) {
57  get_particle()->set_value(get_diffusion_coefficient_key(), d);
58  }
59  double get_diffusion_coefficient() const {
60  return get_particle()->get_value(get_diffusion_coefficient_key());
61  }
62  //! Get the D key
63  static FloatKey get_diffusion_coefficient_key();
64 
65  /** \deprecated_at{2.1} Use set_diffusion_coefficient(). */
66  IMPATOM_DEPRECATED_METHOD_DECL(2.1)
67  void set_d(double d);
68  /** \deprecated_at{2.1} Use get_diffusion_coefficient(). */
69  IMPATOM_DEPRECATED_METHOD_DECL(2.1)
70  double get_d() const;
71 };
72 
73 IMPATOMEXPORT double get_diffusion_coefficient_from_cm2_per_second(double din);
74 
75 IMP_DECORATORS(Diffusion, Diffusions, core::XYZs);
76 
77 /** A rigid body that is diffusing, so it also has a rotation diffusion
78  coefficient. The units on the rotational coefficient are
79  \f$radians^2/fs\f$.*/
80 class IMPATOMEXPORT RigidBodyDiffusion : public Diffusion {
81  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi);
82 
83  public:
85  /** All diffusion coefficients are determined from the radius */
87 
89  return get_particle()->get_value(
90  get_rotational_diffusion_coefficient_key());
91  }
92  void set_rotational_diffusion_coefficient(double d) const {
93  return get_particle()->set_value(get_rotational_diffusion_coefficient_key(),
94  d);
95  }
96 
97  //! Return true if the particle is an instance of an Diffusion
99  return m->get_has_attribute(get_rotational_diffusion_coefficient_key(), p);
100  }
101 
102  //! Get the D key
103  static FloatKey get_rotational_diffusion_coefficient_key();
104 };
105 
106 IMP_DECORATORS(RigidBodyDiffusion, RigidBodyDiffusions, Diffusions);
107 
108 IMPATOM_END_NAMESPACE
109 
110 #endif /* IMPATOM_DIFFUSION_H */
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name)
Particle * get_particle() const
#define IMP_DECORATOR_METHODS(Name, Parent)
static XYZ setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZ.h:53
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
Return true if the particle is an instance of an Diffusion.
Definition: Diffusion.h:98
double get_rotational_diffusion_coefficient(const algebra::Rotation3Ds &displacements, double dt)
#define IMP_DECORATOR_SETUP_0(Name)
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:32
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
Simple 3D vector class.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
Return true if the particle is an instance of an Diffusion.
Definition: Diffusion.h:53
double get_diffusion_coefficient(const algebra::Vector3Ds &displacements, double dt)
A decorator for a diffusing particle.
Definition: Diffusion.h:31
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Decorator for a sphere-like particle.
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
Class for storing model, its restraints, constraints, and particles.