--- trunk/OOPSE/libmdtools/NPTi.cpp 2003/07/14 22:38:13 600 +++ trunk/OOPSE/libmdtools/NPTi.cpp 2003/07/31 15:35:07 658 @@ -20,8 +20,8 @@ // // Hoover, W. G., 1986, Phys. Rev. A, 34, 2499. -NPTi::NPTi ( SimInfo *theInfo, ForceFields* the_ff): - Integrator( theInfo, the_ff ) +template NPTi::NPTi ( SimInfo *theInfo, ForceFields* the_ff): + T( theInfo, the_ff ) { chi = 0.0; eta = 0.0; @@ -31,7 +31,7 @@ NPTi::NPTi ( SimInfo *theInfo, ForceFields* the_ff): have_target_pressure = 0; } -void NPTi::moveA() { +template void NPTi::moveA() { int i, j; DirectionalAtom* dAtom; @@ -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,15 +125,26 @@ 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 ){ +template void NPTi::moveB( void ){ int i, j; DirectionalAtom* dAtom; @@ -191,7 +200,11 @@ void NPTi::moveB( void ){ } } -int NPTi::readyCheck() { +template int NPTi::readyCheck() { + + //check parent's readyCheck() first + if (T::readyCheck() == -1) + return -1; // First check to see if we have a target temperature. // Not having one is fatal.