1 |
|
#include <math.h> |
2 |
|
#include "OOPSEMinimizer.hpp" |
3 |
+ |
#include "ShakeMin.hpp" |
4 |
+ |
#include "Integrator.cpp" |
5 |
|
|
6 |
|
OOPSEMinimizer::OOPSEMinimizer( SimInfo *theInfo, ForceFields* the_ff , |
7 |
< |
MinimizerParameterSet * param) |
8 |
< |
:RealIntegrator(theInfo, the_ff), bVerbose(false), bShake(true){ |
7 |
> |
MinimizerParameterSet * param) : |
8 |
> |
RealIntegrator(theInfo, the_ff), bShake(true), bVerbose(false) { |
9 |
> |
dumpOut = NULL; |
10 |
> |
statOut = NULL; |
11 |
|
|
12 |
|
tStats = new Thermo(info); |
13 |
< |
dumpOut = new DumpWriter(info); |
10 |
< |
statOut = new StatWriter(info); |
13 |
> |
|
14 |
|
|
15 |
|
paramSet = param; |
16 |
|
|
19 |
|
curX = getCoor(); |
20 |
|
curG.resize(ndim); |
21 |
|
|
22 |
< |
preMove(); |
22 |
> |
shakeAlgo = new ShakeMinFramework(theInfo); |
23 |
> |
shakeAlgo->doPreConstraint(); |
24 |
|
} |
25 |
|
|
26 |
|
OOPSEMinimizer::~OOPSEMinimizer(){ |
27 |
|
delete tStats; |
28 |
< |
delete dumpOut; |
29 |
< |
delete statOut; |
28 |
> |
if(dumpOut) |
29 |
> |
delete dumpOut; |
30 |
> |
if(statOut) |
31 |
> |
delete statOut; |
32 |
|
delete paramSet; |
33 |
|
} |
34 |
|
|
40 |
|
double force[3]; |
41 |
|
double dAtomGrad[6]; |
42 |
|
int shakeStatus; |
43 |
+ |
|
44 |
+ |
status = 1; |
45 |
|
|
46 |
|
setCoor(x); |
47 |
|
|
48 |
< |
if (nConstrained && bShake){ |
49 |
< |
shakeStatus = shakeR(); |
48 |
> |
if (bShake){ |
49 |
> |
shakeStatus = shakeAlgo->doShakeR(); |
50 |
> |
if(shakeStatus < 0) |
51 |
> |
status = -1; |
52 |
|
} |
53 |
< |
|
53 |
> |
|
54 |
|
calcForce(1, 1); |
55 |
< |
|
56 |
< |
if (nConstrained && bShake){ |
57 |
< |
shakeStatus |= shakeF(); |
55 |
> |
|
56 |
> |
if (bShake){ |
57 |
> |
shakeStatus = shakeAlgo->doShakeF(); |
58 |
> |
if(shakeStatus < 0) |
59 |
> |
status = -1; |
60 |
|
} |
61 |
< |
|
61 |
> |
|
62 |
|
x = getCoor(); |
63 |
|
|
64 |
|
|
92 |
|
|
93 |
|
energy = tStats->getPotential(); |
94 |
|
|
83 |
– |
status = shakeStatus; |
95 |
|
} |
96 |
|
|
97 |
|
/** |
170 |
|
|
171 |
|
} |
172 |
|
|
173 |
+ |
/* |
174 |
|
int OOPSEMinimizer::shakeR(){ |
175 |
|
int i, j; |
176 |
|
int done; |
410 |
|
return 1; |
411 |
|
} |
412 |
|
|
413 |
< |
//calculate the value of object function |
413 |
> |
*/ |
414 |
> |
|
415 |
> |
//calculate the value of object function |
416 |
|
void OOPSEMinimizer::calcF(){ |
417 |
|
calcEnergyGradient(curX, curG, curF, egEvalStatus); |
418 |
|
} |
550 |
|
lsTol = paramSet->getLineSearchTol(); |
551 |
|
|
552 |
|
//calculate the derivative at a = 0 |
553 |
+ |
slopeA = 0; |
554 |
|
for (size_t i = 0; i < ndim; i++) |
555 |
|
slopeA += curG[i]*direction[i]; |
556 |
|
|
707 |
|
|
708 |
|
if (bVerbose) |
709 |
|
printMinimizerInfo(); |
710 |
+ |
|
711 |
+ |
dumpOut = new DumpWriter(info); |
712 |
+ |
statOut = new StatWriter(info); |
713 |
|
|
714 |
|
init(); |
715 |
|
|
725 |
|
|
726 |
|
stepStatus = step(); |
727 |
|
|
728 |
+ |
if (bShake) |
729 |
+ |
shakeAlgo->doPreConstraint(); |
730 |
+ |
|
731 |
|
if (stepStatus < 0){ |
732 |
|
saveResult(); |
733 |
|
minStatus = MIN_LSERROR; |
740 |
|
writeOut(curX, curIter); |
741 |
|
} |
742 |
|
|
722 |
– |
//if (curIter == nextResetIter){ |
723 |
– |
// reset(); |
724 |
– |
// nextResetIter += resetFrq; |
725 |
– |
//} |
726 |
– |
|
743 |
|
convgStatus = checkConvg(); |
744 |
|
|
745 |
|
if (convgStatus > 0){ |