IMP logo
IMP Reference Guide  2.6.1
The Integrative Modeling Platform
TAMDParticle.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/TAMDParticle.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_TAMD_PARTICLE_H
10 #define IMPATOM_TAMD_PARTICLE_H
11 
12 #include <IMP/atom/atom_config.h>
13 
14 #include <IMP/Decorator.h>
15 #include <IMP/core/XYZ.h>
16 #include <IMP/atom/Diffusion.h>
17 #include <IMP/internal/constants.h>
18 
19 #include <vector>
20 #include <limits>
21 
22 IMPATOM_BEGIN_NAMESPACE
23 
24 //! A decorator for a diffusing particle that is simulated in a TAMD
25 //! BD simulation.
26 /** \ingroup helper
27  \ingroup decorators
28  \see BrownianDynamicsBarak
29 
30  TAMDParticle is used to decorate diffusing particle that are
31  simulated as part of a TAMD simulation (Temperature-Accelerated
32  MD), and exhibit elevated temperature and elevated friction
33  coefficient (=actual diffusion coefficient reduced during TAMD BD
34  simulation).
35 
36  See: Maragliano and Vanden-Eijden, 2006;
37  Abrams and Vanden-Eijden, PNAS 2011
38  */
39 class IMPATOMEXPORT TAMDParticle : public IMP::Decorator {
40  private:
41  /**
42  Setup a TAMD particle with simulation temperature multiplied by a factor
43  tsf, and friction coefficient multiplied by a factor fsf
44  */
45  static void do_setup_particle(Model *m, ParticleIndex pi,
46  ParticleIndex pi_ref,
47  float tsf=1.0,
48  float fsf=1.0);
49 
50  // just an adaptor for the particle index variety of p_ref
51  static void do_setup_particle(Model *m, ParticleIndex pi,
52  Particle* p_ref,
53  float tsf=1.0,
54  float fsf=1.0) {
55  IMP_USAGE_CHECK(m == p_ref->get_model(),
56  "reference particle must be of same model");
57  do_setup_particle(m, pi, p_ref->get_index(), tsf, fsf);
58  }
59 
60 
61  public:
63 
64  /**
65  setup a TAMD variable associated with pi_ref, with temperature scaled by tsf
66  and friction scaled by fsf.
67 
68  @note Particle is assumed to be decorated as diffusive, XYZ particle.
69 
70  @param m the particle model
71  @param pi the particle index to be setup
72  @param pi_ref - reference particle index in same model with which
73  this tamd particle is associate
74  @param tsf - temperature scale factor
75  @param fsf - friction scale factor
76  */
78  ParticleIndex, pi_ref,
79  Float, tsf,
80  Float, fsf);
81 
82  /**
83  setup a TAMD variable associated with pi_ref, with temperature scaled by tsf
84  and friction scaled by fsf
85 
86  @note Particle is assumed to be decorated as diffusive, XYZ particle.
87 
88  @param m the particle model
89  @param pi the particle index to be setup
90  @param p_ref - reference particle with which this tamd particle is associate
91  @param tsf - temperature scale factor
92  @param fsf - friction scale factor
93  */
95  Particle*, p_ref,
96  Float, tsf,
97  Float, fsf);
98 
99 
100 
101  //! Return true if the particle is an instance of an TAMDParticle
102  static bool get_is_setup(Model *m, ParticleIndex p) {
103  return
104  m->get_has_attribute(get_reference_particle_index_key(), p) &&
105  m->get_has_attribute(get_temperature_scale_factor_key(), p) &&
106  m->get_has_attribute(get_friction_scale_factor_key(), p);
107  }
108 
109  /** returns the particle associated with this TAMD variable
110  (eg, centroid of some particles)
111  */
113  return get_model()->get_attribute(get_reference_particle_index_key(),
115  }
116 
117  //! set temperature factoring for particle relative to simulation
118  //! temperature
120  get_particle()->set_value(get_temperature_scale_factor_key(), tsf);
121  }
122 
123  //! get temperature factoring for particle relative to simulation
124  //! temperature
126  return get_model()->get_attribute(get_temperature_scale_factor_key(),
128  }
129 
130  //! set friction factoring for particle relative to particle
131  //! diffusion coefficient / rotational diffusion coefficient
132  void set_friction_scale_factor(float tsf) {
133  get_particle()->set_value(get_friction_scale_factor_key(), tsf);
134  }
135 
136  //! get friction factoring for particle relative to particle
137  //! diffusion coefficient / rotational diffusion coefficient
138  double get_friction_scale_factor() const {
139  return get_model()->get_attribute(get_friction_scale_factor_key(),
141  }
142 
143  /**
144  copy x,y,z coordinates from reference particle.
145 
146  @note Assumes both this particle and the reference particle
147  are decorated by XYZ (no runtime check is made in release
148  mode!)
149 
150  */
151  void update_coordinates_from_ref();
152 
153  //! Get the temperature scale factor key
154  static FloatKey get_temperature_scale_factor_key();
155 
156  //! Get the temperature scale factor key
157  static FloatKey get_friction_scale_factor_key();
158 
159  //! Get the temperature scale factor key
160  static ParticleIndexKey get_reference_particle_index_key();
161 
162 
163 };
164 
165 IMP_DECORATORS(TAMDParticle, TAMDParticles, articlesTemp);
166 
167 IMPATOM_END_NAMESPACE
168 
169 #endif /* IMPATOM_TAMD_PARTICLE_H */
static bool get_is_setup(Model *m, ParticleIndex p)
Return true if the particle is an instance of an TAMDParticle.
Definition: TAMDParticle.h:102
The base class for decorators.
double get_temperature_scale_factor() const
Definition: TAMDParticle.h:125
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:188
A decorator for a diffusing particle.
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:191
void set_friction_scale_factor(float tsf)
Definition: TAMDParticle.h:132
ParticleIndex get_reference_particle_index() const
Definition: TAMDParticle.h:112
void set_temperature_scale_factor(float tsf)
Definition: TAMDParticle.h:119
Simple XYZ decorator.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
double get_friction_scale_factor() const
Definition: TAMDParticle.h:138
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:171
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:118
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Class to handle individual model particles.
Definition: Particle.h:37
#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.
ParticleIndex get_index() const
returns the particle index of this particle in its model
#define IMP_DECORATOR_SETUP_3(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name)
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)