--- trunk/src/restraints/ObjectRestraint.cpp 2013/06/16 15:15:42 1879 +++ trunk/src/restraints/ObjectRestraint.cpp 2015/03/05 16:30:23 2069 @@ -52,9 +52,10 @@ namespace OpenMD { RealType r = del.length(); Vector3d frc = -kDisp_ * del; RealType p = 0.5 * kDisp_ * del.lengthSquare(); + pot_ = p; force_ = frc * scaleFactor_; - restInfo_[rtDisplacement] = std::make_pair(r,p); + if (printRest_) restInfo_[rtDisplacement] = std::make_pair(r,p); } } @@ -68,7 +69,6 @@ namespace OpenMD { Vector3d tBody(0.0); RotMat3x3d temp = A * refA_.transpose(); - Quat4d quat = temp.toQuaternion(); RealType twistAngle; @@ -77,34 +77,41 @@ namespace OpenMD { quat.toSwingTwist(swingX, swingY, twistAngle); + RealType p; Vector3d tTwist, tSwing; if (restType_ & rtTwist){ - RealType dTwist = twistAngle - twist0_; - RealType dVdtwist = kTwist_ * sin(dTwist); - p = kTwist_ * (1.0 - cos(dTwist) ); + RealType dTwist = twistAngle - twist0_; + /// RealType dVdtwist = kTwist_ * sin(dTwist); + /// p = kTwist_ * (1.0 - cos(dTwist) ); + RealType dVdtwist = kTwist_ * dTwist; + p = 0.5 * kTwist_ * dTwist * dTwist; pot_ += p; tBody -= dVdtwist * V3Z; - restInfo_[rtTwist] = std::make_pair(twistAngle, p); + if (printRest_) restInfo_[rtTwist] = std::make_pair(twistAngle, p); } if (restType_ & rtSwingX){ RealType dSwingX = swingX - swingX0_; - RealType dVdswingX = kSwingX_ * 0.5 * sin(2.0 * dSwingX); - p = 0.25 * kSwingX_ * (1.0 - cos(2.0 * dSwingX)); + /// RealType dVdswingX = kSwingX_ * 0.5 * sin(2.0 * dSwingX); + /// p = 0.25 * kSwingX_ * (1.0 - cos(2.0 * dSwingX)); + RealType dVdswingX = kSwingX_ * dSwingX; + p = 0.5 * kSwingX_ * dSwingX * dSwingX; pot_ += p; tBody -= dVdswingX * V3X; - restInfo_[rtSwingX] = std::make_pair(swingX, p); + if (printRest_) restInfo_[rtSwingX] = std::make_pair(swingX, p); } if (restType_ & rtSwingY){ RealType dSwingY = swingY - swingY0_; - RealType dVdswingY = kSwingY_ * 0.5 * sin(2.0 * dSwingY); - p = 0.25 * kSwingY_ * (1.0 - cos(2.0 * dSwingY)); + /// RealType dVdswingY = kSwingY_ * 0.5 * sin(2.0 * dSwingY); + /// p = 0.25 * kSwingY_ * (1.0 - cos(2.0 * dSwingY)); + RealType dVdswingY = kSwingY_ * dSwingY; + p = 0.5 * kSwingX_ * dSwingY * dSwingY; pot_ += p; tBody -= dVdswingY * V3Y; - restInfo_[rtSwingY] = std::make_pair(swingY, p); + if (printRest_) restInfo_[rtSwingY] = std::make_pair(swingY, p); } Vector3d tLab = A.transpose() * tBody;