git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@3085 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2009-08-18 17:13:07 +00:00
parent 8a6024b3ea
commit 1ed625bb28
2 changed files with 17 additions and 15 deletions

View File

@ -248,8 +248,7 @@ int MinLineSearch::linemin_backtrack(double eoriginal, double &alpha,
// backtrack with alpha until energy decrease is sufficient
while (1) {
alpha_step(ecurrent, alpha, nfunc, 1);
ecurrent = alpha_step(alpha,1,nfunc);
// if energy change is better than ideal, exit with success
@ -265,7 +264,7 @@ int MinLineSearch::linemin_backtrack(double eoriginal, double &alpha,
// reset to starting point, exit with error
if (alpha <= 0.0 || de_ideal >= -IDEAL_TOL) {
alpha_step(ecurrent, 0.0, nfunc, 0);
ecurrent = alpha_step(0.0,0,nfunc);
return ZEROALPHA;
}
}
@ -370,8 +369,7 @@ int MinLineSearch::linemin_quadratic(double eoriginal, double &alpha,
alphaprev = 0.0;
while (1) {
alpha_step(ecurrent, alpha, nfunc, 1);
ecurrent = alpha_step(alpha,1,nfunc);
// compute new fh, alpha, delfh
@ -409,7 +407,7 @@ int MinLineSearch::linemin_quadratic(double eoriginal, double &alpha,
// if fh or delfh is epsilon, reset to starting point, exit with error
if (fabs(fh) < EPS_QUAD || fabs(delfh) < EPS_QUAD) {
alpha_step(ecurrent, 0.0, nfunc, 0);
ecurrent = alpha_step(0.0,0,nfunc);
return ZEROQUAD;
}
@ -421,7 +419,7 @@ int MinLineSearch::linemin_quadratic(double eoriginal, double &alpha,
alpha0 = alpha - (alpha-alphaprev)*fh/delfh;
if (relerr <= QUADRATIC_TOL && alpha0 > 0.0) {
alpha_step(ecurrent, alpha0, nfunc, 1);
ecurrent = alpha_step(alpha0,1,nfunc);
return 0;
}
@ -445,19 +443,21 @@ int MinLineSearch::linemin_quadratic(double eoriginal, double &alpha,
// reset to starting point, exit with error
if (alpha <= 0.0 || de_ideal >= -IDEAL_TOL) {
alpha_step(ecurrent, 0.0, nfunc, 0);
ecurrent = alpha_step(0.0,0,nfunc);
return ZEROALPHA;
}
}
}
void MinLineSearch::alpha_step(double& ecurrent, double alpha,
int &nfunc, int resetflag)
/* ---------------------------------------------------------------------- */
double MinLineSearch::alpha_step(double alpha, int resetflag, int &nfunc)
{
int i,n,m;
double *xatom,*x0atom,*hatom;
// First reset to starting point
// reset to starting point
if (nextra_global) modify->min_step(0.0,hextra);
for (i = 0; i < n3; i++) x[i] = x0[i];
if (nextra_atom)
@ -468,7 +468,8 @@ void MinLineSearch::alpha_step(double& ecurrent, double alpha,
for (i = 0; i < n; i++) xatom[i] = x0atom[i];
}
// If requested, step forward along line
// step forward along h
if (alpha > 0.0) {
if (nextra_global) modify->min_step(alpha,hextra);
for (i = 0; i < n3; i++) x[i] += alpha*h[i];
@ -481,7 +482,8 @@ void MinLineSearch::alpha_step(double& ecurrent, double alpha,
}
}
// Compute energy
ecurrent = energy_force(resetflag);
// compute and return new energy
nfunc++;
return energy_force(resetflag);
}

View File

@ -47,7 +47,7 @@ class MinLineSearch : public Min {
int linemin_backtrack(double, double &, int &);
int linemin_quadratic(double, double &, int &);
void alpha_step(double &, double, int &, int);
double alpha_step(double, int, int &);
};
}