| 4 |
|
OOPSEMinimizer::OOPSEMinimizer( SimInfo *theInfo, ForceFields* the_ff , |
| 5 |
|
MinimizerParameterSet * param) |
| 6 |
|
:RealIntegrator(theInfo, the_ff), bVerbose(false), bShake(true){ |
| 7 |
+ |
dumpOut = NULL; |
| 8 |
+ |
statOut = NULL; |
| 9 |
|
|
| 8 |
– |
atoms = info->atoms; |
| 9 |
– |
|
| 10 |
|
tStats = new Thermo(info); |
| 11 |
< |
dumpOut = new DumpWriter(info); |
| 12 |
< |
statOut = new StatWriter(info); |
| 11 |
> |
|
| 12 |
|
|
| 13 |
|
paramSet = param; |
| 14 |
|
|
| 17 |
|
curX = getCoor(); |
| 18 |
|
curG.resize(ndim); |
| 19 |
|
|
| 20 |
+ |
preMove(); |
| 21 |
|
} |
| 22 |
|
|
| 23 |
|
OOPSEMinimizer::~OOPSEMinimizer(){ |
| 24 |
|
delete tStats; |
| 25 |
< |
delete dumpOut; |
| 26 |
< |
delete statOut; |
| 25 |
> |
if(dumpOut) |
| 26 |
> |
delete dumpOut; |
| 27 |
> |
if(statOut) |
| 28 |
> |
delete statOut; |
| 29 |
|
delete paramSet; |
| 30 |
|
} |
| 31 |
|
|
| 55 |
|
|
| 56 |
|
index = 0; |
| 57 |
|
|
| 58 |
< |
for(int i = 0; i < nAtoms; i++){ |
| 58 |
> |
for(int i = 0; i < integrableObjects.size(); i++){ |
| 59 |
|
|
| 60 |
< |
if(atoms[i]->isDirectional()){ |
| 59 |
< |
dAtom = (DirectionalAtom*) atoms[i]; |
| 60 |
< |
dAtom->getGrad(dAtomGrad); |
| 60 |
> |
if (integrableObjects[i]->isDirectional()) { |
| 61 |
|
|
| 62 |
+ |
integrableObjects[i]->getGrad(dAtomGrad); |
| 63 |
+ |
|
| 64 |
|
//gradient is equal to -f |
| 65 |
|
grad[index++] = -dAtomGrad[0]; |
| 66 |
|
grad[index++] = -dAtomGrad[1]; |
| 71 |
|
|
| 72 |
|
} |
| 73 |
|
else{ |
| 74 |
< |
atoms[i]->getFrc(force); |
| 74 |
> |
integrableObjects[i]->getFrc(force); |
| 75 |
|
|
| 76 |
|
grad[index++] = -force[0]; |
| 77 |
|
grad[index++] = -force[1]; |
| 100 |
|
|
| 101 |
|
index = 0; |
| 102 |
|
|
| 103 |
< |
for(int i = 0; i < nAtoms; i++){ |
| 103 |
> |
for(int i = 0; i < integrableObjects.size(); i++){ |
| 104 |
|
|
| 105 |
|
position[0] = x[index++]; |
| 106 |
|
position[1] = x[index++]; |
| 107 |
|
position[2] = x[index++]; |
| 108 |
|
|
| 109 |
< |
atoms[i]->setPos(position); |
| 109 |
> |
integrableObjects[i]->setPos(position); |
| 110 |
|
|
| 111 |
< |
if (atoms[i]->isDirectional()){ |
| 110 |
< |
dAtom = (DirectionalAtom*) atoms[i]; |
| 111 |
> |
if (integrableObjects[i]->isDirectional()){ |
| 112 |
|
|
| 113 |
|
eulerAngle[0] = x[index++]; |
| 114 |
|
eulerAngle[1] = x[index++]; |
| 115 |
|
eulerAngle[2] = x[index++]; |
| 116 |
|
|
| 117 |
< |
dAtom->setEuler(eulerAngle[0], eulerAngle[1], eulerAngle[2]); |
| 117 |
> |
integrableObjects[i]->setEuler(eulerAngle[0], |
| 118 |
> |
eulerAngle[1], |
| 119 |
> |
eulerAngle[2]); |
| 120 |
|
|
| 121 |
|
} |
| 122 |
|
|
| 139 |
|
|
| 140 |
|
index = 0; |
| 141 |
|
|
| 142 |
< |
for(int i = 0; i < nAtoms; i++){ |
| 143 |
< |
atoms[i]->getPos(position); |
| 142 |
> |
for(int i = 0; i < integrableObjects.size(); i++){ |
| 143 |
> |
integrableObjects[i]->getPos(position); |
| 144 |
|
|
| 145 |
|
x[index++] = position[0]; |
| 146 |
|
x[index++] = position[1]; |
| 147 |
|
x[index++] = position[2]; |
| 148 |
|
|
| 149 |
< |
if (atoms[i]->isDirectional()){ |
| 147 |
< |
dAtom = (DirectionalAtom*) atoms[i]; |
| 148 |
< |
dAtom->getEulerAngles(eulerAngle); |
| 149 |
> |
if (integrableObjects[i]->isDirectional()){ |
| 150 |
|
|
| 151 |
+ |
integrableObjects[i]->getEulerAngles(eulerAngle); |
| 152 |
+ |
|
| 153 |
|
x[index++] = eulerAngle[0]; |
| 154 |
|
x[index++] = eulerAngle[1]; |
| 155 |
|
x[index++] = eulerAngle[2]; |
| 427 |
|
|
| 428 |
|
ndim = 0; |
| 429 |
|
|
| 430 |
< |
for(int i = 0; i < nAtoms; i++){ |
| 430 |
> |
for(int i = 0; i < integrableObjects.size(); i++){ |
| 431 |
|
ndim += 3; |
| 432 |
< |
if (atoms[i]->isDirectional()) |
| 432 |
> |
if (integrableObjects[i]->isDirectional()) |
| 433 |
|
ndim += 3; |
| 434 |
|
} |
| 435 |
|
} |
| 486 |
|
|
| 487 |
|
/** |
| 488 |
|
* In thoery, we need to find the minimum along the search direction |
| 489 |
< |
* However, function evaluation is too expensive. I |
| 489 |
> |
* However, function evaluation is too expensive. |
| 490 |
|
* At the very begining of the problem, we check the search direction and make sure |
| 491 |
|
* it is a descent direction |
| 492 |
|
* we will compare the energy of two end points, |
| 520 |
|
double mu; |
| 521 |
|
double eta; |
| 522 |
|
double ftol; |
| 523 |
+ |
double lsTol; |
| 524 |
|
|
| 525 |
|
xa.resize(ndim); |
| 526 |
|
xb.resize(ndim); |
| 536 |
|
ga = curG; |
| 537 |
|
c = a + stepSize; |
| 538 |
|
ftol = paramSet->getFTol(); |
| 539 |
+ |
lsTol = paramSet->getLineSearchTol(); |
| 540 |
|
|
| 541 |
|
//calculate the derivative at a = 0 |
| 542 |
|
for (size_t i = 0; i < ndim; i++) |
| 603 |
|
eta = 3 *(fa -fc) /(c - a) + slopeA + slopeC; |
| 604 |
|
mu = sqrt(eta * eta - slopeA * slopeC); |
| 605 |
|
b = a + (c - a) * (1 - (slopeC + mu - eta) /(slopeC - slopeA + 2 * mu)); |
| 606 |
+ |
|
| 607 |
+ |
if (b < lsTol){ |
| 608 |
+ |
if (bVerbose) |
| 609 |
+ |
cout << "stepSize is less than line search tolerance" << endl; |
| 610 |
+ |
break; |
| 611 |
+ |
} |
| 612 |
|
//} |
| 613 |
|
|
| 614 |
|
// Take a trial step to this new point - new coords in xb |
| 695 |
|
|
| 696 |
|
if (bVerbose) |
| 697 |
|
printMinimizerInfo(); |
| 698 |
+ |
|
| 699 |
+ |
dumpOut = new DumpWriter(info); |
| 700 |
+ |
statOut = new StatWriter(info); |
| 701 |
|
|
| 702 |
|
init(); |
| 703 |
|
|