# | Line 1 | Line 1 | |
---|---|---|
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 | ||
# | Line 17 | Line 19 | OOPSEMinimizer::OOPSEMinimizer( SimInfo *theInfo, Forc | |
19 | curX = getCoor(); | |
20 | curG.resize(ndim); | |
21 | ||
22 | < | preMove(); |
22 | > | shakeAlgo = new ShakeMinFramework(theInfo); |
23 | > | shakeAlgo->doPreConstraint(); |
24 | } | |
25 | ||
26 | OOPSEMinimizer::~OOPSEMinimizer(){ | |
# | Line 37 | Line 40 | void OOPSEMinimizer::calcEnergyGradient(vector<double> | |
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 | ||
# | Line 83 | Line 92 | void OOPSEMinimizer::calcEnergyGradient(vector<double> | |
92 | ||
93 | energy = tStats->getPotential(); | |
94 | ||
86 | – | status = shakeStatus; |
95 | } | |
96 | ||
97 | /** | |
# | Line 162 | Line 170 | vector<double> OOPSEMinimizer::getCoor(){ | |
170 | ||
171 | } | |
172 | ||
173 | + | /* |
174 | int OOPSEMinimizer::shakeR(){ | |
175 | int i, j; | |
176 | int done; | |
# | Line 401 | Line 410 | int OOPSEMinimizer::shakeF(){ | |
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 | } | |
# | Line 539 | Line 550 | int OOPSEMinimizer::doLineSearch(vector<double>& direc | |
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 | ||
# | Line 713 | Line 725 | void OOPSEMinimizer::minimize(){ | |
725 | ||
726 | stepStatus = step(); | |
727 | ||
728 | + | if (bShake) |
729 | + | shakeAlgo->doPreConstraint(); |
730 | + | |
731 | if (stepStatus < 0){ | |
732 | saveResult(); | |
733 | minStatus = MIN_LSERROR; | |
# | Line 725 | Line 740 | void OOPSEMinimizer::minimize(){ | |
740 | writeOut(curX, curIter); | |
741 | } | |
742 | ||
728 | – | //if (curIter == nextResetIter){ |
729 | – | // reset(); |
730 | – | // nextResetIter += resetFrq; |
731 | – | //} |
732 | – | |
743 | convgStatus = checkConvg(); | |
744 | ||
745 | if (convgStatus > 0){ |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |