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

This commit is contained in:
sjplimp
2007-02-21 20:57:31 +00:00
parent 412a1c4d8f
commit 1445a6d536
18 changed files with 1000 additions and 495 deletions

View File

@ -35,10 +35,9 @@ void MinSD::iterate(int n)
{
int i,fail;
double alpha,dot,dotall;
double *f;
f = atom->f[0];
for (int i = 0; i < ndof; i++) h[i] = f[i];
for (i = 0; i < ndof_extra; i++) hextra[i] = fextra[i];
neval = 0;
@ -48,28 +47,29 @@ void MinSD::iterate(int n)
// line minimization along direction h from current atom->x
eprevious = ecurrent;
fail = (this->*linemin)(ndof,atom->x[0],h,ecurrent,dmin,dmax,alpha,neval);
eprevious = energy;
fail = (this->*linemin)(neval);
// if max_eval exceeded, all done
// if linemin failed or energy did not decrease sufficiently, all done
if (neval >= update->max_eval) break;
if (fail || fabs(ecurrent-eprevious) <=
update->tolerance * 0.5*(fabs(ecurrent) + fabs(eprevious) + EPS))
if (fail || fabs(energy-eprevious) <=
update->tolerance * 0.5*(fabs(energy) + fabs(eprevious) + EPS))
break;
// set h to new f = -Grad(x)
// done if size sq of grad vector < EPS
f = atom->f[0];
dot = 0.0;
for (i = 0; i < ndof; i++) dot += f[i]*f[i];
MPI_Allreduce(&dot,&dotall,1,MPI_DOUBLE,MPI_SUM,world);
for (i = 0; i < ndof_extra; i++) dotall += fextra[i]*fextra[i];
if (dotall < EPS) break;
for (i = 0; i < ndof; i++) h[i] = f[i];
for (i = 0; i < ndof_extra; i++) hextra[i] = fextra[i];
// output for thermo, dump, restart files