--- trunk/OOPSE/libmdtools/OOPSEMinimizer.cpp 2004/05/01 18:52:38 1144 +++ trunk/OOPSE/libmdtools/OOPSEMinimizer.cpp 2004/07/16 16:29:44 1330 @@ -1,9 +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; @@ -17,7 +19,8 @@ OOPSEMinimizer::OOPSEMinimizer( SimInfo *theInfo, Forc curX = getCoor(); curG.resize(ndim); - preMove(); + shakeAlgo = new ShakeMinFramework(theInfo); + shakeAlgo->doPreConstraint(); } OOPSEMinimizer::~OOPSEMinimizer(){ @@ -37,19 +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; } - + calcForce(1, 1); - - if (nConstrained && bShake){ - shakeStatus |= shakeF(); + + if (bShake){ + shakeStatus = shakeAlgo->doShakeF(); + if(shakeStatus < 0) + status = -1; } - + x = getCoor(); @@ -83,7 +92,6 @@ void OOPSEMinimizer::calcEnergyGradient(vector energy = tStats->getPotential(); - status = shakeStatus; } /** @@ -162,6 +170,7 @@ vector OOPSEMinimizer::getCoor(){ } +/* int OOPSEMinimizer::shakeR(){ int i, j; int done; @@ -401,7 +410,9 @@ int OOPSEMinimizer::shakeF(){ return 1; } - //calculate the value of object function +*/ + +//calculate the value of object function void OOPSEMinimizer::calcF(){ calcEnergyGradient(curX, curG, curF, egEvalStatus); } @@ -539,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]; @@ -713,6 +725,9 @@ void OOPSEMinimizer::minimize(){ stepStatus = step(); + if (bShake) + shakeAlgo->doPreConstraint(); + if (stepStatus < 0){ saveResult(); minStatus = MIN_LSERROR; @@ -725,11 +740,6 @@ void OOPSEMinimizer::minimize(){ writeOut(curX, curIter); } - //if (curIter == nextResetIter){ - // reset(); - // nextResetIter += resetFrq; - //} - convgStatus = checkConvg(); if (convgStatus > 0){