63 RealType d21 = r21.
length();
65 RealType d21inv = 1.0 / d21;
69 RealType d23 = r23.
length();
71 RealType d23inv = 1.0 / d23;
73 RealType cosTheta =
dot(r21, r23) / (d21 * d23);
78 }
else if (cosTheta < -1.0) {
82 RealType theta = acos(cosTheta);
86 bendType_->calcForce(theta, potential_, dVdTheta);
88 RealType sinTheta = sqrt(1.0 - cosTheta * cosTheta);
90 if (fabs(sinTheta) < 1.0E-6) { sinTheta = 1.0E-6; }
92 RealType commonFactor1 = dVdTheta / sinTheta * d21inv;
93 RealType commonFactor2 = dVdTheta / sinTheta * d23inv;
95 Vector3d force1 = commonFactor1 * (r23 * d23inv - r21 * d21inv * cosTheta);
96 Vector3d force3 = commonFactor2 * (r21 * d21inv - r23 * d23inv * cosTheta);
102 atoms_[0]->addFrc(force1);
103 atoms_[1]->addFrc(force2);
104 atoms_[2]->addFrc(force3);
107 atoms_[0]->addParticlePot(potential_);
108 atoms_[1]->addParticlePot(potential_);
109 atoms_[2]->addParticlePot(potential_);
112 angle = theta / Constants::PI * 180.0;