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 781 by tim, Mon Sep 22 23:07:57 2003 UTC vs.
Revision 1057 by tim, Tue Feb 17 19:23:44 2004 UTC

# Line 1 | Line 1
1   #include <iostream>
2 < #include <cstdlib>
3 < #include <cmath>
2 > #include <stdlib.h>
3 > #include <math.h>
4  
5   #ifdef IS_MPI
6   #include "mpiSimulation.hpp"
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    }
28  info->the_integrator = this;
32  
33    nAtoms = info->n_atoms;
34  
# Line 65 | 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 111 | Line 115 | template<typename T> void Integrator<T>::checkConstrai
115      }
116    }
117  
118 +
119    if (nConstrained > 0){
120      isConstrained = 1;
121  
# Line 132 | 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 147 | Line 152 | template<typename T> void Integrator<T>::integrate(voi
152  
153  
154   template<typename T> void Integrator<T>::integrate(void){
150  int i, j;                         // loop counters
155  
156    double runTime = info->run_time;
157    double sampleTime = info->sampleTime;
# Line 160 | 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;
165  int isError;
169  
170    tStats = new Thermo(info);
171    statOut = new StatWriter(info);
172    dumpOut = new DumpWriter(info);
173  
174    atoms = info->atoms;
172  DirectionalAtom* dAtom;
175  
176    dt = info->dt;
177    dt2 = 0.5 * dt;
178  
179 +  readyCheck();
180 +
181    // initialize the forces before the first step
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 199 | Line 206 | template<typename T> void Integrator<T>::integrate(voi
206    dumpOut->writeDump(info->getTime());
207    statOut->writeStat(info->getTime());
208  
202  readyCheck();
209  
210   #ifdef IS_MPI
211    strcpy(checkPointMsg, "The integrator is ready to go.");
# Line 212 | 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 229 | 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 241 | 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 248 | Line 268 | template<typename T> void Integrator<T>::integrate(voi
268   #endif // is_mpi
269    }
270  
251  dumpOut->writeFinal(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 + #ifdef PROFILE
326 +  endProfile(pro6);
327 + #endif // profile
328  
288
329   #ifdef IS_MPI
330    strcpy(checkPointMsg, "Succesful moveB\n");
331    MPIcheckPoint();
# 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 404 | Line 444 | template<typename T> void Integrator<T>::constrainA(){
444   }
445  
446   template<typename T> void Integrator<T>::constrainA(){
447 <  int i, j, k;
447 >  int i, j;
448    int done;
449    double posA[3], posB[3];
450    double velA[3], velB[3];
# Line 548 | Line 588 | template<typename T> void Integrator<T>::constrainB(vo
588   }
589  
590   template<typename T> void Integrator<T>::constrainB(void){
591 <  int i, j, k;
591 >  int i, j;
592    int done;
593    double posA[3], posB[3];
594    double velA[3], velB[3];
# Line 557 | Line 597 | template<typename T> void Integrator<T>::constrainB(vo
597    int a, b, ax, ay, az, bx, by, bz;
598    double rma, rmb;
599    double dx, dy, dz;
600 <  double rabsq, pabsq, rvab;
561 <  double diffsq;
600 >  double rvab;
601    double gab;
602    int iteration;
603  
# Line 659 | 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 748 | 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 777 | 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