ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/primitives/GhostTorsion.cpp
(Generate patch)

Comparing trunk/src/primitives/GhostTorsion.cpp (file contents):
Revision 273 by tim, Tue Jan 25 17:45:23 2005 UTC vs.
Revision 963 by tim, Wed May 17 21:51:42 2006 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# Line 43 | Line 43 | namespace oopse {
43  
44   namespace oopse {
45  
46 < GhostTorsion::GhostTorsion(Atom *atom1, Atom *atom2,  DirectionalAtom* ghostAtom,
47 <                 TorsionType *tt) : Torsion(atom1, atom2, ghostAtom, ghostAtom, tt) {}
46 >  GhostTorsion::GhostTorsion(Atom *atom1, Atom *atom2,  DirectionalAtom* ghostAtom,
47 >                             TorsionType *tt) : Torsion(atom1, atom2, ghostAtom, ghostAtom, tt) {}
48  
49 < void GhostTorsion::calcForce() {
50 <    DirectionalAtom* ghostAtom = static_cast<DirectionalAtom*>(atom2_);    
49 >  void GhostTorsion::calcForce(RealType& angle) {
50 >    DirectionalAtom* ghostAtom = static_cast<DirectionalAtom*>(atom3_);    
51  
52      Vector3d pos1 = atom1_->getPos();
53      Vector3d pos2 = atom2_->getPos();
# Line 59 | Line 59 | void GhostTorsion::calcForce() {
59  
60      //  Calculate the cross products and distances
61      Vector3d A = cross(r21, r32);
62 <    double rA = A.length();
62 >    RealType rA = A.length();
63      Vector3d B = cross(r32, r43);
64 <    double rB = B.length();
64 >    RealType rB = B.length();
65      Vector3d C = cross(r32, A);
66 <    double rC = C.length();
66 >    RealType rC = C.length();
67  
68      A.normalize();
69      B.normalize();
70      C.normalize();
71      
72      //  Calculate the sin and cos
73 <    double cos_phi = dot(A, B) ;
74 <    double sin_phi = dot(C, B);
73 >    RealType cos_phi = dot(A, B) ;
74  
75 <    double dVdPhi;
76 <    torsionType_->calcForce(cos_phi, sin_phi, potential_, dVdPhi);
75 >    RealType dVdcosPhi;
76 >    torsionType_->calcForce(cos_phi, potential_, dVdcosPhi);
77  
78      Vector3d dcosdA = (cos_phi * A - B) /rA;
79      Vector3d dcosdB = (cos_phi * B - A) /rB;
80  
82    double dVdcosPhi = -dVdPhi / sin_phi;
83
81      Vector3d f1 = dVdcosPhi * cross(r32, dcosdA);
82      Vector3d f2 = dVdcosPhi * ( cross(r43, dcosdB) - cross(r21, dcosdA));
83      Vector3d f3 = dVdcosPhi * cross(dcosdB, r32);
# Line 92 | Line 89 | void GhostTorsion::calcForce() {
89  
90      f3.negate();
91      ghostAtom->addTrq(cross(r43, f3));    
95 }
92  
93 +    angle = acos(cos_phi) /M_PI * 180.0;
94 +  }
95 +
96   }
97  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines