ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/primitives/GhostBend.cpp
Revision: 1832
Committed: Thu Dec 2 16:04:19 2004 UTC (19 years, 7 months ago) by tim
File size: 1439 byte(s)
Log Message:
still have two linking problem

File Contents

# Content
1 #include "primitives/GhostBend.hpp"
2 #include "primitives/DirectionalAtom.hpp"
3 namespace oopse {
4
5 /**@todo still a lot left to improve*/
6 void GhostBend::calcForce() {
7 DirectionalAtom* ghostAtom = static_cast<DirectionalAtom*>(atom2_);
8
9 Vector3d pos1 = atom1_->getPos();
10 Vector3d pos2 = ghostAtom->getPos();
11
12 Vector3d r12 = pos1 - pos2;
13 double d12 = r12.length();
14
15 double d12inv = 1.0 / d12;
16
17 Vector3d r32 = ghostAtom->getElectroFrame().getColumn(2);
18 double d32 = r32.length();
19
20 double d32inv = 1.0 / d32;
21
22 double cosTheta = dot(r12, r32) / (d12 * d32);
23
24 //check roundoff
25 if (cosTheta > 1.0) {
26 cosTheta = 1.0;
27 } else if (cosTheta < -1.0) {
28 cosTheta = -1.0;
29 }
30
31 double theta = acos(cosTheta);
32
33 double firstDerivative;
34
35 bendType_->calcForce(theta, firstDerivative, potential_);
36
37 double sinTheta = sqrt(1.0 - cosTheta * cosTheta);
38
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 Vector3d force3 = commonFactor2*(r32*(d32inv*cosTheta) - r12*d12inv);
48 atom1_->addFrc(force1);
49 ghostAtom->addFrc(-force1);
50 /**@todo test correctness */
51 ghostAtom->addTrq(cross(r32, force3) );
52
53 }
54
55 } //end namespace oopse
56