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 841 by mmeineke, Wed Oct 29 17:55:28 2003 UTC vs.
Revision 1097 by gezelter, Mon Apr 12 20:32:20 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 174 | Line 181 | template<typename T> void Integrator<T>::integrate(voi
181  
182    // initialize the forces before the first step
183  
177  std::cerr << "Before initial Force calc\n";
178
184    calcForce(1, 1);
185  
186 +  //temp test
187 +  tStats->getPotential();
188 +  
189    if (nConstrained){
190      preMove();
191      constrainA();
192      calcForce(1, 1);
193      constrainB();
186    std::cerr << "premove done\n";
194    }
195 <
189 <
190 <
195 >  
196    if (info->setTemp){
197      thermalize();
198    }
# Line 203 | Line 208 | template<typename T> void Integrator<T>::integrate(voi
208    statOut->writeStat(info->getTime());
209  
210  
206
211   #ifdef IS_MPI
212    strcpy(checkPointMsg, "The integrator is ready to go.");
213    MPIcheckPoint();
# Line 215 | Line 219 | template<typename T> void Integrator<T>::integrate(voi
219        calcStress = 1;
220      }
221  
222 + #ifdef PROFILE
223 +    startProfile( pro1 );
224 + #endif
225 +    
226      integrateStep(calcPot, calcStress);
227  
228 + #ifdef PROFILE
229 +    endProfile( pro1 );
230 +
231 +    startProfile( pro2 );
232 + #endif // profile
233 +
234      info->incrTime(dt);
235  
236      if (info->setTemp){
# Line 244 | Line 258 | template<typename T> void Integrator<T>::integrate(voi
258          currReset += resetTime;
259        }
260      }
261 <
262 <    std::cerr << "done with time = " << info->getTime() << "\n";
261 >    
262 > #ifdef PROFILE
263 >    endProfile( pro2 );
264 > #endif //profile
265  
266   #ifdef IS_MPI
267      strcpy(checkPointMsg, "successfully took a time step.");
# Line 253 | Line 269 | template<typename T> void Integrator<T>::integrate(voi
269   #endif // is_mpi
270    }
271  
256
257  // write the last frame
258  dumpOut->writeDump(info->getTime());
259
272    delete dumpOut;
273    delete statOut;
274   }
# Line 264 | Line 276 | template<typename T> void Integrator<T>::integrateStep
276   template<typename T> void Integrator<T>::integrateStep(int calcPot,
277                                                         int calcStress){
278    // Position full step, and velocity half step
279 +
280 + #ifdef PROFILE
281 +  startProfile(pro3);
282 + #endif //profile
283 +
284    preMove();
285  
286 <  moveA();
286 > #ifdef PROFILE
287 >  endProfile(pro3);
288  
289 +  startProfile(pro4);
290 + #endif // profile
291  
292 +  moveA();
293  
294 + #ifdef PROFILE
295 +  endProfile(pro4);
296 +  
297 +  startProfile(pro5);
298 + #endif//profile
299  
300 +
301   #ifdef IS_MPI
302    strcpy(checkPointMsg, "Succesful moveA\n");
303    MPIcheckPoint();
# Line 286 | Line 313 | template<typename T> void Integrator<T>::integrateStep
313    MPIcheckPoint();
314   #endif // is_mpi
315  
316 + #ifdef PROFILE
317 +  endProfile( pro5 );
318  
319 +  startProfile( pro6 );
320 + #endif //profile
321 +
322    // finish the velocity  half step
323  
324    moveB();
325  
326 + #ifdef PROFILE
327 +  endProfile(pro6);
328 + #endif // profile
329  
295
330   #ifdef IS_MPI
331    strcpy(checkPointMsg, "Succesful moveB\n");
332    MPIcheckPoint();
# Line 301 | Line 335 | template<typename T> void Integrator<T>::moveA(void){
335  
336  
337   template<typename T> void Integrator<T>::moveA(void){
338 <  int i, j;
338 >  size_t i, j;
339    DirectionalAtom* dAtom;
340    double Tb[3], ji[3];
341    double vel[3], pos[3], frc[3];
342    double mass;
343 +
344 +  for (i = 0; i < integrableObjects.size() ; i++){
345 +    integrableObjects[i]->getVel(vel);
346 +    integrableObjects[i]->getPos(pos);
347 +    integrableObjects[i]->getFrc(frc);
348 +    
349 +    mass = integrableObjects[i]->getMass();
350  
310  for (i = 0; i < nAtoms; i++){
311    atoms[i]->getVel(vel);
312    atoms[i]->getPos(pos);
313    atoms[i]->getFrc(frc);
314
315    mass = atoms[i]->getMass();
316
351      for (j = 0; j < 3; j++){
352        // velocity half step
353        vel[j] += (dt2 * frc[j] / mass) * eConvert;
# Line 321 | Line 355 | template<typename T> void Integrator<T>::moveA(void){
355        pos[j] += dt * vel[j];
356      }
357  
358 <    atoms[i]->setVel(vel);
359 <    atoms[i]->setPos(pos);
358 >    integrableObjects[i]->setVel(vel);
359 >    integrableObjects[i]->setPos(pos);
360  
361 <    if (atoms[i]->isDirectional()){
328 <      dAtom = (DirectionalAtom *) atoms[i];
361 >    if (integrableObjects[i]->isDirectional()){
362  
363        // get and convert the torque to body frame
364  
365 <      dAtom->getTrq(Tb);
366 <      dAtom->lab2Body(Tb);
365 >      integrableObjects[i]->getTrq(Tb);
366 >      integrableObjects[i]->lab2Body(Tb);
367  
368        // get the angular momentum, and propagate a half step
369  
370 <      dAtom->getJ(ji);
370 >      integrableObjects[i]->getJ(ji);
371  
372        for (j = 0; j < 3; j++)
373          ji[j] += (dt2 * Tb[j]) * eConvert;
374  
375 <      this->rotationPropagation( dAtom, ji );
375 >      this->rotationPropagation( integrableObjects[i], ji );
376  
377 <      dAtom->setJ(ji);
377 >      integrableObjects[i]->setJ(ji);
378      }
379    }
380  
# Line 353 | Line 386 | template<typename T> void Integrator<T>::moveB(void){
386  
387   template<typename T> void Integrator<T>::moveB(void){
388    int i, j;
356  DirectionalAtom* dAtom;
389    double Tb[3], ji[3];
390    double vel[3], frc[3];
391    double mass;
392  
393 <  for (i = 0; i < nAtoms; i++){
394 <    atoms[i]->getVel(vel);
395 <    atoms[i]->getFrc(frc);
393 >  for (i = 0; i < integrableObjects.size(); i++){
394 >    integrableObjects[i]->getVel(vel);
395 >    integrableObjects[i]->getFrc(frc);
396  
397 <    mass = atoms[i]->getMass();
397 >    mass = integrableObjects[i]->getMass();
398  
399      // velocity half step
400      for (j = 0; j < 3; j++)
401        vel[j] += (dt2 * frc[j] / mass) * eConvert;
402  
403 <    atoms[i]->setVel(vel);
403 >    integrableObjects[i]->setVel(vel);
404  
405 <    if (atoms[i]->isDirectional()){
374 <      dAtom = (DirectionalAtom *) atoms[i];
405 >    if (integrableObjects[i]->isDirectional()){
406  
407        // get and convert the torque to body frame
408  
409 <      dAtom->getTrq(Tb);
410 <      dAtom->lab2Body(Tb);
409 >      integrableObjects[i]->getTrq(Tb);
410 >      integrableObjects[i]->lab2Body(Tb);
411  
412        // get the angular momentum, and propagate a half step
413  
414 <      dAtom->getJ(ji);
414 >      integrableObjects[i]->getJ(ji);
415  
416        for (j = 0; j < 3; j++)
417          ji[j] += (dt2 * Tb[j]) * eConvert;
418  
419  
420 <      dAtom->setJ(ji);
420 >      integrableObjects[i]->setJ(ji);
421      }
422    }
423  
# Line 655 | Line 686 | template<typename T> void Integrator<T>::rotationPropa
686   }
687  
688   template<typename T> void Integrator<T>::rotationPropagation
689 < ( DirectionalAtom* dAtom, double ji[3] ){
689 > ( StuntDouble* sd, double ji[3] ){
690  
691    double angle;
692    double A[3][3], I[3][3];
# Line 663 | Line 694 | template<typename T> void Integrator<T>::rotationPropa
694    // use the angular velocities to propagate the rotation matrix a
695    // full time step
696  
697 <  dAtom->getA(A);
698 <  dAtom->getI(I);
697 >  sd->getA(A);
698 >  sd->getI(I);
699  
700    // rotate about the x-axis
701    angle = dt2 * ji[0] / I[0][0];
# Line 686 | Line 717 | template<typename T> void Integrator<T>::rotationPropa
717    angle = dt2 * ji[0] / I[0][0];
718    this->rotate( 1, 2, angle, ji, A );
719  
720 <  dAtom->setA( A  );
720 >  sd->setA( A  );
721   }
722  
723   template<typename T> void Integrator<T>::rotate(int axes1, int axes2,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines