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

@ -347,12 +347,9 @@ void Min::setup_minimal(int flag)
/* ----------------------------------------------------------------------
perform minimization, calling iterate() for N steps
complete = 1 if caller wants to force N iterations (in every replica)
minimize command and PRD call with complete = 0
NEB calls with complete = 1
------------------------------------------------------------------------- */
void Min::run(int n, int complete)
void Min::run(int n)
{
// minimizer iterations
@ -360,24 +357,7 @@ void Min::run(int n, int complete)
stop_condition = iterate(n);
stopstr = stopstrings(stop_condition);
// if early exit from iterate loop and complete flag set
// perform remaining dummy iterations
if (stop_condition && complete) {
int ntimestep;
while (niter - iter_start < n) {
ntimestep = ++update->ntimestep;
niter++;
ecurrent = energy_force(0);
if (output->next == ntimestep) {
timer->stamp();
output->write(ntimestep);
timer->stamp(TIME_OUTPUT);
}
}
}
// if early exit from iterate loop and complete flag not set
// if early exit from iterate loop:
// set update->nsteps to niter for Finish stats to print
// set output->next values to this timestep
// call energy_force() to insure vflag is set when forces computed
@ -385,7 +365,7 @@ void Min::run(int n, int complete)
// add ntimestep to all computes that store invocation times
// since are hardwiring call to thermo/dumps and computes may not be ready
if (stop_condition && !complete) {
if (stop_condition) {
update->nsteps = niter;
if (update->restrict_output == 0) {

View File

@ -33,7 +33,7 @@ class Min : protected Pointers {
void init();
void setup();
void setup_minimal(int);
void run(int,int);
void run(int);
void cleanup();
int request(class Pair *, int, double);
double memory_usage() {return 0.0;}

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

View File

@ -11,8 +11,10 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "mpi.h"
#include "math.h"
#include "min_quickmin.h"
#include "universe.h"
#include "atom.h"
#include "force.h"
#include "update.h"
@ -22,6 +24,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};
@ -65,11 +71,13 @@ void MinQuickMin::reset_vectors()
if (nvec) fvec = atom->f[0];
}
/* ----------------------------------------------------------------------
minimization via QuickMin damped dynamics
/* ---------------------------------------------------------------------- */
int MinQuickMin::iterate(int maxiter)
{
int ntimestep;
int ntimestep,flag,flagall;
double vmax,vdotf,vdotfall,fdotf,fdotfall,scale;
double dtvone,dtv,dtfm;
@ -141,10 +149,39 @@ int MinQuickMin::iterate(int maxiter)
ecurrent = energy_force(0);
neval++;
// force tolerance criterion
// energy tolerance criterion
// sync across replicas if running multi-replica minimization
//fdotf = fnorm_sqr();
//if (fdotf < update->ftol*update->ftol) return FTOL;
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

View File

@ -51,7 +51,7 @@ void Minimize::command(int narg, char **arg)
update->minimize->setup();
timer->barrier_start(TIME_LOOP);
update->minimize->run(update->nsteps,0);
update->minimize->run(update->nsteps);
timer->barrier_stop(TIME_LOOP);
update->minimize->cleanup();

View File

@ -43,6 +43,7 @@ Update::Update(LAMMPS *lmp) : Pointers(lmp)
firststep = laststep = 0;
beginstep = endstep = 0;
setupflag = 0;
multireplica = 0;
restrict_output = 0;

View File

@ -31,6 +31,7 @@ class Update : protected Pointers {
int max_eval; // max force evaluations for minimizer
int restrict_output; // 1 if output should not write dump/restart
int setupflag; // set when setup() is computing forces
int multireplica; // 1 if min across replicas, else 0
int eflag_global,eflag_atom; // timestep global/peratom eng is tallied on
int vflag_global,vflag_atom; // ditto for virial