--- trunk/OOPSE/libmdtools/SimInfo.cpp 2003/04/04 19:47:19 458 +++ trunk/OOPSE/libmdtools/SimInfo.cpp 2003/04/05 03:39:25 463 @@ -35,10 +35,56 @@ void SimInfo::setBox(double newBox[3]) { } void SimInfo::setBox(double newBox[3]) { + double smallestBox, maxCutoff; + int status; box_x = newBox[0]; box_y = newBox[1]; box_z = newBox[2]; setFortranBoxSize(newBox); + + smallestBox = box_x; + if (box_y < smallestBox) smallestBox = box_y; + if (box_z < smallestBox) smallestBox = box_z; + + maxCutoff = smallestBox / 2.0; + + if (rList > maxCutoff) { + sprintf( painCave.errMsg, + "New Box size is forcing neighborlist radius down to %lf\n", + maxCutoff ); + painCave.isFatal = 0; + simError(); + + rList = maxCutoff; + + sprintf( painCave.errMsg, + "New Box size is forcing cutoff radius down to %lf\n", + maxCutoff - 1.0 ); + painCave.isFatal = 0; + simError(); + + rCut = rList - 1.0; + + // list radius changed so we have to refresh the simulation structure. + refreshSim(); + } + + if (rCut > maxCutoff) { + sprintf( painCave.errMsg, + "New Box size is forcing cutoff radius down to %lf\n", + maxCutoff ); + painCave.isFatal = 0; + simError(); + + status = 0; + LJ_new_rcut(&rCut, &status); + if (status != 0) { + sprintf( painCave.errMsg, + "Error in recomputing LJ shifts based on new rcut\n"); + painCave.isFatal = 1; + simError(); + } + } } void SimInfo::getBox(double theBox[3]) {