50 |
|
Inversion::Inversion(Atom *atom1, Atom *atom2, Atom *atom3, |
51 |
|
Atom *atom4, InversionType *it) : |
52 |
|
atom1_(atom1), atom2_(atom2), atom3_(atom3), atom4_(atom4), |
53 |
< |
inversionType_(it) { } |
53 |
> |
inversionType_(it) { |
54 |
> |
inversionKey_ = inversionType_->getKey(); |
55 |
> |
} |
56 |
|
|
57 |
|
void Inversion::calcForce(RealType& angle, bool doParticlePot) { |
58 |
|
|
88 |
|
if (cos_phi < -1.0) cos_phi = -1.0; |
89 |
|
|
90 |
|
RealType dVdcosPhi; |
91 |
< |
inversionType_->calcForce(cos_phi, potential_, dVdcosPhi); |
91 |
> |
switch (inversionKey_) { |
92 |
> |
case itCosAngle: |
93 |
> |
inversionType_->calcForce(cos_phi, potential_, dVdcosPhi); |
94 |
> |
break; |
95 |
> |
case itAngle: |
96 |
> |
RealType phi = acos(cos_phi); |
97 |
> |
RealType dVdPhi; |
98 |
> |
inversionType_->calcForce(phi, potential_, dVdPhi); |
99 |
> |
RealType sin_phi = sqrt(1.0 - cos_phi * cos_phi); |
100 |
> |
if (fabs(sin_phi) < 1.0E-6) { |
101 |
> |
sin_phi = 1.0E-6; |
102 |
> |
} |
103 |
> |
dVdcosPhi = dVdPhi / sin_phi; |
104 |
> |
break; |
105 |
> |
} |
106 |
> |
|
107 |
|
Vector3d f1 ; |
108 |
|
Vector3d f2 ; |
109 |
|
Vector3d f3 ; |