IMP logo
IMP Reference Guide  2.5.0
The Integrative Modeling Platform
TAMDCentroid.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/TAMDCentroid.h
3  * \brief A decorator for a particle that is a centroid of TAMD simulations.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_TAMD_CENTROID_H
10 #define IMPATOM_TAMD_CENTROID_H
11 
12 #include <IMP/atom/atom_config.h>
13 
14 #include <IMP/Decorator.h>
15 #include <IMP/core/XYZ.h>
17 #include <IMP/atom/Diffusion.h>
18 #include <IMP/internal/constants.h>
19 
20 #include <vector>
21 #include <limits>
22 
23 IMPATOM_BEGIN_NAMESPACE
24 
25 //! A decorator for a center of mass particle that is part of a TAMD
26 //! simulation (so simulators can recognize it as such)
27 /** \ingroup helper
28  \ingroup decorators
29  \see BrownianDynamicsBarak
30 
31  TAMDCentroid is almost identical to IMP::core::Centroid, used to
32  decorate particles that represet centers of mass of their children.
33  It also contains some flags that are useful for TAMD simulations
34  (Temperature-Accelerated MD).
35 
36  \see IMP::core::Centroid
37  */
38 class IMPATOMEXPORT TAMDCentroid : public IMP::core::Centroid {
39  /** Sets up TAMDCentroid over particles in pis */
40  static void do_setup_particle(Model *m, ParticleIndex pi,
41  const ParticleIndexes &pis) {
42  Centroid::setup_particle(m, pi, pis);
43  m->add_attribute(get_is_tamd_centroid_key(), pi, true);
44  }
45 
46  /** Sets up TAMDCentroid over particles passed by applying the refiner
47  over the particle pi
48  */
49  static void do_setup_particle(Model *m, ParticleIndex pi,
50  Refiner *ref) {
51  Centroid::setup_particle(m, pi, ref);
52  m->add_attribute(get_is_tamd_centroid_key(), pi, true);
53  }
54 
55  public:
57 
58  /** Sets up TAMDCentroid over members, and constrains TAMDCentroid to be
59  computed before model evaluation and to propogate derivatives
60  folllowing model evaulation.
61  SetupDoc
62  */
64 
65  /** Sets up TAMDCentroid over particles passed by applying the refiner
66  over the particle pi, and constrains TAMDCentroid to be computed before
67  model evaluation and to propogate derivatives following model
68  evaluation.
69  SetupDoc
70  */
72 
73  static bool get_is_setup(Model *m, ParticleIndex pi) {
74  return m->get_has_attribute(get_is_tamd_centroid_key(), pi);
75  }
76 
77  private:
78  /** Returns whether this tamd centroid is marked as such. */
79  bool get_is_tamd_centroid() const {
80  return static_cast<bool>
81  ( get_model()->get_attribute( get_is_tamd_centroid_key(),
82  get_particle_index() ) );
83  }
84 
85  void set_is_tamd_centroid(bool t) {
86  get_model()->set_attribute( get_is_tamd_centroid_key(),
88  static_cast<Int>(t) );
89  }
90 
91  //! Get the is_tamd_centroid key
92  static IntKey get_is_tamd_centroid_key();
93 
94 };
95 
96 IMP_DECORATORS(TAMDCentroid, TAMDCentroids, IMP::core::Centroid);
97 
98 IMPATOM_END_NAMESPACE
99 
100 #endif /* IMPATOM_TAMD_CENTROID_H */
The base class for decorators.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:186
A decorator for a diffusing particle.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:189
A particle that is the geometric centroid of other particles.
Simple XYZ decorator.
static Centroid setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor members)
Key< 1, true > IntKey
The type used to identify int attributes in the Particles.
Definition: base_types.h:36
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
#define IMP_DECORATOR_METHODS(Name, Parent)
Abstract class to implement hierarchical methods.
Definition: Refiner.h:34
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
Set the coordinates of the particle to be the centroid of the refined particles.