IMP  2.3.1
The Integrative Modeling Platform
RigidBodyUmbrella.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/RigidBodyUmbrella.h
3  * \brief Distance restraint between two particles.
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_RIGIDBODY_UMBRELLA_H
10 #define IMPCORE_RIGIDBODY_UMBRELLA_H
11 
12 #include <IMP/core/core_config.h>
13 #include <IMP/core/internal/tunneler_helpers.h>
14 #include "DistancePairScore.h"
15 #include "XYZ.h"
16 #include <IMP/generic.h>
17 
18 #include <IMP/kernel/Restraint.h>
19 
20 #include <iostream>
21 
22 IMPCORE_BEGIN_NAMESPACE
23 
24 //! Umbrella-like restraint for rigid bodies
25 /**
26  * Let \f$x\f$ be the reduced coordinates (ie centroid+rotation) of some rigid
27  * body, relative to a reference rigid body. Let \f$x_0\f$ be the center of the
28  * umbrella. Then the restraint score is
29  * \f[ E(x) = \frac{\alpha}{2} d^2(x,x_0) \f]
30  * \f$d\f$ is the distance between x and x_0
31  * \f[d^2(x,x_0) = d^2_\text{eucl}(COM,COM_0) + k*d^2_\text{quat}(Q,Q_0)\f]
32  * \f$d_\text{eucl}\f$ is the 3D euclidian distance
33  * \f$d_\text{quat}\f$ is the geodesic distance between two rotations, i.e. the
34  * angle of the rotation \f$Q\cdot Q_0^{-1}\f$
35  *
36  * \see RigidBodyTunneler
37  */
38 class IMPCOREEXPORT RigidBodyUmbrella : public kernel::Restraint {
39  public:
40  //! Create the restraint by specifying \f$x_0\f$ directly.
41  /** \param[in] pi rigid body particle index to restrain
42  \param[in] ref rigid body particle index of reference
43  \param[in] x0 \f$x_0\f$ the restraint center
44  \param[in] alpha \f$\alpha\f$ restraint stiffness
45  \param[in] k \f$k\f$ relative weight between centroid and quaternion
46  restraints
47  \param[in] name restraint name
48  */
50  kernel::ParticleIndex ref, Floats x0, double alpha,
51  double k, std::string name = "RigidBodyUmbrella %1%");
52 
53  //! Create the restraint by specifying \f$x_0\f$ as a linear interpolation.
54  /**
55  * The restraint input is the triplet \f$\lambda,x_1,x_2\f$ with
56  * \f$\lambda\in [0,1]\f$ such that the restraint center is at
57  * \f[ x_0 = (1-\lambda) x_1 + \lambda x_2 \f]
58  *
59  * \param[in] pi rigid body particle index to restrain
60  * \param[in] ref rigid body particle index of reference
61  * \param[in] lambda \f$\lambda\f$ the restraint center
62  * \param[in] x1 \f$x_1\f$ the restraint center when \f$\lambda=0\f$
63  * \param[in] x2 \f$x_2\f$ the restraint center when \f$\lambda=1\f$
64  * \param[in] alpha \f$\alpha\f$ restraint stiffness
65  * \param[in] k \f$k\f$ relative weight between centroid and quaternion
66  * restraints
67  * \param[in] name restraint name
68  */
70  kernel::ParticleIndex ref, double lambda, Floats x1,
71  Floats x2, double alpha, double k,
72  std::string name = "RigidBodyUmbrella %1%");
73 
74  void set_x0(Floats x0) {x0_ = internal::Coord(x0); }
75  void set_x0(double lambda, Floats x1, Floats x2) {
76  x0_ = interpolate(lambda, x1, x2);
77  }
78  Floats get_x0() const {
79  return x0_.as_floats();
80  }
81  Floats get_x() const {
82  kernel::ParticleIndexes pis(1, pi_);
83  internal::Coord x(internal::get_coordinates_from_rbs(get_model(), pis,
84  ref_));
85  return x.as_floats();
86  }
87  void set_alpha(double alpha) { alpha_ = alpha; }
88  void set_k(double k) { k_ = k; }
89 
90  protected:
91  double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const;
94 
95  private:
96  internal::Coord interpolate(double lambda, Floats x1, Floats x2) const;
97 
98  private:
99  kernel::ParticleIndex pi_, ref_;
100  internal::Coord x0_;
101  double alpha_, k_;
102 };
103 
104 IMPCORE_END_NAMESPACE
105 
106 #endif /* IMPCORE_RIGIDBODY_UMBRELLA_H */
Class for adding derivatives from restraints to the model.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Simple XYZ decorator.
Umbrella-like restraint for rigid bodies.
Abstract base class for all restraints.
A restraint is a term in an IMP ScoringFunction.
A Score on the distance between a pair of particles.
virtual ModelObjectsTemp do_get_inputs() const =0
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73
Import IMP/kernel/generic.h in the namespace.