--- trunk/src/restraints/ObjectRestraint.cpp 2014/03/06 19:34:22 1973 +++ trunk/src/restraints/ObjectRestraint.cpp 2014/10/16 19:13:51 2024 @@ -55,7 +55,7 @@ namespace OpenMD { pot_ = p; force_ = frc * scaleFactor_; - restInfo_[rtDisplacement] = std::make_pair(r,p); + if (printRest_) restInfo_[rtDisplacement] = std::make_pair(r,p); } } @@ -70,6 +70,8 @@ namespace OpenMD { RotMat3x3d temp = A * refA_.transpose(); + Vector3d euler = temp.toEulerAngles(); + Quat4d quat = temp.toQuaternion(); RealType twistAngle; @@ -78,34 +80,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;