--- trunk/OOPSE/libmdtools/SimInfo.cpp 2003/09/29 21:16:11 790 +++ trunk/OOPSE/libmdtools/SimInfo.cpp 2003/11/06 22:01:37 855 @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include using namespace std; @@ -49,8 +49,10 @@ SimInfo::SimInfo(){ boxIsInit = 0; resetTime = 1e99; - + orthoTolerance = 1E-6; + useInitXSstate = true; + usePBC = 0; useLJ = 0; useSticky = 0; @@ -146,6 +148,7 @@ void SimInfo::calcHmatInv( void ) { void SimInfo::calcHmatInv( void ) { + int oldOrtho; int i,j; double smallDiag; double tol; @@ -153,28 +156,44 @@ void SimInfo::calcHmatInv( void ) { invertMat3( Hmat, HmatInv ); - // Check the inverse to make sure it is sane: - - matMul3( Hmat, HmatInv, sanity ); - // check to see if Hmat is orthorhombic - smallDiag = Hmat[0][0]; - if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1]; - if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2]; - tol = smallDiag * 1E-6; + oldOrtho = orthoRhombic; + smallDiag = fabs(Hmat[0][0]); + if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]); + if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]); + tol = smallDiag * orthoTolerance; + orthoRhombic = 1; for (i = 0; i < 3; i++ ) { for (j = 0 ; j < 3; j++) { if (i != j) { if (orthoRhombic) { - if (Hmat[i][j] >= tol) orthoRhombic = 0; + if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0; } } } } + + if( oldOrtho != orthoRhombic ){ + + if( orthoRhombic ){ + sprintf( painCave.errMsg, + "Hmat is switching from Non-Orthorhombic to OrthoRhombic\n" + " If this is a bad thing, change the orthoBoxTolerance( currently %G ).\n", + orthoTolerance); + simError(); + } + else { + sprintf( painCave.errMsg, + "Hmat is switching from Orthorhombic to Non-OrthoRhombic\n" + " If this is a bad thing, change the orthoBoxTolerance( currently %G ).\n", + orthoTolerance); + simError(); + } + } } double SimInfo::matDet3(double a[3][3]) { @@ -515,33 +534,52 @@ void SimInfo::setRcut( double theRcut ){ void SimInfo::setRcut( double theRcut ){ - if( !haveOrigRcut ){ - haveOrigRcut = 1; - origRcut = theRcut; - } - rCut = theRcut; checkCutOffs(); } -void SimInfo::setEcr( double theEcr ){ +void SimInfo::setDefaultRcut( double theRcut ){ - if( !haveOrigEcr ){ - haveOrigEcr = 1; - origEcr = theEcr; - } + haveOrigRcut = 1; + origRcut = theRcut; + rCut = theRcut; + ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; + + notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); +} + +void SimInfo::setEcr( double theEcr ){ + ecr = theEcr; checkCutOffs(); } +void SimInfo::setDefaultEcr( double theEcr ){ + + haveOrigEcr = 1; + origEcr = theEcr; + + ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; + + ecr = theEcr; + + notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); +} + void SimInfo::setEcr( double theEcr, double theEst ){ est = theEst; setEcr( theEcr ); } +void SimInfo::setDefaultEcr( double theEcr, double theEst ){ + est = theEst; + setDefaultEcr( theEcr ); +} + + void SimInfo::checkCutOffs( void ){ int cutChanged = 0; @@ -608,7 +646,6 @@ void SimInfo::checkCutOffs( void ){ ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; if( cutChanged ){ - notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); }