56 void MolecularRestraint::calcForce(std::vector<Vector3d> struc,
58 assert(struc.size() == ref_.size());
60 std::vector<Vector3d>::iterator it;
64 for (it = forces_.begin(); it != forces_.end(); ++it)
67 if (restType_ & rtDisplacement) {
71 RealType p = 0.5 * kDisp_ * r * r;
75 if (printRest_) restInfo_[rtDisplacement] = std::make_pair(r, p);
77 for (it = forces_.begin(); it != forces_.end(); ++it)
78 (*it) += -kDisp_ * del * scaleFactor_;
81 if (restType_ & rtAbsoluteZ) {
82 RealType r = molCom(2) - posZ0_;
83 RealType p = 0.5 * kAbs_ * r * r;
88 if (printRest_) restInfo_[rtAbsoluteZ] = std::make_pair(r, p);
90 for (it = forces_.begin(); it != forces_.end(); ++it)
91 (*it) += frc * scaleFactor_;
101 for (
unsigned int n = 0; n < struc.size(); n++) {
113 R += outProduct(struc[n], ref_[n]);
125 Rtmp.setSubMatrix(0, 0, R);
139 vtmp.getSubMatrix(0, 0, v);
140 stmp.getSubVector(0, s);
141 wtmp.getSubMatrix(0, 0, w_tr);
157 RealType swingX, swingY;
159 quat.toTwistSwing(twistAngle, swingX, swingY);
161 RealType dVdtwist, dVdswingX, dVdswingY;
162 RealType dTwist, dSwingX, dSwingY;
165 if (restType_ & rtTwist) {
166 dTwist = twistAngle - twist0_;
169 dVdtwist = kTwist_ * dTwist;
170 p = 0.5 * kTwist_ * dTwist * dTwist;
172 tBody -= dVdtwist * V3Z;
173 if (printRest_) restInfo_[rtTwist] = std::make_pair(twistAngle, p);
176 if (restType_ & rtSwingX) {
177 dSwingX = swingX - swingX0_;
180 dVdswingX = kSwingX_ * dSwingX;
181 p = 0.5 * kSwingX_ * dSwingX * dSwingX;
183 tBody -= dVdswingX * V3X;
184 if (printRest_) restInfo_[rtSwingX] = std::make_pair(swingX, p);
186 if (restType_ & rtSwingY) {
187 dSwingY = swingY - swingY0_;
190 dVdswingY = kSwingY_ * dSwingY;
191 p = 0.5 * kSwingX_ * dSwingY * dSwingY;
193 tBody -= dVdswingY * V3Y;
194 if (printRest_) restInfo_[rtSwingY] = std::make_pair(swingY, p);
197 RealType t2 =
dot(tBody, tBody);
199 Vector3d rLab, rBody, txr, fBody, fLab;
201 for (
unsigned int i = 0; i < struc.size(); i++) {
205 txr =
cross(tBody, rBody);
207 fLab = Atrans * fBody;
208 fLab *= scaleFactor_;