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

Comparing:
trunk/src/primitives/Torsion.cpp (file contents), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/primitives/Torsion.cpp (file contents), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 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 "primitives/Torsion.hpp"
# Line 63 | Line 64 | namespace OpenMD {
64      RealType rA = A.length();
65      Vector3d B = cross(r32, r43);
66      RealType rB = B.length();
66    Vector3d C = cross(r32, A);
67    RealType rC = C.length();
67  
68 +    /*
69 +       If either of the two cross product vectors is tiny, that means
70 +       the three atoms involved are colinear, and the torsion angle is
71 +       going to be undefined.  The easiest check for this problem is
72 +       to use the product of the two lengths.
73 +    */
74 +    if (rA * rB < OpenMD::epsilon) return;
75 +    
76      A.normalize();
77 <    B.normalize();
71 <    C.normalize();
77 >    B.normalize();  
78      
79      //  Calculate the sin and cos
80      RealType cos_phi = dot(A, B) ;
81      if (cos_phi > 1.0) cos_phi = 1.0;
82      if (cos_phi < -1.0) cos_phi = -1.0;
83 <
83 >    
84      RealType dVdcosPhi;
85      torsionType_->calcForce(cos_phi, potential_, dVdcosPhi);
86      Vector3d f1 ;
87      Vector3d f2 ;
88      Vector3d f3 ;
89 <
89 >    
90      Vector3d dcosdA = (cos_phi * A - B) /rA;
91      Vector3d dcosdB = (cos_phi * B - A) /rB;
92 <
92 >    
93      f1 = dVdcosPhi * cross(r32, dcosdA);
94      f2 = dVdcosPhi * ( cross(r43, dcosdB) - cross(r21, dcosdA));
95      f3 = dVdcosPhi * cross(dcosdB, r32);
# Line 92 | Line 98 | namespace OpenMD {
98      atom2_->addFrc(f2 - f1);
99      atom3_->addFrc(f3 - f2);
100      atom4_->addFrc(-f3);
101 <
101 >    
102      atom1_->addParticlePot(potential_);
103      atom2_->addParticlePot(potential_);
104      atom3_->addParticlePot(potential_);
105      atom4_->addParticlePot(potential_);
106 <
107 <    angle = acos(cos_phi) /M_PI * 180.0;
108 <  }
103 <
106 >    
107 >    angle = acos(cos_phi) /M_PI * 180.0;    
108 >  }  
109   }

Comparing:
trunk/src/primitives/Torsion.cpp (property svn:keywords), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/primitives/Torsion.cpp (property svn:keywords), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines