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

Comparing trunk/src/primitives/Torsion.cpp (file contents):
Revision 1446 by gezelter, Thu Jun 17 14:48:02 2010 UTC vs.
Revision 1953 by gezelter, Thu Dec 5 18:19:26 2013 UTC

# Line 35 | Line 35
35   *                                                                      
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).                        
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
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/Torsion.hpp"
47  
48   namespace OpenMD {
49  
50    Torsion::Torsion(Atom *atom1, Atom *atom2, Atom *atom3, Atom *atom4,
51 <                   TorsionType *tt) :
52 <    atom1_(atom1), atom2_(atom2), atom3_(atom3), atom4_(atom4), torsionType_(tt) { }
51 >                   TorsionType *tt) : ShortRangeInteraction(),
52 >                                      torsionType_(tt) {
53 >    atoms_.resize(4);
54 >    atoms_[0] = atom1;
55 >    atoms_[1] = atom2;
56 >    atoms_[2] = atom3;
57 >    atoms_[3] = atom4;
58 >  }
59  
60 <  void Torsion::calcForce(RealType& angle) {
60 >  void Torsion::calcForce(RealType& angle, bool doParticlePot) {
61  
62 <    Vector3d pos1 = atom1_->getPos();
63 <    Vector3d pos2 = atom2_->getPos();
64 <    Vector3d pos3 = atom3_->getPos();
65 <    Vector3d pos4 = atom4_->getPos();
62 >    Vector3d pos1 = atoms_[0]->getPos();
63 >    Vector3d pos2 = atoms_[1]->getPos();
64 >    Vector3d pos3 = atoms_[2]->getPos();
65 >    Vector3d pos4 = atoms_[3]->getPos();
66  
67      Vector3d r21 = pos1 - pos2;
68      Vector3d r32 = pos2 - pos3;
# Line 93 | Line 103 | namespace OpenMD {
103      f2 = dVdcosPhi * ( cross(r43, dcosdB) - cross(r21, dcosdA));
104      f3 = dVdcosPhi * cross(dcosdB, r32);
105      
106 <    atom1_->addFrc(f1);
107 <    atom2_->addFrc(f2 - f1);
108 <    atom3_->addFrc(f3 - f2);
109 <    atom4_->addFrc(-f3);
106 >    atoms_[0]->addFrc(f1);
107 >    atoms_[1]->addFrc(f2 - f1);
108 >    atoms_[2]->addFrc(f3 - f2);
109 >    atoms_[3]->addFrc(-f3);
110      
111 <    atom1_->addParticlePot(potential_);
112 <    atom2_->addParticlePot(potential_);
113 <    atom3_->addParticlePot(potential_);
114 <    atom4_->addParticlePot(potential_);
111 >    if (doParticlePot) {
112 >      atoms_[0]->addParticlePot(potential_);
113 >      atoms_[1]->addParticlePot(potential_);
114 >      atoms_[2]->addParticlePot(potential_);
115 >      atoms_[3]->addParticlePot(potential_);
116 >    }
117      
118      angle = acos(cos_phi) /M_PI * 180.0;    
119    }  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines