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 829 by gezelter, Tue Oct 28 16:03:37 2003 UTC vs.
Revision 1057 by tim, Tue Feb 17 19:23:44 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 25 | Line 29 | template<typename T> Integrator<T>::Integrator(SimInfo
29    if (info->the_integrator != NULL){
30      delete info->the_integrator;
31    }
32 <  
32 >
33    nAtoms = info->n_atoms;
34  
35    // check for constraints
# Line 64 | Line 68 | template<typename T> void Integrator<T>::checkConstrai
68  
69    SRI** theArray;
70    for (int i = 0; i < nMols; i++){
71 <    theArray = (SRI * *) molecules[i].getMyBonds();
71 >
72 >          theArray = (SRI * *) molecules[i].getMyBonds();
73      for (int j = 0; j < molecules[i].getNBonds(); j++){
74        constrained = theArray[j]->is_constrained();
75  
# Line 110 | Line 115 | template<typename T> void Integrator<T>::checkConstrai
115      }
116    }
117  
118 +
119    if (nConstrained > 0){
120      isConstrained = 1;
121  
# Line 131 | Line 137 | template<typename T> void Integrator<T>::checkConstrai
137      }
138  
139  
140 <    // save oldAtoms to check for lode balanceing later on.
140 >    // save oldAtoms to check for lode balancing later on.
141  
142      oldAtoms = nAtoms;
143  
# Line 158 | Line 164 | template<typename T> void Integrator<T>::integrate(voi
164    double currThermal;
165    double currStatus;
166    double currReset;
167 <  
167 >
168    int calcPot, calcStress;
169  
170    tStats = new Thermo(info);
# Line 176 | Line 182 | template<typename T> void Integrator<T>::integrate(voi
182  
183    calcForce(1, 1);
184  
185 +  //temp test
186 +  tStats->getPotential();
187 +  
188    if (nConstrained){
189      preMove();
190      constrainA();
191 <    calcForce(1, 1);    
191 >    calcForce(1, 1);
192      constrainB();
193    }
194    
# Line 198 | Line 207 | template<typename T> void Integrator<T>::integrate(voi
207    statOut->writeStat(info->getTime());
208  
209  
201
210   #ifdef IS_MPI
211    strcpy(checkPointMsg, "The integrator is ready to go.");
212    MPIcheckPoint();
# Line 210 | Line 218 | template<typename T> void Integrator<T>::integrate(voi
218        calcStress = 1;
219      }
220  
221 + #ifdef PROFILE
222 +    startProfile( pro1 );
223 + #endif
224 +    
225      integrateStep(calcPot, calcStress);
226 +
227 + #ifdef PROFILE
228 +    endProfile( pro1 );
229  
230 +    startProfile( pro2 );
231 + #endif // profile
232 +
233      info->incrTime(dt);
234  
235      if (info->setTemp){
# Line 227 | Line 245 | template<typename T> void Integrator<T>::integrate(voi
245      }
246  
247      if (info->getTime() >= currStatus){
248 <      statOut->writeStat(info->getTime());
249 <      calcPot = 0;
248 >      statOut->writeStat(info->getTime());
249 >      calcPot = 0;
250        calcStress = 0;
251        currStatus += statusTime;
252 <    }
252 >    }
253  
254      if (info->resetIntegrator){
255        if (info->getTime() >= currReset){
# Line 239 | Line 257 | template<typename T> void Integrator<T>::integrate(voi
257          currReset += resetTime;
258        }
259      }
260 +    
261 + #ifdef PROFILE
262 +    endProfile( pro2 );
263 + #endif //profile
264  
265   #ifdef IS_MPI
266      strcpy(checkPointMsg, "successfully took a time step.");
# Line 246 | Line 268 | template<typename T> void Integrator<T>::integrate(voi
268   #endif // is_mpi
269    }
270  
249
250  // write the last frame
251  dumpOut->writeDump(info->getTime());
252
271    delete dumpOut;
272    delete statOut;
273   }
# Line 257 | Line 275 | template<typename T> void Integrator<T>::integrateStep
275   template<typename T> void Integrator<T>::integrateStep(int calcPot,
276                                                         int calcStress){
277    // Position full step, and velocity half step
278 +
279 + #ifdef PROFILE
280 +  startProfile(pro3);
281 + #endif //profile
282 +
283    preMove();
284  
285 <  moveA();
285 > #ifdef PROFILE
286 >  endProfile(pro3);
287  
288 +  startProfile(pro4);
289 + #endif // profile
290  
291 +  moveA();
292  
293 + #ifdef PROFILE
294 +  endProfile(pro4);
295 +  
296 +  startProfile(pro5);
297 + #endif//profile
298  
299 +
300   #ifdef IS_MPI
301    strcpy(checkPointMsg, "Succesful moveA\n");
302    MPIcheckPoint();
# Line 279 | Line 312 | template<typename T> void Integrator<T>::integrateStep
312    MPIcheckPoint();
313   #endif // is_mpi
314  
315 + #ifdef PROFILE
316 +  endProfile( pro5 );
317  
318 +  startProfile( pro6 );
319 + #endif //profile
320 +
321    // finish the velocity  half step
322  
323    moveB();
324  
325 <
325 > #ifdef PROFILE
326 >  endProfile(pro6);
327 > #endif // profile
328  
329   #ifdef IS_MPI
330    strcpy(checkPointMsg, "Succesful moveB\n");
# Line 366 | Line 406 | template<typename T> void Integrator<T>::moveB(void){
406      if (atoms[i]->isDirectional()){
407        dAtom = (DirectionalAtom *) atoms[i];
408  
409 <      // get and convert the torque to body frame      
409 >      // get and convert the torque to body frame
410  
411        dAtom->getTrq(Tb);
412        dAtom->lab2Body(Tb);
# Line 658 | Line 698 | template<typename T> void Integrator<T>::rotationPropa
698  
699    dAtom->getA(A);
700    dAtom->getI(I);
701 <  
702 <  // rotate about the x-axis      
701 >
702 >  // rotate about the x-axis
703    angle = dt2 * ji[0] / I[0][0];
704 <  this->rotate( 1, 2, angle, ji, A );
705 <  
704 >  this->rotate( 1, 2, angle, ji, A );
705 >
706    // rotate about the y-axis
707    angle = dt2 * ji[1] / I[1][1];
708    this->rotate( 2, 0, angle, ji, A );
709 <  
709 >
710    // rotate about the z-axis
711    angle = dt * ji[2] / I[2][2];
712    this->rotate( 0, 1, angle, ji, A);
713 <  
713 >
714    // rotate about the y-axis
715    angle = dt2 * ji[1] / I[1][1];
716    this->rotate( 2, 0, angle, ji, A );
717 <  
717 >
718    // rotate about the x-axis
719    angle = dt2 * ji[0] / I[0][0];
720    this->rotate( 1, 2, angle, ji, A );
721 <  
722 <  dAtom->setA( A  );    
721 >
722 >  dAtom->setA( A  );
723   }
724  
725   template<typename T> void Integrator<T>::rotate(int axes1, int axes2,
# Line 747 | Line 787 | template<typename T> void Integrator<T>::rotate(int ax
787      }
788    }
789  
790 <  // rotate the Rotation matrix acording to:
790 >  // rotate the Rotation matrix acording to:
791    //            A[][] = A[][] * transpose(rot[][])
792  
793  
# Line 776 | Line 816 | template<typename T> double Integrator<T>::getConserve
816   template<typename T> double Integrator<T>::getConservedQuantity(void){
817    return tStats->getTotalE();
818   }
819 + template<typename T> string Integrator<T>::getAdditionalParameters(void){
820 +  //By default, return a null string
821 +  //The reason we use string instead of char* is that if we use char*, we will
822 +  //return a pointer point to local variable which might cause problem
823 +  return string();
824 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines