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: 1748
Committed: Wed Nov 17 21:47:42 2004 UTC (19 years, 7 months ago) by tim
File size: 1263 byte(s)
Log Message:
UreyBradleyBend and GhostBend

File Contents

# Content
1 #include "primitives/Bend.hpp"
2
3 namespace oopse {
4
5 /**@todo still a lot left to improve*/
6 void Bend::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->getUnitVector();
18 double d32 = r32.length();
19
20 double d32inv = 1. 0 / d32;
21
22 double cosTheta = (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
48 atom1_->addFrc(force1);
49 ghostAtom->addFrc(-force1);
50 ghostAtom->addTrq();
51
52 }
53
54 } //end namespace oopse
55