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 837 by tim, Wed Oct 29 00:19:10 2003 UTC vs.
Revision 1118 by tim, Mon Apr 19 03:52:27 2004 UTC

# Line 7 | Line 7
7   #include <unistd.h>
8   #endif //is_mpi
9  
10 + #ifdef PROFILE
11 + #include "mdProfile.hpp"
12 + #endif // profile
13 +
14   #include "Integrator.hpp"
15   #include "simError.h"
16  
# Line 27 | Line 31 | template<typename T> Integrator<T>::Integrator(SimInfo
31    }
32  
33    nAtoms = info->n_atoms;
34 +  integrableObjects = info->integrableObjects;
35  
36    // check for constraints
37  
# Line 64 | Line 69 | template<typename T> void Integrator<T>::checkConstrai
69  
70    SRI** theArray;
71    for (int i = 0; i < nMols; i++){
72 <    theArray = (SRI * *) molecules[i].getMyBonds();
72 >
73 >          theArray = (SRI * *) molecules[i].getMyBonds();
74      for (int j = 0; j < molecules[i].getNBonds(); j++){
75        constrained = theArray[j]->is_constrained();
76  
# Line 110 | Line 116 | template<typename T> void Integrator<T>::checkConstrai
116      }
117    }
118  
119 +
120    if (nConstrained > 0){
121      isConstrained = 1;
122  
# Line 131 | Line 138 | template<typename T> void Integrator<T>::checkConstrai
138      }
139  
140  
141 <    // save oldAtoms to check for lode balanceing later on.
141 >    // save oldAtoms to check for lode balancing later on.
142  
143      oldAtoms = nAtoms;
144  
# Line 175 | Line 182 | template<typename T> void Integrator<T>::integrate(voi
182    // initialize the forces before the first step
183  
184    calcForce(1, 1);
185 <
185 >  
186    if (nConstrained){
187      preMove();
188      constrainA();
189      calcForce(1, 1);
190      constrainB();
191    }
192 <
192 >  
193    if (info->setTemp){
194      thermalize();
195    }
# Line 198 | Line 205 | template<typename T> void Integrator<T>::integrate(voi
205    statOut->writeStat(info->getTime());
206  
207  
201
208   #ifdef IS_MPI
209    strcpy(checkPointMsg, "The integrator is ready to go.");
210    MPIcheckPoint();
211   #endif // is_mpi
212  
213 <  while (info->getTime() < runTime){
213 >  while (info->getTime() < runTime && !stopIntegrator()){
214      if ((info->getTime() + dt) >= currStatus){
215        calcPot = 1;
216        calcStress = 1;
217      }
218  
219 + #ifdef PROFILE
220 +    startProfile( pro1 );
221 + #endif
222 +    
223      integrateStep(calcPot, calcStress);
224  
225 + #ifdef PROFILE
226 +    endProfile( pro1 );
227 +
228 +    startProfile( pro2 );
229 + #endif // profile
230 +
231      info->incrTime(dt);
232  
233      if (info->setTemp){
# Line 239 | Line 255 | template<typename T> void Integrator<T>::integrate(voi
255          currReset += resetTime;
256        }
257      }
258 +    
259 + #ifdef PROFILE
260 +    endProfile( pro2 );
261 + #endif //profile
262  
263   #ifdef IS_MPI
264      strcpy(checkPointMsg, "successfully took a time step.");
# Line 246 | Line 266 | template<typename T> void Integrator<T>::integrate(voi
266   #endif // is_mpi
267    }
268  
249
250  // write the last frame
251  dumpOut->writeDump(info->getTime());
252
269    delete dumpOut;
270    delete statOut;
271   }
# Line 257 | Line 273 | template<typename T> void Integrator<T>::integrateStep
273   template<typename T> void Integrator<T>::integrateStep(int calcPot,
274                                                         int calcStress){
275    // Position full step, and velocity half step
276 +
277 + #ifdef PROFILE
278 +  startProfile(pro3);
279 + #endif //profile
280 +
281    preMove();
282  
283 <  moveA();
283 > #ifdef PROFILE
284 >  endProfile(pro3);
285  
286 +  startProfile(pro4);
287 + #endif // profile
288  
289 +  moveA();
290  
291 + #ifdef PROFILE
292 +  endProfile(pro4);
293 +  
294 +  startProfile(pro5);
295 + #endif//profile
296  
297 +
298   #ifdef IS_MPI
299    strcpy(checkPointMsg, "Succesful moveA\n");
300    MPIcheckPoint();
# Line 279 | Line 310 | template<typename T> void Integrator<T>::integrateStep
310    MPIcheckPoint();
311   #endif // is_mpi
312  
313 + #ifdef PROFILE
314 +  endProfile( pro5 );
315  
316 +  startProfile( pro6 );
317 + #endif //profile
318 +
319    // finish the velocity  half step
320  
321    moveB();
322  
323 + #ifdef PROFILE
324 +  endProfile(pro6);
325 + #endif // profile
326  
288
327   #ifdef IS_MPI
328    strcpy(checkPointMsg, "Succesful moveB\n");
329    MPIcheckPoint();
# Line 294 | Line 332 | template<typename T> void Integrator<T>::moveA(void){
332  
333  
334   template<typename T> void Integrator<T>::moveA(void){
335 <  int i, j;
335 >  size_t i, j;
336    DirectionalAtom* dAtom;
337    double Tb[3], ji[3];
338    double vel[3], pos[3], frc[3];
339    double mass;
340 <
341 <  for (i = 0; i < nAtoms; i++){
342 <    atoms[i]->getVel(vel);
343 <    atoms[i]->getPos(pos);
344 <    atoms[i]->getFrc(frc);
345 <
346 <    mass = atoms[i]->getMass();
340 >
341 >  for (i = 0; i < integrableObjects.size() ; i++){
342 >    integrableObjects[i]->getVel(vel);
343 >    integrableObjects[i]->getPos(pos);
344 >    integrableObjects[i]->getFrc(frc);
345 >    
346 >    mass = integrableObjects[i]->getMass();
347  
348      for (j = 0; j < 3; j++){
349        // velocity half step
# Line 314 | Line 352 | template<typename T> void Integrator<T>::moveA(void){
352        pos[j] += dt * vel[j];
353      }
354  
355 <    atoms[i]->setVel(vel);
356 <    atoms[i]->setPos(pos);
355 >    integrableObjects[i]->setVel(vel);
356 >    integrableObjects[i]->setPos(pos);
357  
358 <    if (atoms[i]->isDirectional()){
321 <      dAtom = (DirectionalAtom *) atoms[i];
358 >    if (integrableObjects[i]->isDirectional()){
359  
360        // get and convert the torque to body frame
361  
362 <      dAtom->getTrq(Tb);
363 <      dAtom->lab2Body(Tb);
362 >      integrableObjects[i]->getTrq(Tb);
363 >      integrableObjects[i]->lab2Body(Tb);
364  
365        // get the angular momentum, and propagate a half step
366  
367 <      dAtom->getJ(ji);
367 >      integrableObjects[i]->getJ(ji);
368  
369        for (j = 0; j < 3; j++)
370          ji[j] += (dt2 * Tb[j]) * eConvert;
371  
372 <      this->rotationPropagation( dAtom, ji );
372 >      this->rotationPropagation( integrableObjects[i], ji );
373  
374 <      dAtom->setJ(ji);
374 >      integrableObjects[i]->setJ(ji);
375      }
376    }
377  
# Line 346 | Line 383 | template<typename T> void Integrator<T>::moveB(void){
383  
384   template<typename T> void Integrator<T>::moveB(void){
385    int i, j;
349  DirectionalAtom* dAtom;
386    double Tb[3], ji[3];
387    double vel[3], frc[3];
388    double mass;
389  
390 <  for (i = 0; i < nAtoms; i++){
391 <    atoms[i]->getVel(vel);
392 <    atoms[i]->getFrc(frc);
390 >  for (i = 0; i < integrableObjects.size(); i++){
391 >    integrableObjects[i]->getVel(vel);
392 >    integrableObjects[i]->getFrc(frc);
393  
394 <    mass = atoms[i]->getMass();
394 >    mass = integrableObjects[i]->getMass();
395  
396      // velocity half step
397      for (j = 0; j < 3; j++)
398        vel[j] += (dt2 * frc[j] / mass) * eConvert;
399  
400 <    atoms[i]->setVel(vel);
400 >    integrableObjects[i]->setVel(vel);
401  
402 <    if (atoms[i]->isDirectional()){
367 <      dAtom = (DirectionalAtom *) atoms[i];
402 >    if (integrableObjects[i]->isDirectional()){
403  
404        // get and convert the torque to body frame
405  
406 <      dAtom->getTrq(Tb);
407 <      dAtom->lab2Body(Tb);
406 >      integrableObjects[i]->getTrq(Tb);
407 >      integrableObjects[i]->lab2Body(Tb);
408  
409        // get the angular momentum, and propagate a half step
410  
411 <      dAtom->getJ(ji);
411 >      integrableObjects[i]->getJ(ji);
412  
413        for (j = 0; j < 3; j++)
414          ji[j] += (dt2 * Tb[j]) * eConvert;
415  
416  
417 <      dAtom->setJ(ji);
417 >      integrableObjects[i]->setJ(ji);
418      }
419    }
420  
# Line 648 | Line 683 | template<typename T> void Integrator<T>::rotationPropa
683   }
684  
685   template<typename T> void Integrator<T>::rotationPropagation
686 < ( DirectionalAtom* dAtom, double ji[3] ){
686 > ( StuntDouble* sd, double ji[3] ){
687  
688    double angle;
689    double A[3][3], I[3][3];
690 +  int i, j, k;
691  
692    // use the angular velocities to propagate the rotation matrix a
693    // full time step
694  
695 <  dAtom->getA(A);
696 <  dAtom->getI(I);
695 >  sd->getA(A);
696 >  sd->getI(I);
697  
698 +  if (sd->isLinear()) {
699 +    i = sd->linearAxis();
700 +    j = (i+1)%3;
701 +    k = (i+2)%3;
702 +    
703 +    angle = dt2 * ji[j] / I[j][j];
704 +    this->rotate( k, i, angle, ji, A );
705 +
706 +    angle = dt * ji[k] / I[k][k];
707 +    this->rotate( i, j, angle, ji, A);
708 +
709 +    angle = dt2 * ji[j] / I[j][j];
710 +    this->rotate( k, i, angle, ji, A );
711 +
712 +  } else {
713    // rotate about the x-axis
714    angle = dt2 * ji[0] / I[0][0];
715    this->rotate( 1, 2, angle, ji, A );
# Line 679 | Line 730 | template<typename T> void Integrator<T>::rotationPropa
730    angle = dt2 * ji[0] / I[0][0];
731    this->rotate( 1, 2, angle, ji, A );
732  
733 <  dAtom->setA( A  );
733 >  }
734 >  sd->setA( A  );
735   }
736  
737   template<typename T> void Integrator<T>::rotate(int axes1, int axes2,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines