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

Comparing trunk/src/primitives/Inversion.cpp (file contents):
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC vs.
Revision 1890 by gezelter, Tue Jun 18 21:06:25 2013 UTC

# Line 50 | Line 50 | namespace OpenMD {
50    Inversion::Inversion(Atom *atom1, Atom *atom2, Atom *atom3,
51                         Atom *atom4, InversionType *it) :
52      atom1_(atom1), atom2_(atom2), atom3_(atom3), atom4_(atom4),
53 <    inversionType_(it) { }
53 >    inversionType_(it) {
54 >    inversionKey_ = inversionType_->getKey();
55 >  }
56    
57    void Inversion::calcForce(RealType& angle, bool doParticlePot) {
58      
# Line 86 | Line 88 | namespace OpenMD {
88      if (cos_phi < -1.0) cos_phi = -1.0;
89  
90      RealType dVdcosPhi;
91 <    inversionType_->calcForce(cos_phi, potential_, dVdcosPhi);
91 >    switch (inversionKey_) {
92 >    case itCosAngle:
93 >      inversionType_->calcForce(cos_phi, potential_, dVdcosPhi);
94 >      break;
95 >    case itAngle:
96 >      RealType phi = acos(cos_phi);
97 >      RealType dVdPhi;
98 >      inversionType_->calcForce(phi, potential_, dVdPhi);
99 >      RealType sin_phi = sqrt(1.0 - cos_phi * cos_phi);  
100 >      if (fabs(sin_phi) < 1.0E-6) {
101 >        sin_phi = 1.0E-6;
102 >      }
103 >      dVdcosPhi = dVdPhi / sin_phi;
104 >      break;
105 >    }
106 >    
107      Vector3d f1 ;
108      Vector3d f2 ;
109      Vector3d f3 ;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines