--- trunk/OOPSE/libmdtools/ZConstraint.cpp 2003/07/31 15:35:07 658 +++ trunk/OOPSE/libmdtools/ZConstraint.cpp 2003/08/01 16:18:13 661 @@ -33,7 +33,29 @@ template ZConstraint::ZConstraint(SimIn } else{ + indexOfAllZConsMols = index->getIndexData(); + + //the maximum value of index is the last one(we sorted the index data in SimSetup.cpp) + int maxIndex; + int totalNumMol; + + maxIndex = indexOfAllZConsMols[indexOfAllZConsMols.size() - 1]; + +#ifndef IS_MPI + totalNumMol = nMols; +#else + totalNumMol = mpiSim->getTotNmol(); +#endif + + if(maxIndex > totalNumMol - 1){ + sprintf( painCave.errMsg, + "ZConstraint error: index is out of range\n"); + painCave.isFatal = 1; + simError(); + + } + } } @@ -503,15 +525,12 @@ template void ZConstraint::resetZ() #endif zsys = (totalMZOfZCons + totalMZOfUncons) /totalMassOfUncons; - - cout << "current time: " << info->getTime() <getCOM(COM); - cout << "global index: " << zconsMols[i]->getGlobalIndex() << "\tZ: " << COM[2] << "\t"; deltaZ = zsys + refZ[i] - COM[2]; - cout << "\tdistance: " << COM[2] +deltaZ - zsys; //update z coordinate zconsAtoms = zconsMols[i]->getMyAtoms(); for(int j =0; j < zconsMols[i]->getNAtoms(); j++){ @@ -521,7 +540,6 @@ template void ZConstraint::resetZ() //calculate z constrain force fz[i] = massOfZConsMols[i]* deltaZ / dt2; - cout << "\tforce: " << fz[i] << endl; }