48#include "restraints/ObjectRestraint.hpp"
52 void ObjectRestraint::calcForce(Vector3d struc) {
56 if (restType_ & rtDisplacement) {
57 Vector3d del = struc - refPos_;
59 Vector3d frc = -kDisp_ * del;
63 force_ += frc * scaleFactor_;
64 if (printRest_) restInfo_[rtDisplacement] = std::make_pair(r, p);
67 if (restType_ & rtDisplacementX) {
68 Vector3d del = struc - refPos_;
70 Vector3d frc = -kDispX_ * r * V3X;
71 RealType p = 0.5 * kDisp_ * r * r;
74 force_ += frc * scaleFactor_;
75 if (printRest_) restInfo_[rtDisplacementX] = std::make_pair(r, p);
78 if (restType_ & rtDisplacementY) {
79 Vector3d del = struc - refPos_;
81 Vector3d frc = -kDispY_ * r * V3Y;
82 RealType p = 0.5 * kDisp_ * r * r;
85 force_ += frc * scaleFactor_;
86 if (printRest_) restInfo_[rtDisplacementY] = std::make_pair(r, p);
89 if (restType_ & rtDisplacementZ) {
90 Vector3d del = struc - refPos_;
92 Vector3d frc = -kDispZ_ * r * V3Z;
93 RealType p = 0.5 * kDisp_ * r * r;
96 force_ += frc * scaleFactor_;
97 if (printRest_) restInfo_[rtDisplacementZ] = std::make_pair(r, p);
100 if (restType_ & rtAbsoluteZ) {
101 RealType r = struc(2) - posZ0_;
102 Vector3d frc = Vector3d(0.0, 0.0, -kAbs_ * r);
103 RealType p = 0.5 * kAbs_ * r * r;
106 force_ += frc * scaleFactor_;
107 if (printRest_) restInfo_[rtAbsoluteZ] = std::make_pair(r, p);
111 void ObjectRestraint::calcForce(Vector3d struc, RotMat3x3d A) {
116 if (restType_ >= 32) {
119 RotMat3x3d temp = A * refA_.transpose();
123 RealType swingX, swingY;
125 quat.toTwistSwing(twistAngle, swingX, swingY);
128 Vector3d tTwist, tSwing;
130 if (restType_ & rtTwist) {
131 RealType dTwist = twistAngle - twist0_;
134 RealType dVdtwist = kTwist_ * dTwist;
135 p = 0.5 * kTwist_ * dTwist * dTwist;
137 tBody -= dVdtwist * V3Z;
139 if (printRest_) restInfo_[rtTwist] = std::make_pair(twistAngle, p);
142 if (restType_ & rtSwingX) {
143 RealType dSwingX = swingX - swingX0_;
146 RealType dVdswingX = kSwingX_ * dSwingX;
147 p = 0.5 * kSwingX_ * dSwingX * dSwingX;
149 tBody -= dVdswingX * V3X;
150 if (printRest_) restInfo_[rtSwingX] = std::make_pair(swingX, p);
153 if (restType_ & rtSwingY) {
154 RealType dSwingY = swingY - swingY0_;
157 RealType dVdswingY = kSwingY_ * dSwingY;
158 p = 0.5 * kSwingX_ * dSwingY * dSwingY;
160 tBody -= dVdswingY * V3Y;
161 if (printRest_) restInfo_[rtSwingY] = std::make_pair(swingY, p);
164 Vector3d tLab = A.transpose() * tBody;
165 torque_ = tLab * scaleFactor_;
Quaternion< Real > toQuaternion()
Returns the quaternion from this rotation matrix.
Real & z()
Returns reference of the third element of Vector3.
Real & x()
Returns reference of the first element of Vector3.
Real & y()
Returns reference of the second element of Vector3.
Real length() const
Returns the length of this vector.
Real lengthSquare() const
Returns the squared length of this vector.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.