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 1118 by tim, Mon Apr 19 03:52:27 2004 UTC vs.
Revision 1234 by tim, Fri Jun 4 03:15:31 2004 UTC

# Line 1 | Line 1
1   #include <iostream>
2   #include <stdlib.h>
3   #include <math.h>
4 <
4 > #include "Rattle.hpp"
5   #ifdef IS_MPI
6   #include "mpiSimulation.hpp"
7   #include <unistd.h>
# Line 33 | Line 33 | template<typename T> Integrator<T>::Integrator(SimInfo
33    nAtoms = info->n_atoms;
34    integrableObjects = info->integrableObjects;
35  
36 +  rattle = new RattleFramework(info);
37 +
38 +  if(rattle == NULL){
39 +    sprintf(painCave.errMsg,
40 +      "Integrator::Intergrator() Error: Memory allocation error for RattleFramework" );
41 +    painCave.isFatal = 1;
42 +    simError();
43 +  }
44 +  
45 + /*
46    // check for constraints
47  
48    constrainedA = NULL;
# Line 45 | Line 55 | template<typename T> Integrator<T>::Integrator(SimInfo
55    nConstrained = 0;
56  
57    checkConstraints();
58 + */
59   }
60  
61   template<typename T> Integrator<T>::~Integrator(){
62 +  if (rattle != NULL)
63 +    delete rattle;
64 + /*
65    if (nConstrained){
66      delete[] constrainedA;
67      delete[] constrainedB;
# Line 56 | Line 70 | template<typename T> Integrator<T>::~Integrator(){
70      delete[] moved;
71      delete[] oldPos;
72    }
73 + */
74   }
75  
76 + /*
77   template<typename T> void Integrator<T>::checkConstraints(void){
78    isConstrained = 0;
79  
# Line 150 | Line 166 | template<typename T> void Integrator<T>::checkConstrai
166  
167    delete[] temp_con;
168   }
169 + */
170  
154
171   template<typename T> void Integrator<T>::integrate(void){
172  
173    double runTime = info->run_time;
# Line 160 | Line 176 | template<typename T> void Integrator<T>::integrate(voi
176    double thermalTime = info->thermalTime;
177    double resetTime = info->resetTime;
178  
179 <
179 >  double difference;
180    double currSample;
181    double currThermal;
182    double currStatus;
# Line 179 | Line 195 | template<typename T> void Integrator<T>::integrate(voi
195  
196    readyCheck();
197  
198 +  // remove center of mass drift velocity (in case we passed in a configuration
199 +  // that was drifting
200 +  tStats->removeCOMdrift();
201 +
202 +  // initialize the retraints if necessary
203 +  if (info->useSolidThermInt && !info->useLiquidThermInt) {
204 +    myFF->initRestraints();
205 +  }
206 +
207    // initialize the forces before the first step
208  
209    calcForce(1, 1);
210 +
211 +  //execute constraint algorithm to make sure at the very beginning the system is constrained  
212 +  rattle->doPreConstraint();
213 +  rattle->doRattleA();
214 +  calcForce(1, 1);
215 +  rattle->doRattleB();
216    
186  if (nConstrained){
187    preMove();
188    constrainA();
189    calcForce(1, 1);
190    constrainB();
191  }
192  
217    if (info->setTemp){
218      thermalize();
219    }
# Line 211 | Line 235 | template<typename T> void Integrator<T>::integrate(voi
235   #endif // is_mpi
236  
237    while (info->getTime() < runTime && !stopIntegrator()){
238 <    if ((info->getTime() + dt) >= currStatus){
238 >    difference = info->getTime() + dt - currStatus;
239 >    if (difference > 0 || fabs(difference) < 1e-4 ){
240        calcPot = 1;
241        calcStress = 1;
242      }
# Line 266 | Line 291 | template<typename T> void Integrator<T>::integrate(voi
291   #endif // is_mpi
292    }
293  
294 +  // dump out a file containing the omega values for the final configuration
295 +  if (info->useSolidThermInt && !info->useLiquidThermInt)
296 +    myFF->dumpzAngle();
297 +  
298 +
299    delete dumpOut;
300    delete statOut;
301   }
# Line 278 | Line 308 | template<typename T> void Integrator<T>::integrateStep
308    startProfile(pro3);
309   #endif //profile
310  
311 <  preMove();
311 >  //save old state (position, velocity etc)
312 >  rattle->doPreConstraint();
313  
314   #ifdef PROFILE
315    endProfile(pro3);
# Line 300 | Line 331 | template<typename T> void Integrator<T>::integrateStep
331    MPIcheckPoint();
332   #endif // is_mpi
333  
303
334    // calc forces
305
335    calcForce(calcPot, calcStress);
336  
337   #ifdef IS_MPI
# Line 337 | Line 366 | template<typename T> void Integrator<T>::moveA(void){
366    double Tb[3], ji[3];
367    double vel[3], pos[3], frc[3];
368    double mass;
369 +  double omega;
370  
371    for (i = 0; i < integrableObjects.size() ; i++){
372      integrableObjects[i]->getVel(vel);
# Line 375 | Line 405 | template<typename T> void Integrator<T>::moveA(void){
405      }
406    }
407  
408 <  if (nConstrained){
379 <    constrainA();
380 <  }
408 >  rattle->doRattleA();
409   }
410  
411  
# Line 418 | Line 446 | template<typename T> void Integrator<T>::moveB(void){
446      }
447    }
448  
449 <  if (nConstrained){
422 <    constrainB();
423 <  }
449 >  rattle->doRattleB();
450   }
451  
452 + /*
453   template<typename T> void Integrator<T>::preMove(void){
454    int i, j;
455    double pos[3];
# Line 681 | Line 708 | template<typename T> void Integrator<T>::constrainB(vo
708      simError();
709    }
710   }
711 <
711 > */
712   template<typename T> void Integrator<T>::rotationPropagation
713   ( StuntDouble* sd, double ji[3] ){
714  
# Line 710 | Line 737 | template<typename T> void Integrator<T>::rotationPropa
737      this->rotate( k, i, angle, ji, A );
738  
739    } else {
740 <  // rotate about the x-axis
741 <  angle = dt2 * ji[0] / I[0][0];
742 <  this->rotate( 1, 2, angle, ji, A );
743 <
744 <  // rotate about the y-axis
745 <  angle = dt2 * ji[1] / I[1][1];
746 <  this->rotate( 2, 0, angle, ji, A );
747 <
748 <  // rotate about the z-axis
749 <  angle = dt * ji[2] / I[2][2];
750 <  this->rotate( 0, 1, angle, ji, A);
751 <
752 <  // rotate about the y-axis
753 <  angle = dt2 * ji[1] / I[1][1];
754 <  this->rotate( 2, 0, angle, ji, A );
755 <
756 <  // rotate about the x-axis
757 <  angle = dt2 * ji[0] / I[0][0];
758 <  this->rotate( 1, 2, angle, ji, A );
759 <
740 >    // rotate about the x-axis
741 >    angle = dt2 * ji[0] / I[0][0];
742 >    this->rotate( 1, 2, angle, ji, A );
743 >    
744 >    // rotate about the y-axis
745 >    angle = dt2 * ji[1] / I[1][1];
746 >    this->rotate( 2, 0, angle, ji, A );
747 >    
748 >    // rotate about the z-axis
749 >    angle = dt * ji[2] / I[2][2];
750 >    sd->addZangle(angle);
751 >    this->rotate( 0, 1, angle, ji, A);
752 >    
753 >    // rotate about the y-axis
754 >    angle = dt2 * ji[1] / I[1][1];
755 >    this->rotate( 2, 0, angle, ji, A );
756 >    
757 >    // rotate about the x-axis
758 >    angle = dt2 * ji[0] / I[0][0];
759 >    this->rotate( 1, 2, angle, ji, A );
760 >    
761    }
762    sd->setA( A  );
763   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines