IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2022 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>
16#include <IMP/Particle.h>
17
18IMPNPCTRANSPORT_BEGIN_NAMESPACE
19
20//! A decorator for a spring particle connecting two diffusing particles
21/** \ingroup helper
22 \ingroup decorators
23 */
24
25class IMPNPCTRANSPORTEXPORT
26RelaxingSpring : public Decorator
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,
41 ParticleIndex bonded_pi0,
42 ParticleIndex bonded_pi1,
43 double equilibrium_rest_length_factor,
44 double rest_length_diffusion_coefficient);
45
46
47 public:
48 IMP_DECORATOR_METHODS(RelaxingSpring, Decorator);
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 */
63 IMP_DECORATOR_SETUP_4(RelaxingSpring,
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
82
83 //! get decorator key for spring rest length
85
86 //! get decorator key for diffusion coefficient of rest length
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,
115
116 IMP_DECORATOR_GET_SET(rest_length_diffusion_coefficient,
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
139IMP_DECORATORS(RelaxingSpring, RelaxingSprings, IMP::Decorators);
140
141IMPNPCTRANSPORT_END_NAMESPACE
142
143#endif /* IMPNPCTRANSPORT_RELAXING_SPRING_H */
The base class for decorators.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition Decorator.h:211
Model * get_model() const
Returns the Model containing the particle.
Definition Decorator.h:214
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition Decorator.h:194
Class for adding derivatives from restraints to the model.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
static FloatKey get_equilibrium_rest_length_factor_key()
get decorator key for spring equilibrium rest length factor
static FloatKey get_rest_length_key()
get decorator key for spring rest length
static FloatKey get_rest_length_diffusion_coefficient_key()
get decorator key for diffusion coefficient of rest length
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is an instance of an Transporting.
Helper macros for implementing Decorators.
#define IMP_DECORATOR_GET_SET(name, AttributeKey, Type, ReturnType)
Define methods for getting and setting a particular simple field.
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_DECORATOR_SETUP_4(Name, FirstArgumentType, first_argument_name, SecondArgumentType, second_argument_name, ThirdArgumentType, third_argument_name, FourthArgumentType, fourth_argument_name)
#define IMP_DECORATOR_METHODS(Name, Parent)
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
double Float
Basic floating-point value (could be float, double...).
Definition types.h:19
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
Definition base_types.h:32
Key< 3 > ParticleIndexKey
The type used to identify a particle attribute in the Particles.
Definition base_types.h:44