IMP logo
IMP Reference Guide  develop.4390929e3e,2024/11/11
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-2022 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 represent 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 propagate derivatives
60  following model evaluation.
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 propagate 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:211
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:214
A particle that is the geometric centroid of other particles.
Simple XYZ decorator.
static Centroid setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor members)
Take Decorator, Particle or ParticleIndex.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle attribute with the specified key and initial value
Key< 1 > IntKey
The type used to identify int attributes in the Particles.
Definition: base_types.h:36
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
set the value of particle attribute with the specified key
#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.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
get the value of the particle attribute with the specified key
Set the coordinates of the particle to be the centroid of the refined particles.