1 |
|
#include "primitives/Bend.hpp" |
2 |
< |
|
2 |
> |
#include "primitives/DirectionalAtom.hpp" |
3 |
|
namespace oopse { |
4 |
|
|
5 |
|
/**@todo still a lot left to improve*/ |
6 |
< |
void Bend::calcForce() { |
7 |
< |
DirectionalAtom* ghostAtom = static_cast<DirectionalAtom>(atom2_); |
8 |
< |
|
6 |
> |
void Bend::calcForce() { |
7 |
> |
DirectionalAtom* ghostAtom = static_cast<DirectionalAtom*>(atom2_); |
8 |
> |
|
9 |
|
Vector3d pos1 = atom1_->getPos(); |
10 |
< |
Vector3d pos2 = ghostAtom->getPos(); |
10 |
> |
Vector3d pos2 = ghostAtom->getPos(); |
11 |
|
|
12 |
|
Vector3d r12 = pos1 - pos2; |
13 |
|
double d12 = r12.length(); |
14 |
|
|
15 |
< |
double d12inv = 1. 0 / d12; |
15 |
> |
double d12inv = 1.0 / d12; |
16 |
|
|
17 |
< |
Vector3d r32 = ghostAtom->getUnitVector(); |
17 |
> |
Vector3d r32 = ghostAtom->getUnitFrame().getColum(2); |
18 |
|
double d32 = r32.length(); |
19 |
|
|
20 |
< |
double d32inv = 1. 0 / d32; |
20 |
> |
double d32inv = 1.0 / d32; |
21 |
|
|
22 |
< |
double cosTheta = (r12 * r32) / (d12 * d32); |
22 |
> |
double cosTheta = dot(r12, r32) / (d12 * d32); |
23 |
|
|
24 |
|
//check roundoff |
25 |
|
if (cosTheta > 1.0) { |
36 |
|
|
37 |
|
double sinTheta = sqrt(1.0 - cosTheta * cosTheta); |
38 |
|
|
39 |
< |
if (fabs(sinTheta) < 1.0E - 12) { |
40 |
< |
sinTheta = 1.0E - 12; |
39 |
> |
if (fabs(sinTheta) < 1.0E-12) { |
40 |
> |
sinTheta = 1.0E-12; |
41 |
|
} |
42 |
|
|
43 |
|
double commonFactor1 = -firstDerivative / sinTheta * d12inv; |
44 |
|
double commonFactor2 = -firstDerivative / sinTheta * d32inv; |
45 |
|
|
46 |
|
Vector3d force1 = commonFactor1*(r12*(d12inv*cosTheta) - r32*d32inv); |
47 |
< |
|
47 |
> |
Vector3d force3 = commonFactor2*(r32*(d32inv*cosTheta) - r12*d12inv); |
48 |
|
atom1_->addFrc(force1); |
49 |
< |
ghostAtom->addFrc(-force1); |
50 |
< |
ghostAtom->addTrq(); |
51 |
< |
|
52 |
< |
} |
53 |
< |
|
49 |
> |
ghostAtom->addFrc(-force1); |
50 |
> |
/**@todo test correctness */ |
51 |
> |
ghostAtom->addTrq(cross(r32, force3) ); |
52 |
> |
|
53 |
> |
} |
54 |
> |
|
55 |
|
} //end namespace oopse |
56 |
< |
|
56 |
> |
|