IMP logo
IMP Reference Guide  2.13.0
The Integrative Modeling Platform
RelaxingSpring.h
Go to the documentation of this file.
1 /**
2  * \file IMP/npctransport/RelaxingSpring.h
3  * \brief a spring between two diffusing particles whose resting length
4  * is relaxing towards some equilibrium value
5  *
6  * Copyright 2007-2020 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPNPCTRANSPORT_RELAXING_SPRING_H
11 #define IMPNPCTRANSPORT_RELAXING_SPRING_H
12 
13 #include "npctransport_config.h"
14 #include <IMP/Decorator.h>
15 #include <IMP/decorator_macros.h>
16 #include <IMP/Particle.h>
17 
18 IMPNPCTRANSPORT_BEGIN_NAMESPACE
19 
20 //! A decorator for a spring particle connecting two diffusing particles
21 /** \ingroup helper
22  \ingroup decorators
23  */
24 
25 class IMPNPCTRANSPORTEXPORT
27 {
28  /** Decorate a spring particle that connects two particles
29  in no particular order, with a dynamic rest length
30  that may relax towards some equilibrium value
31 
32  @param m the model
33  @param pi the particle index
34  @param bonded_pi0 particle on first side of spring
35  @param bonded_pi1 particle on second side of spring
36  @param equilibrium_rest_length_factor the rest length factor of the spring at equilibrium (relative to sum of the radii of the bonded particles)
37  @param rest_length_diffusion_coefficient the diffusion coefficient for the rest length
38  */
39  static void do_setup_particle(IMP::Model* m,
40  ParticleIndex pi,
41  ParticleIndex bonded_pi0,
42  ParticleIndex bonded_pi1,
43  double equilibrium_rest_length_factor,
44  double rest_length_diffusion_coefficient);
45 
46 
47  public:
49 
50 
51  /** Decorate a spring particle that connects two particles
52  in no particular order, with a dynamic rest length
53  that may relax towards some equilibrium value
54 
55  @param m the model
56  @param pi the particle index
57  @param bonded_pi0 particle on first side of spring
58  @param bonded_pi1 particle on second side of spring
59  @param equilibrium_rest_length_factor the rest length factor of the spring at equilibrium (relative to sum of the radii of the bonded particles)
60  @param rest_length_diffusion_coefficient the diffusion
61  coefficient for the rest length
62  */
64  ParticleIndex, bonded_pi0,
65  ParticleIndex, bonded_pi1,
66  double, equilibrium_rest_length_factor,
67  double, rest_length_diffusion_coefficient);
68 
69  //! Return true if the particle is an instance of an Transporting
70  static bool get_is_setup(Model *m, ParticleIndex pi) {
71  return
72  m->get_has_attribute(get_equilibrium_rest_length_factor_key(), pi)
73  && m->get_has_attribute(get_rest_length_key(), pi);
74  }
75 
76  static ParticleIndexKey get_bonded_particle_0_key();
77 
78  static ParticleIndexKey get_bonded_particle_1_key();
79 
80  //! get decorator key for spring equilibrium rest length factor
81  static FloatKey get_equilibrium_rest_length_factor_key();
82 
83  //! get decorator key for spring rest length
84  static FloatKey get_rest_length_key();
85 
86  //! get decorator key for diffusion coefficient of rest length
87  static FloatKey get_rest_length_diffusion_coefficient_key();
88 
89  Particle* get_bonded_particle_0() const{
90  Particle* this_p= get_particle();
91  return this_p->get_value(get_bonded_particle_0_key());
92  }
93 
94  Particle* get_bonded_particle_1() const{
95  Particle* this_p= get_particle();
96  return this_p->get_value(get_bonded_particle_1_key());
97  }
98 
99  ParticleIndex get_bonded_particle_index_0() const{
100  return get_bonded_particle_0()->get_index();
101  }
102 
103  ParticleIndex get_bonded_particle_index_1() const{
104  return get_bonded_particle_1()->get_index();
105  }
106 
107 
108  IMP_DECORATOR_GET_SET(equilibrium_rest_length_factor,
109  get_equilibrium_rest_length_factor_key(),
111 
112  IMP_DECORATOR_GET_SET(rest_length,
113  get_rest_length_key(),
115 
116  IMP_DECORATOR_GET_SET(rest_length_diffusion_coefficient,
117  get_rest_length_diffusion_coefficient_key(),
119 
120  void add_to_rest_length_derivative
121  ( double d, DerivativeAccumulator& da )
122  {
123  get_model()->add_to_derivative( get_rest_length_key(),
125  d,
126  da );
127  }
128 
129  double get_rest_length_derivative()
130  {
131  return get_model()->get_derivative( get_rest_length_key(),
132  get_particle_index() );
133  }
134 
135 };
136 
137 
138 
139 IMP_DECORATORS(RelaxingSpring, RelaxingSprings, IMP::Decorators);
140 
141 IMPNPCTRANSPORT_END_NAMESPACE
142 
143 #endif /* IMPNPCTRANSPORT_RELAXING_SPRING_H */
The base class for decorators.
#define IMP_DECORATOR_GET_SET(name, AttributeKey, Type, ReturnType)
Define methods for getting and setting a particular simple field.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:188
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is an instance of an Transporting.
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:191
Index< ParticleIndexTag > ParticleIndex
Definition: base_types.h:154
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Various general useful macros for IMP.
#define IMP_DECORATOR_SETUP_4(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name,FourthArgumentType, fourth_argument_name)
A decorator for a spring particle connecting two diffusing particles.
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
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Class to handle individual particles of a Model object.
Definition: Particle.h:41
#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
Class for adding derivatives from restraints to the model.