--- trunk/OOPSE/libmdtools/NPTi.cpp 2003/07/14 22:38:13 600 +++ trunk/OOPSE/libmdtools/NPTi.cpp 2003/07/15 19:56:08 617 @@ -42,7 +42,7 @@ void NPTi::moveA() { double rj[3]; double instaTemp, instaPress, instaVol; - double tt2, tb2; + double tt2, tb2, scaleFactor; tt2 = tauThermostat * tauThermostat; tb2 = tauBarostat * tauBarostat; @@ -76,10 +76,8 @@ void NPTi::moveA() { for (j = 0; j < 3; j++) pos[j] += dt * (vel[j] + eta*rj[j]); - atoms[i]->setPos( pos ); - if( atoms[i]->isDirectional() ){ dAtom = (DirectionalAtom *)atoms[i]; @@ -127,12 +125,23 @@ void NPTi::moveA() { } } + // Scale the box after all the positions have been moved: - cerr << "eta = " << eta - << "; exp(dt*eta) = " << exp(eta*dt) << "\n"; - - info->scaleBox(exp(dt*eta)); + scaleFactor = exp(dt*eta); + + if ((scaleFactor > 1.1) || (scaleFactor < 0.9)) { + sprintf( painCave.errMsg, + "NPTi error: Attempting a Box scaling of more than 10 percent" + " check your tauBarostat, as it is probably too small!\n" + " eta = %lf, scaleFactor = %lf\n", eta, scaleFactor + ); + painCave.isFatal = 1; + simError(); + } else { + info->scaleBox(exp(dt*eta)); + } + } void NPTi::moveB( void ){