--- trunk/OOPSE/libmdtools/NPTi.cpp 2003/09/19 14:55:41 770 +++ trunk/OOPSE/libmdtools/NPTi.cpp 2003/09/19 16:01:07 772 @@ -13,7 +13,6 @@ #include "mpiSimulation.hpp" #endif - // Basic isotropic thermostating and barostating via the Melchionna // modification of the Hoover algorithm: // @@ -88,9 +87,8 @@ template void NPTi::moveA() { mass = atoms[i]->getMass(); for (j=0; j < 3; j++) { - // velocity half step (use chi from previous step here): + // velocity half step vel[j] += dt2 * ((frc[j] / mass ) * eConvert - vel[j]*(chi + eta)); - } atoms[i]->setVel( vel ); @@ -142,14 +140,18 @@ template void NPTi::moveA() { } } - // evolve chi and eta half step + // advance chi half step chi += dt2 * ( instaTemp / targetTemp - 1.0) / tt2; - eta += dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2)); - //calculate the integral of chidt + // calculate the integral of chidt + integralOfChidt += dt2*chi; + // advance eta half step + + eta += dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2)); + //save the old positions for(i = 0; i < nAtoms; i++){ atoms[i]->getPos(pos); @@ -208,10 +210,10 @@ template void NPTi::moveB( void ){ double vel[3], frc[3]; double mass; - double instTemp, instPress, instVol; + double instaTemp, instaPress, instaVol; double tt2, tb2; double oldChi, prevChi; - double oldEta, preEta; + double oldEta, prevEta; tt2 = tauThermostat * tauThermostat; tb2 = tauBarostat * tauBarostat; @@ -242,21 +244,23 @@ template void NPTi::moveB( void ){ // do the iteration: - instVol = tStats->getVolume(); + instaVol = tStats->getVolume(); for (k=0; k < 4; k++) { - instTemp = tStats->getTemperature(); - instPress = tStats->getPressure(); + instaTemp = tStats->getTemperature(); + instaPress = tStats->getPressure(); // evolve chi another half step using the temperature at t + dt/2 prevChi = chi; - chi = oldChi + dt2 * ( instTemp / targetTemp - 1.0) / - (tauThermostat*tauThermostat); + chi = oldChi + dt2 * ( instaTemp / targetTemp - 1.0) / tt2; - preEta = eta; - eta = oldEta + dt2 * ( instVol * (instPress - targetPressure) / + prevEta = eta; + + // advance eta half step and calculate scale factor for velocity + + eta = oldEta + dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2)); @@ -294,14 +298,13 @@ template void NPTi::moveB( void ){ } if (fabs(prevChi - chi) <= - chiTolerance && fabs(preEta -eta) <= etaTolerance) + chiTolerance && fabs(prevEta -eta) <= etaTolerance) break; } - //calculate integral of chida + //calculate integral of chidt integralOfChidt += dt2*chi; - } template void NPTi::resetIntegrator() {