--- trunk/OOPSE/libmdtools/SimInfo.cpp 2003/09/22 23:07:57 781 +++ 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; @@ -94,8 +96,7 @@ void SimInfo::setBoxM( double theBox[3][3] ){ void SimInfo::setBoxM( double theBox[3][3] ){ - int i, j, status; - double smallestBoxL, maxCutoff; + int i, j; double FortranHmat[9]; // to preserve compatibility with Fortran the // ordering in the array is as follows: // [ 0 3 6 ] @@ -147,6 +148,7 @@ void SimInfo::calcHmatInv( void ) { void SimInfo::calcHmatInv( void ) { + int oldOrtho; int i,j; double smallDiag; double tol; @@ -154,27 +156,43 @@ 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(); + } } } @@ -302,7 +320,6 @@ void SimInfo::calcBoxL( void ){ void SimInfo::calcBoxL( void ){ double dx, dy, dz, dsq; - int i; // boxVol = Determinant of Hmat @@ -372,7 +389,7 @@ void SimInfo::wrapVector( double thePos[3] ){ void SimInfo::wrapVector( double thePos[3] ){ - int i, j, k; + int i; double scaled[3]; if( !orthoRhombic ){ @@ -410,7 +427,7 @@ int SimInfo::getNDF(){ int SimInfo::getNDF(){ - int ndf_local, ndf; + int ndf_local; ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints; @@ -426,7 +443,7 @@ int SimInfo::getNDFraw() { } int SimInfo::getNDFraw() { - int ndfRaw_local, ndfRaw; + int ndfRaw_local; // Raw degrees of freedom that we have to set ndfRaw_local = 3 * n_atoms + 3 * n_oriented; @@ -441,7 +458,7 @@ int SimInfo::getNDFtranslational() { } int SimInfo::getNDFtranslational() { - int ndfTrans_local, ndfTrans; + int ndfTrans_local; ndfTrans_local = 3 * n_atoms - n_constraints; @@ -517,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; @@ -610,7 +646,6 @@ void SimInfo::checkCutOffs( void ){ ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; if( cutChanged ){ - notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); }