49 |
|
|
50 |
|
Vector3d pos1 = atom1_->getPos(); |
51 |
|
Vector3d pos2 = ghostAtom->getPos(); |
52 |
+ |
|
53 |
+ |
Vector3d r21 = pos1 - pos2; |
54 |
+ |
RealType d21 = r21.length(); |
55 |
|
|
56 |
< |
Vector3d r12 = pos1 - pos2; |
57 |
< |
RealType d12 = r12.length(); |
56 |
> |
RealType d21inv = 1.0 / d21; |
57 |
> |
|
58 |
> |
// we need the transpose of A to get the lab fixed vector: |
59 |
> |
Vector3d r23 = ghostAtom->getA().transpose().getColumn(2); |
60 |
> |
RealType d23 = r23.length(); |
61 |
|
|
62 |
< |
RealType d12inv = 1.0 / d12; |
62 |
> |
RealType d23inv = 1.0 / d23; |
63 |
|
|
64 |
< |
Vector3d r32 = ghostAtom->getElectroFrame().getColumn(2); |
65 |
< |
RealType d32 = r32.length(); |
60 |
< |
|
61 |
< |
RealType d32inv = 1.0 / d32; |
62 |
< |
|
63 |
< |
RealType cosTheta = dot(r12, r32) / (d12 * d32); |
64 |
< |
|
64 |
> |
RealType cosTheta = dot(r21, r23) / (d21 * d23); |
65 |
> |
|
66 |
|
//check roundoff |
67 |
|
if (cosTheta > 1.0) { |
68 |
|
cosTheta = 1.0; |
71 |
|
} |
72 |
|
|
73 |
|
RealType theta = acos(cosTheta); |
74 |
+ |
|
75 |
+ |
RealType dVdTheta; |
76 |
|
|
77 |
< |
RealType firstDerivative; |
77 |
> |
bendType_->calcForce(theta, potential_, dVdTheta); |
78 |
|
|
76 |
– |
bendType_->calcForce(theta, potential_, firstDerivative); |
77 |
– |
|
79 |
|
RealType sinTheta = sqrt(1.0 - cosTheta * cosTheta); |
80 |
|
|
81 |
< |
if (fabs(sinTheta) < 1.0E-12) { |
82 |
< |
sinTheta = 1.0E-12; |
81 |
> |
if (fabs(sinTheta) < 1.0E-6) { |
82 |
> |
sinTheta = 1.0E-6; |
83 |
|
} |
84 |
|
|
85 |
< |
RealType commonFactor1 = -firstDerivative / sinTheta * d12inv; |
86 |
< |
RealType commonFactor2 = -firstDerivative / sinTheta * d32inv; |
85 |
> |
RealType commonFactor1 = dVdTheta / sinTheta * d21inv; |
86 |
> |
RealType commonFactor2 = dVdTheta / sinTheta * d23inv; |
87 |
|
|
88 |
< |
Vector3d force1 = commonFactor1*(r12*(d12inv*cosTheta) - r32*d32inv); |
89 |
< |
Vector3d force3 = commonFactor2*(r32*(d32inv*cosTheta) - r12*d12inv); |
88 |
> |
Vector3d force1 = commonFactor1 * (r23 * d23inv - r21*d21inv*cosTheta); |
89 |
> |
Vector3d force3 = commonFactor2 * (r21 * d21inv - r23*d23inv*cosTheta); |
90 |
> |
|
91 |
> |
// Total force in current bend is zero |
92 |
> |
|
93 |
|
atom1_->addFrc(force1); |
94 |
|
ghostAtom->addFrc(-force1); |
91 |
– |
/**@todo test correctness */ |
92 |
– |
ghostAtom->addTrq(cross(r32, force3) ); |
95 |
|
|
96 |
+ |
ghostAtom->addTrq( cross(r23, force3) ); |
97 |
+ |
|
98 |
|
atom1_->addParticlePot(potential_); |
99 |
|
ghostAtom->addParticlePot(potential_); |
100 |
|
|
101 |
|
angle = theta /M_PI * 180.0; |
102 |
< |
|
102 |
> |
|
103 |
|
} |
104 |
|
} //end namespace OpenMD |
105 |
|
|