ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/NPTi.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/NPTi.cpp (file contents):
Revision 770 by gezelter, Fri Sep 19 14:55:41 2003 UTC vs.
Revision 772 by gezelter, Fri Sep 19 16:01:07 2003 UTC

# Line 13 | Line 13
13   #include "mpiSimulation.hpp"
14   #endif
15  
16
16   // Basic isotropic thermostating and barostating via the Melchionna
17   // modification of the Hoover algorithm:
18   //
# Line 88 | Line 87 | template<typename T> void NPTi<T>::moveA() {
87      mass = atoms[i]->getMass();
88  
89      for (j=0; j < 3; j++) {
90 <      // velocity half step  (use chi from previous step here):
90 >      // velocity half step
91        vel[j] += dt2 * ((frc[j] / mass ) * eConvert - vel[j]*(chi + eta));
93  
92      }
93  
94      atoms[i]->setVel( vel );
# Line 142 | Line 140 | template<typename T> void NPTi<T>::moveA() {
140      }    
141    }
142  
143 <  // evolve chi and eta  half step
143 >  // advance chi half step
144    
145    chi += dt2 * ( instaTemp / targetTemp - 1.0) / tt2;
148  eta += dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2));
146  
147 <  //calculate the integral of chidt
147 >  // calculate the integral of chidt
148 >
149    integralOfChidt += dt2*chi;
150  
151 +  // advance eta half step
152 +
153 +  eta += dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2));
154 +
155    //save the old positions
156    for(i = 0; i < nAtoms; i++){
157      atoms[i]->getPos(pos);
# Line 208 | Line 210 | template<typename T> void NPTi<T>::moveB( void ){
210    double vel[3], frc[3];
211    double mass;
212  
213 <  double instTemp, instPress, instVol;
213 >  double instaTemp, instaPress, instaVol;
214    double tt2, tb2;
215    double oldChi, prevChi;
216 <  double oldEta, preEta;
216 >  double oldEta, prevEta;
217    
218    tt2 = tauThermostat * tauThermostat;
219    tb2 = tauBarostat * tauBarostat;
# Line 242 | Line 244 | template<typename T> void NPTi<T>::moveB( void ){
244  
245    // do the iteration:
246  
247 <  instVol = tStats->getVolume();
247 >  instaVol = tStats->getVolume();
248    
249    for (k=0; k < 4; k++) {
250      
251 <    instTemp = tStats->getTemperature();
252 <    instPress = tStats->getPressure();
251 >    instaTemp = tStats->getTemperature();
252 >    instaPress = tStats->getPressure();
253  
254      // evolve chi another half step using the temperature at t + dt/2
255  
256      prevChi = chi;
257 <    chi = oldChi + dt2 * ( instTemp / targetTemp - 1.0) /
256 <      (tauThermostat*tauThermostat);
257 >    chi = oldChi + dt2 * ( instaTemp / targetTemp - 1.0) / tt2;
258  
259 <    preEta = eta;
260 <    eta = oldEta + dt2 * ( instVol * (instPress - targetPressure) /
259 >    prevEta = eta;
260 >
261 >    // advance eta half step and calculate scale factor for velocity
262 >
263 >    eta = oldEta + dt2 * ( instaVol * (instaPress - targetPressure) /
264         (p_convert*NkBT*tb2));
265  
266    
# Line 294 | Line 298 | template<typename T> void NPTi<T>::moveB( void ){
298      }    
299      
300      if (fabs(prevChi - chi) <=
301 <        chiTolerance && fabs(preEta -eta) <= etaTolerance)
301 >        chiTolerance && fabs(prevEta -eta) <= etaTolerance)
302        break;
303    }
304  
305 <  //calculate integral of chida
305 >  //calculate integral of chidt
306    integralOfChidt += dt2*chi;
307  
304
308   }
309  
310   template<typename T> void NPTi<T>::resetIntegrator() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines