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

Comparing trunk/src/primitives/RigidBody.cpp (file contents):
Revision 636 by gezelter, Wed Sep 28 16:32:44 2005 UTC vs.
Revision 899 by tim, Wed Mar 15 17:35:12 2006 UTC

# Line 51 | Line 51 | namespace oopse {
51  
52    void RigidBody::setPrevA(const RotMat3x3d& a) {
53      ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = a;
54    //((snapshotMan_->getPrevSnapshot())->*storage_).electroFrame[localIndex_] = a.transpose() * sU_;
54  
55      for (int i =0 ; i < atoms_.size(); ++i){
56        if (atoms_[i]->isDirectional()) {
57 <        atoms_[i]->setPrevA(a * refOrients_[i]);
57 >        atoms_[i]->setPrevA(refOrients_[i].transpose() * a);
58        }
59      }
60  
# Line 64 | Line 63 | namespace oopse {
63        
64    void RigidBody::setA(const RotMat3x3d& a) {
65      ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = a;
67    //((snapshotMan_->getCurrentSnapshot())->*storage_).electroFrame[localIndex_] = a.transpose() * sU_;
66  
67      for (int i =0 ; i < atoms_.size(); ++i){
68        if (atoms_[i]->isDirectional()) {
69 <        atoms_[i]->setA(a * refOrients_[i]);
69 >        atoms_[i]->setA(refOrients_[i].transpose() * a);
70        }
71      }
72    }    
# Line 79 | Line 77 | namespace oopse {
77  
78      for (int i =0 ; i < atoms_.size(); ++i){
79        if (atoms_[i]->isDirectional()) {
80 <        atoms_[i]->setA(a * refOrients_[i], snapshotNo);
80 >        atoms_[i]->setA(refOrients_[i].transpose() * a, snapshotNo);
81        }
82      }
83  
# Line 164 | Line 162 | namespace oopse {
162      }
163  
164      // Moment of Inertia calculation
165 <    Mat3x3d Itmp(0.0);
168 <  
165 >    Mat3x3d Itmp(0.0);    
166      for (std::size_t i = 0; i < atoms_.size(); i++) {
167 +      Mat3x3d IAtom(0.0);  
168        mtmp = atoms_[i]->getMass();
169 <      Itmp -= outProduct(refCoords_[i], refCoords_[i]) * mtmp;
169 >      IAtom -= outProduct(refCoords_[i], refCoords_[i]) * mtmp;
170        double r2 = refCoords_[i].lengthSquare();
171 <      Itmp(0, 0) += mtmp * r2;
172 <      Itmp(1, 1) += mtmp * r2;
173 <      Itmp(2, 2) += mtmp * r2;
174 <    }
171 >      IAtom(0, 0) += mtmp * r2;
172 >      IAtom(1, 1) += mtmp * r2;
173 >      IAtom(2, 2) += mtmp * r2;
174 >      Itmp += IAtom;
175  
176 <    //project the inertial moment of directional atoms into this rigid body
179 <    for (std::size_t i = 0; i < atoms_.size(); i++) {
176 >      //project the inertial moment of directional atoms into this rigid body
177        if (atoms_[i]->isDirectional()) {
178 <        RectMatrix<double, 3, 3> Iproject = refOrients_[i].transpose() * atoms_[i]->getI();
179 <        Itmp(0, 0) += Iproject(0, 0);
183 <        Itmp(1, 1) += Iproject(1, 1);
184 <        Itmp(2, 2) += Iproject(2, 2);
185 <      }
178 >        Itmp += refOrients_[i].transpose() * atoms_[i]->getI() * refOrients_[i];
179 >      }
180      }
181  
182 +    //    std::cout << Itmp << std::endl;
183 +
184      //diagonalize
185      Vector3d evals;
186      Mat3x3d::diagonalize(Itmp, evals, sU_);
# Line 249 | Line 245 | namespace oopse {
245          
246      }
247      
248 <    setFrc(frc);
249 <    setTrq(trq);
248 >    addFrc(frc);
249 >    addTrq(trq);
250      
251    }
252  
# Line 273 | Line 269 | namespace oopse {
269        if (atoms_[i]->isDirectional()) {
270            
271          dAtom = (DirectionalAtom *) atoms_[i];
272 <        dAtom->setA(refOrients_[i] * a);
272 >        dAtom->setA(refOrients_[i].transpose() * a);
273        }
274  
275      }
# Line 300 | Line 296 | namespace oopse {
296        if (atoms_[i]->isDirectional()) {
297            
298          dAtom = (DirectionalAtom *) atoms_[i];
299 <        dAtom->setA(refOrients_[i] * a, frame);
299 >        dAtom->setA(refOrients_[i].transpose() * a, frame);
300        }
301  
302      }
# Line 485 | Line 481 | namespace oopse {
481                 "RigidBody error.\n"
482                 "\tAtom %s does not have a position specified.\n"
483                 "\tThis means RigidBody cannot set up reference coordinates.\n",
484 <               ats->getType() );
484 >               ats->getType().c_str() );
485        painCave.isFatal = 1;
486        simError();
487      }
# Line 505 | Line 501 | namespace oopse {
501                   "RigidBody error.\n"
502                   "\tAtom %s does not have an orientation specified.\n"
503                   "\tThis means RigidBody cannot set up reference orientations.\n",
504 <                 ats->getType() );
504 >                 ats->getType().c_str() );
505          painCave.isFatal = 1;
506          simError();
507        }    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines