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 253 by tim, Thu Jan 13 19:40:37 2005 UTC vs.
Revision 374 by tim, Tue Feb 22 18:56:25 2005 UTC

# Line 42 | Line 42
42   #include <math.h>
43   #include "primitives/RigidBody.hpp"
44   #include "utils/simError.h"
45 + #include "utils/NumericConstant.hpp"
46   namespace oopse {
47  
48   RigidBody::RigidBody() : StuntDouble(otRigidBody, &Snapshot::rigidbodyData), inertiaTensor_(0.0){
# Line 172 | Line 173 | void  RigidBody::calcRefCoords() {
173          Itmp(0, 0) += mtmp * r2;
174          Itmp(1, 1) += mtmp * r2;
175          Itmp(2, 2) += mtmp * r2;
176 +    }
177 +
178 +    //project the inertial moment of directional atoms into this rigid body
179 +    for (std::size_t i = 0; i < atoms_.size(); i++) {
180 +        if (atoms_[i]->isDirectional()) {
181 +            RectMatrix<double, 3, 3> Iproject = refOrients_[i].transpose() * atoms_[i]->getI();
182 +            Itmp(0, 0) += Iproject(0, 0);
183 +            Itmp(1, 1) += Iproject(1, 1);
184 +            Itmp(2, 2) += Iproject(2, 2);
185 +        }
186      }
187  
188      //diagonalize
# Line 271 | Line 282 | void  RigidBody::updateAtoms() {
282   }
283  
284  
285 + void  RigidBody::updateAtoms(int frame) {
286 +    unsigned int i;
287 +    Vector3d ref;
288 +    Vector3d apos;
289 +    DirectionalAtom* dAtom;
290 +    Vector3d pos = getPos(frame);
291 +    RotMat3x3d a = getA(frame);
292 +    
293 +    for (i = 0; i < atoms_.size(); i++) {
294 +    
295 +        ref = body2Lab(refCoords_[i], frame);
296 +
297 +        apos = pos + ref;
298 +
299 +        atoms_[i]->setPos(apos, frame);
300 +
301 +        if (atoms_[i]->isDirectional()) {
302 +          
303 +          dAtom = (DirectionalAtom *) atoms_[i];
304 +          dAtom->setA(a * refOrients_[i], frame);
305 +        }
306 +
307 +    }
308 +  
309 + }
310 +
311 + void RigidBody::updateAtomVel() {
312 +    Mat3x3d skewMat;;
313 +
314 +    Vector3d ji = getJ();
315 +    Mat3x3d I =  getI();
316 +
317 +    skewMat(0, 0) =0;
318 +    skewMat(0, 1) = ji[2] /I(2, 2);
319 +    skewMat(0, 2) = -ji[1] /I(1, 1);
320 +
321 +    skewMat(1, 0) = -ji[2] /I(2, 2);
322 +    skewMat(1, 1) = 0;
323 +    skewMat(1, 2) = ji[0]/I(0, 0);
324 +
325 +    skewMat(2, 0) =ji[1] /I(1, 1);
326 +    skewMat(2, 1) = -ji[0]/I(0, 0);
327 +    skewMat(2, 2) = 0;
328 +
329 +    Mat3x3d mat = (getA() * skewMat).transpose();
330 +    Vector3d rbVel = getVel();
331 +
332 +
333 +    Vector3d velRot;        
334 +    for (int i =0 ; i < refCoords_.size(); ++i) {
335 +        atoms_[i]->setVel(rbVel + mat * refCoords_[i]);
336 +    }
337 +
338 + }
339 +
340 + void RigidBody::updateAtomVel(int frame) {
341 +    Mat3x3d skewMat;;
342 +
343 +    Vector3d ji = getJ(frame);
344 +    Mat3x3d I =  getI();
345 +
346 +    skewMat(0, 0) =0;
347 +    skewMat(0, 1) = ji[2] /I(2, 2);
348 +    skewMat(0, 2) = -ji[1] /I(1, 1);
349 +
350 +    skewMat(1, 0) = -ji[2] /I(2, 2);
351 +    skewMat(1, 1) = 0;
352 +    skewMat(1, 2) = ji[0]/I(0, 0);
353 +
354 +    skewMat(2, 0) =ji[1] /I(1, 1);
355 +    skewMat(2, 1) = -ji[0]/I(0, 0);
356 +    skewMat(2, 2) = 0;
357 +
358 +    Mat3x3d mat = (getA(frame) * skewMat).transpose();
359 +    Vector3d rbVel = getVel(frame);
360 +
361 +
362 +    Vector3d velRot;        
363 +    for (int i =0 ; i < refCoords_.size(); ++i) {
364 +        atoms_[i]->setVel(rbVel + mat * refCoords_[i], frame);
365 +    }
366 +
367 + }
368 +
369 +        
370 +
371   bool RigidBody::getAtomPos(Vector3d& pos, unsigned int index) {
372      if (index < atoms_.size()) {
373  
# Line 414 | Line 511 | void RigidBody::addAtom(Atom* at, AtomStamp* ats) {
511        simError();
512      }    
513      
514 <    euler[0] = ats->getEulerPhi();
515 <    euler[1] = ats->getEulerTheta();
516 <    euler[2] = ats->getEulerPsi();
514 >    euler[0] = ats->getEulerPhi() * NumericConstant::PI /180.0;
515 >    euler[1] = ats->getEulerTheta() * NumericConstant::PI /180.0;
516 >    euler[2] = ats->getEulerPsi() * NumericConstant::PI /180.0;
517  
518      RotMat3x3d Atmp(euler);
519      refOrients_.push_back(Atmp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines