| 47 |
|
TorsionType *tt) : |
| 48 |
|
atom1_(atom1), atom2_(atom2), atom3_(atom3), atom4_(atom4), torsionType_(tt) { } |
| 49 |
|
|
| 50 |
< |
void Torsion::calcForce(double& angle) { |
| 50 |
> |
void Torsion::calcForce(RealType& angle) { |
| 51 |
|
|
| 52 |
|
Vector3d pos1 = atom1_->getPos(); |
| 53 |
|
Vector3d pos2 = atom2_->getPos(); |
| 60 |
|
|
| 61 |
|
// Calculate the cross products and distances |
| 62 |
|
Vector3d A = cross(r21, r32); |
| 63 |
< |
double rA = A.length(); |
| 63 |
> |
RealType rA = A.length(); |
| 64 |
|
Vector3d B = cross(r32, r43); |
| 65 |
< |
double rB = B.length(); |
| 65 |
> |
RealType rB = B.length(); |
| 66 |
|
Vector3d C = cross(r32, A); |
| 67 |
< |
double rC = C.length(); |
| 67 |
> |
RealType rC = C.length(); |
| 68 |
|
|
| 69 |
|
A.normalize(); |
| 70 |
|
B.normalize(); |
| 71 |
|
C.normalize(); |
| 72 |
|
|
| 73 |
|
// Calculate the sin and cos |
| 74 |
< |
double cos_phi = dot(A, B) ; |
| 74 |
> |
RealType cos_phi = dot(A, B) ; |
| 75 |
|
if (cos_phi > 1.0) cos_phi = 1.0; |
| 76 |
|
if (cos_phi < -1.0) cos_phi = -1.0; |
| 77 |
|
|
| 78 |
< |
double dVdcosPhi; |
| 78 |
> |
RealType dVdcosPhi; |
| 79 |
|
torsionType_->calcForce(cos_phi, potential_, dVdcosPhi); |
| 80 |
< |
Vector3d f1; |
| 81 |
< |
Vector3d f2; |
| 82 |
< |
Vector3d f3; |
| 80 |
> |
Vector3d f1 ; |
| 81 |
> |
Vector3d f2 ; |
| 82 |
> |
Vector3d f3 ; |
| 83 |
|
|
| 84 |
|
Vector3d dcosdA = (cos_phi * A - B) /rA; |
| 85 |
|
Vector3d dcosdB = (cos_phi * B - A) /rB; |
| 92 |
|
atom2_->addFrc(f2 - f1); |
| 93 |
|
atom3_->addFrc(f3 - f2); |
| 94 |
|
atom4_->addFrc(-f3); |
| 95 |
+ |
|
| 96 |
+ |
atom1_->addParticlePot(potential_); |
| 97 |
+ |
atom2_->addParticlePot(potential_); |
| 98 |
+ |
atom3_->addParticlePot(potential_); |
| 99 |
+ |
atom4_->addParticlePot(potential_); |
| 100 |
+ |
|
| 101 |
|
angle = acos(cos_phi) /M_PI * 180.0; |
| 102 |
|
} |
| 103 |
|
|