ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Integrator.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/Integrator.cpp (file contents):
Revision 755 by mmeineke, Tue Sep 9 20:35:25 2003 UTC vs.
Revision 787 by mmeineke, Thu Sep 25 19:27:15 2003 UTC

# Line 25 | Line 25 | template<typename T> Integrator<T>::Integrator(SimInfo
25    if (info->the_integrator != NULL){
26      delete info->the_integrator;
27    }
28 <  info->the_integrator = this;
29 <
28 >  
29    nAtoms = info->n_atoms;
30  
31    // check for constraints
# Line 147 | Line 146 | template<typename T> void Integrator<T>::integrate(voi
146  
147  
148   template<typename T> void Integrator<T>::integrate(void){
150  int i, j;                         // loop counters
149  
150    double runTime = info->run_time;
151    double sampleTime = info->sampleTime;
# Line 162 | Line 160 | template<typename T> void Integrator<T>::integrate(voi
160    double currReset;
161    
162    int calcPot, calcStress;
165  int isError;
163  
164    tStats = new Thermo(info);
165    statOut = new StatWriter(info);
166    dumpOut = new DumpWriter(info);
167  
168    atoms = info->atoms;
172  DirectionalAtom* dAtom;
169  
170    dt = info->dt;
171    dt2 = 0.5 * dt;
172  
173 +  readyCheck();
174 +
175    // initialize the forces before the first step
176  
177    calcForce(1, 1);
178 +
179 +  if (nConstrained){
180 +    preMove();
181 +    constrainA();
182 +    calcForce(1, 1);    
183 +    constrainB();
184 +  }
185    
186    if (info->setTemp){
187      thermalize();
# Line 192 | Line 197 | template<typename T> void Integrator<T>::integrate(voi
197    dumpOut->writeDump(info->getTime());
198    statOut->writeStat(info->getTime());
199  
195  readyCheck();
200  
201 +
202   #ifdef IS_MPI
203    strcpy(checkPointMsg, "The integrator is ready to go.");
204    MPIcheckPoint();
# Line 254 | Line 259 | template<typename T> void Integrator<T>::integrateStep
259  
260    moveA();
261  
257  if (nConstrained){
258    constrainA();
259  }
262  
263  
264 +
265   #ifdef IS_MPI
266    strcpy(checkPointMsg, "Succesful moveA\n");
267    MPIcheckPoint();
# Line 279 | Line 282 | template<typename T> void Integrator<T>::integrateStep
282  
283    moveB();
284  
282  if (nConstrained){
283    constrainB();
284  }
285  
286 +
287   #ifdef IS_MPI
288    strcpy(checkPointMsg, "Succesful moveB\n");
289    MPIcheckPoint();
# Line 294 | Line 295 | template<typename T> void Integrator<T>::moveA(void){
295    int i, j;
296    DirectionalAtom* dAtom;
297    double Tb[3], ji[3];
297  double A[3][3], I[3][3];
298  double angle;
298    double vel[3], pos[3], frc[3];
299    double mass;
300  
# Line 331 | Line 330 | template<typename T> void Integrator<T>::moveA(void){
330        for (j = 0; j < 3; j++)
331          ji[j] += (dt2 * Tb[j]) * eConvert;
332  
333 <      // use the angular velocities to propagate the rotation matrix a
335 <      // full time step
333 >      this->rotationPropagation( dAtom, ji );
334  
337      dAtom->getA(A);
338      dAtom->getI(I);
339
340      // rotate about the x-axis      
341      angle = dt2 * ji[0] / I[0][0];
342      this->rotate(1, 2, angle, ji, A);
343
344      // rotate about the y-axis
345      angle = dt2 * ji[1] / I[1][1];
346      this->rotate(2, 0, angle, ji, A);
347
348      // rotate about the z-axis
349      angle = dt * ji[2] / I[2][2];
350      this->rotate(0, 1, angle, ji, A);
351
352      // rotate about the y-axis
353      angle = dt2 * ji[1] / I[1][1];
354      this->rotate(2, 0, angle, ji, A);
355
356      // rotate about the x-axis
357      angle = dt2 * ji[0] / I[0][0];
358      this->rotate(1, 2, angle, ji, A);
359
335        dAtom->setJ(ji);
361      dAtom->setA(A);
336      }
337    }
338 +
339 +  if (nConstrained){
340 +    constrainA();
341 +  }
342   }
343  
344  
# Line 402 | Line 380 | template<typename T> void Integrator<T>::moveB(void){
380        dAtom->setJ(ji);
381      }
382    }
383 +
384 +  if (nConstrained){
385 +    constrainB();
386 +  }
387   }
388  
389   template<typename T> void Integrator<T>::preMove(void){
# Line 420 | Line 402 | template<typename T> void Integrator<T>::constrainA(){
402   }
403  
404   template<typename T> void Integrator<T>::constrainA(){
405 <  int i, j, k;
405 >  int i, j;
406    int done;
407    double posA[3], posB[3];
408    double velA[3], velB[3];
# Line 560 | Line 542 | template<typename T> void Integrator<T>::constrainA(){
542      painCave.isFatal = 1;
543      simError();
544    }
545 +
546   }
547  
548   template<typename T> void Integrator<T>::constrainB(void){
549 <  int i, j, k;
549 >  int i, j;
550    int done;
551    double posA[3], posB[3];
552    double velA[3], velB[3];
# Line 572 | Line 555 | template<typename T> void Integrator<T>::constrainB(vo
555    int a, b, ax, ay, az, bx, by, bz;
556    double rma, rmb;
557    double dx, dy, dz;
558 <  double rabsq, pabsq, rvab;
576 <  double diffsq;
558 >  double rvab;
559    double gab;
560    int iteration;
561  
# Line 661 | Line 643 | template<typename T> void Integrator<T>::constrainB(vo
643      painCave.isFatal = 1;
644      simError();
645    }
646 + }
647 +
648 + template<typename T> void Integrator<T>::rotationPropagation
649 + ( DirectionalAtom* dAtom, double ji[3] ){
650 +
651 +  double angle;
652 +  double A[3][3], I[3][3];
653 +
654 +  // use the angular velocities to propagate the rotation matrix a
655 +  // full time step
656 +
657 +  dAtom->getA(A);
658 +  dAtom->getI(I);
659 +  
660 +  // rotate about the x-axis      
661 +  angle = dt2 * ji[0] / I[0][0];
662 +  this->rotate( 1, 2, angle, ji, A );
663 +  
664 +  // rotate about the y-axis
665 +  angle = dt2 * ji[1] / I[1][1];
666 +  this->rotate( 2, 0, angle, ji, A );
667 +  
668 +  // rotate about the z-axis
669 +  angle = dt * ji[2] / I[2][2];
670 +  this->rotate( 0, 1, angle, ji, A);
671 +  
672 +  // rotate about the y-axis
673 +  angle = dt2 * ji[1] / I[1][1];
674 +  this->rotate( 2, 0, angle, ji, A );
675 +  
676 +  // rotate about the x-axis
677 +  angle = dt2 * ji[0] / I[0][0];
678 +  this->rotate( 1, 2, angle, ji, A );
679 +  
680 +  dAtom->setA( A  );    
681   }
682  
683   template<typename T> void Integrator<T>::rotate(int axes1, int axes2,
# Line 753 | Line 770 | template<typename T> void Integrator<T>::thermalize(){
770   template<typename T> void Integrator<T>::thermalize(){
771    tStats->velocitize();
772   }
773 +
774 + template<typename T> double Integrator<T>::getConservedQuantity(void){
775 +  return tStats->getTotalE();
776 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines