--- trunk/src/restraints/ObjectRestraint.cpp 2014/09/22 19:18:35 2020 +++ trunk/src/restraints/ObjectRestraint.cpp 2014/10/16 19:13:51 2024 @@ -70,6 +70,8 @@ namespace OpenMD { RotMat3x3d temp = A * refA_.transpose(); + Vector3d euler = temp.toEulerAngles(); + Quat4d quat = temp.toQuaternion(); RealType twistAngle; @@ -78,13 +80,16 @@ 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; if (printRest_) restInfo_[rtTwist] = std::make_pair(twistAngle, p); @@ -92,8 +97,10 @@ namespace OpenMD { 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; if (printRest_) restInfo_[rtSwingX] = std::make_pair(swingX, p); @@ -101,8 +108,10 @@ namespace OpenMD { 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; if (printRest_) restInfo_[rtSwingY] = std::make_pair(swingY, p);