60 Vector3d pos1 = atoms_[0]->getPos();
61 Vector3d pos2 = atoms_[1]->getPos();
62 Vector3d pos3 = atoms_[2]->getPos();
64 Vector3d r21 = pos1 - pos2;
65 snapshotMan_->getCurrentSnapshot()->wrapVector(r21);
66 RealType d21 = r21.
length();
68 RealType d21inv = 1.0 / d21;
70 Vector3d r23 = pos3 - pos2;
71 snapshotMan_->getCurrentSnapshot()->wrapVector(r23);
72 RealType d23 = r23.
length();
74 RealType d23inv = 1.0 / d23;
76 RealType cosTheta =
dot(r21, r23) / (d21 * d23);
81 }
else if (cosTheta < -1.0) {
85 RealType theta = acos(cosTheta);
89 bendType_->calcForce(theta, potential_, dVdTheta);
91 RealType sinTheta = sqrt(1.0 - cosTheta * cosTheta);
93 if (fabs(sinTheta) < 1.0E-6) { sinTheta = 1.0E-6; }
95 RealType commonFactor1 = dVdTheta / sinTheta * d21inv;
96 RealType commonFactor2 = dVdTheta / sinTheta * d23inv;
98 Vector3d force1 = commonFactor1 * (r23 * d23inv - r21 * d21inv * cosTheta);
99 Vector3d force3 = commonFactor2 * (r21 * d21inv - r23 * d23inv * cosTheta);
102 Vector3d force2 = force1 + force3;
105 atoms_[0]->addFrc(force1);
106 atoms_[1]->addFrc(force2);
107 atoms_[2]->addFrc(force3);
110 atoms_[0]->addParticlePot(potential_);
111 atoms_[1]->addParticlePot(potential_);
112 atoms_[2]->addParticlePot(potential_);
115 angle = theta / Constants::PI * 180.0;