| 1 |
|
#include <math.h> |
| 2 |
|
#include "OOPSEMinimizer.hpp" |
| 3 |
+ |
#include "ShakeMin.hpp" |
| 4 |
|
|
| 5 |
|
OOPSEMinimizer::OOPSEMinimizer( SimInfo *theInfo, ForceFields* the_ff , |
| 6 |
|
MinimizerParameterSet * param) |
| 7 |
|
:RealIntegrator(theInfo, the_ff), bVerbose(false), bShake(true){ |
| 8 |
+ |
dumpOut = NULL; |
| 9 |
+ |
statOut = NULL; |
| 10 |
|
|
| 11 |
|
tStats = new Thermo(info); |
| 12 |
< |
dumpOut = new DumpWriter(info); |
| 10 |
< |
statOut = new StatWriter(info); |
| 12 |
> |
|
| 13 |
|
|
| 14 |
|
paramSet = param; |
| 15 |
|
|
| 18 |
|
curX = getCoor(); |
| 19 |
|
curG.resize(ndim); |
| 20 |
|
|
| 21 |
< |
preMove(); |
| 21 |
> |
shakeAlgo = new ShakeMinFramework(theInfo); |
| 22 |
> |
shakeAlgo->doPreConstraint(); |
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
OOPSEMinimizer::~OOPSEMinimizer(){ |
| 26 |
|
delete tStats; |
| 27 |
< |
delete dumpOut; |
| 28 |
< |
delete statOut; |
| 27 |
> |
if(dumpOut) |
| 28 |
> |
delete dumpOut; |
| 29 |
> |
if(statOut) |
| 30 |
> |
delete statOut; |
| 31 |
|
delete paramSet; |
| 32 |
|
} |
| 33 |
|
|
| 39 |
|
double force[3]; |
| 40 |
|
double dAtomGrad[6]; |
| 41 |
|
int shakeStatus; |
| 42 |
+ |
|
| 43 |
+ |
status = 1; |
| 44 |
|
|
| 45 |
|
setCoor(x); |
| 46 |
|
|
| 47 |
< |
if (nConstrained && bShake){ |
| 48 |
< |
shakeStatus = shakeR(); |
| 47 |
> |
if (bShake){ |
| 48 |
> |
shakeStatus = shakeAlgo->doShakeR(); |
| 49 |
> |
if(shakeStatus < 0) |
| 50 |
> |
status = -1; |
| 51 |
|
} |
| 52 |
< |
|
| 53 |
< |
calcForce(1, 1); |
| 54 |
< |
|
| 55 |
< |
if (nConstrained && bShake){ |
| 56 |
< |
shakeStatus |= shakeF(); |
| 52 |
> |
|
| 53 |
> |
calcForce(1, 1); |
| 54 |
> |
|
| 55 |
> |
if (bShake){ |
| 56 |
> |
shakeStatus = shakeAlgo->doShakeF(); |
| 57 |
> |
if(shakeStatus < 0) |
| 58 |
> |
status = -1; |
| 59 |
|
} |
| 60 |
< |
|
| 60 |
> |
|
| 61 |
|
x = getCoor(); |
| 62 |
|
|
| 63 |
|
|
| 91 |
|
|
| 92 |
|
energy = tStats->getPotential(); |
| 93 |
|
|
| 83 |
– |
status = shakeStatus; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
/** |
| 169 |
|
|
| 170 |
|
} |
| 171 |
|
|
| 172 |
+ |
/* |
| 173 |
|
int OOPSEMinimizer::shakeR(){ |
| 174 |
|
int i, j; |
| 175 |
|
int done; |
| 409 |
|
return 1; |
| 410 |
|
} |
| 411 |
|
|
| 412 |
< |
//calculate the value of object function |
| 412 |
> |
*/ |
| 413 |
> |
|
| 414 |
> |
//calculate the value of object function |
| 415 |
|
void OOPSEMinimizer::calcF(){ |
| 416 |
|
calcEnergyGradient(curX, curG, curF, egEvalStatus); |
| 417 |
|
} |
| 496 |
|
|
| 497 |
|
/** |
| 498 |
|
* In thoery, we need to find the minimum along the search direction |
| 499 |
< |
* However, function evaluation is too expensive. I |
| 499 |
> |
* However, function evaluation is too expensive. |
| 500 |
|
* At the very begining of the problem, we check the search direction and make sure |
| 501 |
|
* it is a descent direction |
| 502 |
|
* we will compare the energy of two end points, |
| 705 |
|
|
| 706 |
|
if (bVerbose) |
| 707 |
|
printMinimizerInfo(); |
| 708 |
+ |
|
| 709 |
+ |
dumpOut = new DumpWriter(info); |
| 710 |
+ |
statOut = new StatWriter(info); |
| 711 |
|
|
| 712 |
|
init(); |
| 713 |
|
|
| 723 |
|
|
| 724 |
|
stepStatus = step(); |
| 725 |
|
|
| 726 |
+ |
if (bShake) |
| 727 |
+ |
shakeAlgo->doPreConstraint(); |
| 728 |
+ |
|
| 729 |
|
if (stepStatus < 0){ |
| 730 |
|
saveResult(); |
| 731 |
|
minStatus = MIN_LSERROR; |
| 738 |
|
writeOut(curX, curIter); |
| 739 |
|
} |
| 740 |
|
|
| 722 |
– |
//if (curIter == nextResetIter){ |
| 723 |
– |
// reset(); |
| 724 |
– |
// nextResetIter += resetFrq; |
| 725 |
– |
//} |
| 726 |
– |
|
| 741 |
|
convgStatus = checkConvg(); |
| 742 |
|
|
| 743 |
|
if (convgStatus > 0){ |