--- trunk/OOPSE/libmdtools/NPTfm.cpp 2003/07/15 03:28:05 606 +++ trunk/OOPSE/libmdtools/NPTfm.cpp 2003/07/15 19:56:08 617 @@ -1,3 +1,4 @@ +#include #include "Atom.hpp" #include "Molecule.hpp" #include "SRI.hpp" @@ -51,7 +52,7 @@ void NPTfm::moveA() { double instaTemp, instaPress, instaVol; double tt2, tb2; double sc[3]; - double eta2ij; + double eta2ij, smallScale, bigScale, offDiagMax; double press[3][3], vScale[3][3], hm[3][3], hmnew[3][3], scaleMat[3][3]; int nInMol; @@ -127,6 +128,8 @@ void NPTfm::moveA() { for (k = 0; k < 3; k++ ) pos[k] += dt * (vel[k] + sc[k]); + + myAtoms[j]->setPos( pos ); if( myAtoms[j]->isDirectional() ){ @@ -183,6 +186,10 @@ void NPTfm::moveA() { // Hmat = Hmat . ( Ident + dt * etaMat + dt^2 * etaMat*etaMat / 2) + bigScale = 1.0; + smallScale = 1.0; + offDiagMax = 0.0; + for(i=0; i<3; i++){ for(j=0; j<3; j++){ @@ -199,14 +206,44 @@ void NPTfm::moveA() { if (i == j) scaleMat[i][j] = 1.0; // Taylor expansion for the exponential truncated at second order: scaleMat[i][j] += dt*eta[i][j] + 0.5*dt*dt*eta2ij; - + + if (i != j) + if (fabs(scaleMat[i][j]) > offDiagMax) + offDiagMax = fabs(scaleMat[i][j]); } + if (scaleMat[i][i] > bigScale) bigScale = scaleMat[i][i]; + if (scaleMat[i][i] < smallScale) smallScale = scaleMat[i][i]; } - info->getBoxM(hm); - info->matMul3(hm, scaleMat, hmnew); - info->setBoxM(hmnew); - + if ((bigScale > 1.1) || (smallScale < 0.9)) { + sprintf( painCave.errMsg, + "NPTf error: Attempting a Box scaling of more than 10 percent.\n" + " Check your tauBarostat, as it is probably too small!\n\n" + " scaleMat = [%lf\t%lf\t%lf]\n" + " [%lf\t%lf\t%lf]\n" + " [%lf\t%lf\t%lf]\n", + scaleMat[0][0],scaleMat[0][1],scaleMat[0][2], + scaleMat[1][0],scaleMat[1][1],scaleMat[1][2], + scaleMat[2][0],scaleMat[2][1],scaleMat[2][2]); + painCave.isFatal = 1; + simError(); + } else if (offDiagMax > 0.1) { + sprintf( painCave.errMsg, + "NPTf error: Attempting an off-diagonal Box scaling of more than 10 percent.\n" + " Check your tauBarostat, as it is probably too small!\n\n" + " scaleMat = [%lf\t%lf\t%lf]\n" + " [%lf\t%lf\t%lf]\n" + " [%lf\t%lf\t%lf]\n", + scaleMat[0][0],scaleMat[0][1],scaleMat[0][2], + scaleMat[1][0],scaleMat[1][1],scaleMat[1][2], + scaleMat[2][0],scaleMat[2][1],scaleMat[2][2]); + painCave.isFatal = 1; + simError(); + } else { + info->getBoxM(hm); + info->matMul3(hm, scaleMat, hmnew); + info->setBoxM(hmnew); + } } void NPTfm::moveB( void ){