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

This commit is contained in:
sjplimp
2010-09-30 22:28:15 +00:00
parent 653d41ec75
commit f97280116a
7 changed files with 87 additions and 34 deletions

View File

@ -13,6 +13,7 @@
#include "math.h"
#include "min_fire.h"
#include "universe.h"
#include "atom.h"
#include "force.h"
#include "update.h"
@ -22,6 +23,10 @@
using namespace LAMMPS_NS;
// EPS_ENERGY = minimum normalization for energy tolerance
#define EPS_ENERGY 1.0e-8
// same as in other min classes
enum{MAXITER,MAXEVAL,ETOL,FTOL,DOWNHILL,ZEROALPHA,ZEROFORCE,ZEROQUAD};
@ -76,7 +81,7 @@ void MinFire::reset_vectors()
int MinFire::iterate(int maxiter)
{
int ntimestep;
int ntimestep,flag,flagall;
double vmax,vdotf,vdotfall,vdotv,vdotvall,fdotf,fdotfall;
double scale1,scale2;
double dtvone,dtv,dtfm;
@ -173,11 +178,40 @@ int MinFire::iterate(int maxiter)
eprevious = ecurrent;
ecurrent = energy_force(0);
neval++;
// force tolerance criterion
//fdotf = fnorm_sqr();
//if (fdotf < update->ftol*update->ftol) return FTOL;
// energy tolerance criterion
// sync across replicas if running multi-replica minimization
if (update->etol > 0.0) {
if (update->multireplica == 0) {
if (fabs(ecurrent-eprevious) <
update->etol * 0.5*(fabs(ecurrent) + fabs(eprevious) + EPS_ENERGY))
return ETOL;
} else {
printf("EEE %g %g\n",ecurrent,eprevious);
if (fabs(ecurrent-eprevious) <
update->etol * 0.5*(fabs(ecurrent) + fabs(eprevious) + EPS_ENERGY))
flag = 0;
else flag = 1;
MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,universe->uworld);
if (flagall == 0) return ETOL;
}
}
// force tolerance criterion
// sync across replicas if running multi-replica minimization
if (update->ftol > 0.0) {
fdotf = fnorm_sqr();
if (update->multireplica == 0) {
if (fdotf < update->ftol*update->ftol) return FTOL;
} else {
if (fdotf < update->ftol*update->ftol) flag = 0;
else flag = 1;
MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,universe->uworld);
if (flagall == 0) return FTOL;
}
}
// output for thermo, dump, restart files