--- trunk/OOPSE/libmdtools/OOPSEMinimizer.cpp 2004/06/04 03:15:31 1234 +++ trunk/OOPSE/libmdtools/OOPSEMinimizer.cpp 2004/07/16 16:29:44 1330 @@ -1,10 +1,11 @@ #include #include "OOPSEMinimizer.hpp" #include "ShakeMin.hpp" +#include "Integrator.cpp" OOPSEMinimizer::OOPSEMinimizer( SimInfo *theInfo, ForceFields* the_ff , - MinimizerParameterSet * param) - :RealIntegrator(theInfo, the_ff), bVerbose(false), bShake(true){ + MinimizerParameterSet * param) : + RealIntegrator(theInfo, the_ff), bShake(true), bVerbose(false) { dumpOut = NULL; statOut = NULL; @@ -18,7 +19,8 @@ OOPSEMinimizer::OOPSEMinimizer( SimInfo *theInfo, Forc curX = getCoor(); curG.resize(ndim); - //preMove(); + shakeAlgo = new ShakeMinFramework(theInfo); + shakeAlgo->doPreConstraint(); } OOPSEMinimizer::~OOPSEMinimizer(){ @@ -38,23 +40,25 @@ void OOPSEMinimizer::calcEnergyGradient(vector double force[3]; double dAtomGrad[6]; int shakeStatus; + + status = 1; setCoor(x); - //if (nConstrained && bShake){ - // shakeStatus = shakeR(); - //} + if (bShake){ + shakeStatus = shakeAlgo->doShakeR(); + if(shakeStatus < 0) + status = -1; + } - shakeAlgo->doShakeR(); - calcForce(1, 1); - - //if (nConstrained && bShake){ - // shakeStatus |= shakeF(); - //} + + if (bShake){ + shakeStatus = shakeAlgo->doShakeF(); + if(shakeStatus < 0) + status = -1; + } - shakeAlgo->doShakeF(); - x = getCoor(); @@ -88,7 +92,6 @@ void OOPSEMinimizer::calcEnergyGradient(vector energy = tStats->getPotential(); - status = shakeStatus; } /** @@ -547,6 +550,7 @@ int OOPSEMinimizer::doLineSearch(vector& direc lsTol = paramSet->getLineSearchTol(); //calculate the derivative at a = 0 + slopeA = 0; for (size_t i = 0; i < ndim; i++) slopeA += curG[i]*direction[i]; @@ -721,6 +725,9 @@ void OOPSEMinimizer::minimize(){ stepStatus = step(); + if (bShake) + shakeAlgo->doPreConstraint(); + if (stepStatus < 0){ saveResult(); minStatus = MIN_LSERROR; @@ -733,11 +740,6 @@ void OOPSEMinimizer::minimize(){ writeOut(curX, curIter); } - //if (curIter == nextResetIter){ - // reset(); - // nextResetIter += resetFrq; - //} - convgStatus = checkConvg(); if (convgStatus > 0){