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 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
Revision 1782 by gezelter, Wed Aug 22 02:28:28 2012 UTC

# Line 36 | Line 36
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38   * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43 + #include "config.h"
44 + #include <cmath>
45 +
46   #include "primitives/GhostTorsion.hpp"
47  
48   namespace OpenMD {
# Line 47 | Line 51 | namespace OpenMD {
51                               DirectionalAtom* ghostAtom, TorsionType *tt)
52      : Torsion(atom1, atom2, ghostAtom, ghostAtom, tt) {}
53    
54 <  void GhostTorsion::calcForce(RealType& angle) {
54 >  void GhostTorsion::calcForce(RealType& angle, bool doParticlePot) {
55      DirectionalAtom* ghostAtom = static_cast<DirectionalAtom*>(atom3_);    
56      
57      Vector3d pos1 = atom1_->getPos();
# Line 56 | Line 60 | namespace OpenMD {
60      
61      Vector3d r21 = pos1 - pos2;
62      Vector3d r32 = pos2 - pos3;
63 <    Vector3d r43 = ghostAtom->getElectroFrame().getColumn(2);
63 >    Vector3d r43 = ghostAtom->getA().transpose().getColumn(2);
64      
65      //  Calculate the cross products and distances
66      Vector3d A = cross(r21, r32);
67      RealType rA = A.length();
68      Vector3d B = cross(r32, r43);
69      RealType rB = B.length();
70 <    Vector3d C = cross(r32, A);
71 <    RealType rC = C.length();
70 >
71 >    /*
72 >       If either of the two cross product vectors is tiny, that means
73 >       the three atoms involved are colinear, and the torsion angle is
74 >       going to be undefined.  The easiest check for this problem is
75 >       to use the product of the two lengths.
76 >    */
77 >    if (rA * rB < OpenMD::epsilon) return;
78      
79      A.normalize();
80      B.normalize();
71    C.normalize();
81      
82      //  Calculate the sin and cos
83      RealType cos_phi = dot(A, B) ;
# Line 91 | Line 100 | namespace OpenMD {
100      f3.negate();
101      ghostAtom->addTrq(cross(r43, f3));    
102      
103 <    atom1_->addParticlePot(potential_);
104 <    atom2_->addParticlePot(potential_);
105 <    ghostAtom->addParticlePot(potential_);
103 >    if (doParticlePot) {
104 >      atom1_->addParticlePot(potential_);
105 >      atom2_->addParticlePot(potential_);
106 >      ghostAtom->addParticlePot(potential_);
107 >    }
108  
109      angle = acos(cos_phi) /M_PI * 180.0;
110    }

Comparing trunk/src/primitives/GhostTorsion.cpp (property svn:keywords):
Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
Revision 1782 by gezelter, Wed Aug 22 02:28:28 2012 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines