git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@4915 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
26
src/min.cpp
26
src/min.cpp
@ -347,12 +347,9 @@ void Min::setup_minimal(int flag)
|
|||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
perform minimization, calling iterate() for N steps
|
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
|
// minimizer iterations
|
||||||
|
|
||||||
@ -360,24 +357,7 @@ void Min::run(int n, int complete)
|
|||||||
stop_condition = iterate(n);
|
stop_condition = iterate(n);
|
||||||
stopstr = stopstrings(stop_condition);
|
stopstr = stopstrings(stop_condition);
|
||||||
|
|
||||||
// if early exit from iterate loop and complete flag set
|
// if early exit from iterate loop:
|
||||||
// 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
|
|
||||||
// set update->nsteps to niter for Finish stats to print
|
// set update->nsteps to niter for Finish stats to print
|
||||||
// set output->next values to this timestep
|
// set output->next values to this timestep
|
||||||
// call energy_force() to insure vflag is set when forces computed
|
// 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
|
// add ntimestep to all computes that store invocation times
|
||||||
// since are hardwiring call to thermo/dumps and computes may not be ready
|
// since are hardwiring call to thermo/dumps and computes may not be ready
|
||||||
|
|
||||||
if (stop_condition && !complete) {
|
if (stop_condition) {
|
||||||
update->nsteps = niter;
|
update->nsteps = niter;
|
||||||
|
|
||||||
if (update->restrict_output == 0) {
|
if (update->restrict_output == 0) {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class Min : protected Pointers {
|
|||||||
void init();
|
void init();
|
||||||
void setup();
|
void setup();
|
||||||
void setup_minimal(int);
|
void setup_minimal(int);
|
||||||
void run(int,int);
|
void run(int);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
int request(class Pair *, int, double);
|
int request(class Pair *, int, double);
|
||||||
double memory_usage() {return 0.0;}
|
double memory_usage() {return 0.0;}
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "min_fire.h"
|
#include "min_fire.h"
|
||||||
|
#include "universe.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
@ -22,6 +23,10 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
// EPS_ENERGY = minimum normalization for energy tolerance
|
||||||
|
|
||||||
|
#define EPS_ENERGY 1.0e-8
|
||||||
|
|
||||||
// same as in other min classes
|
// same as in other min classes
|
||||||
|
|
||||||
enum{MAXITER,MAXEVAL,ETOL,FTOL,DOWNHILL,ZEROALPHA,ZEROFORCE,ZEROQUAD};
|
enum{MAXITER,MAXEVAL,ETOL,FTOL,DOWNHILL,ZEROALPHA,ZEROFORCE,ZEROQUAD};
|
||||||
@ -76,7 +81,7 @@ void MinFire::reset_vectors()
|
|||||||
|
|
||||||
int MinFire::iterate(int maxiter)
|
int MinFire::iterate(int maxiter)
|
||||||
{
|
{
|
||||||
int ntimestep;
|
int ntimestep,flag,flagall;
|
||||||
double vmax,vdotf,vdotfall,vdotv,vdotvall,fdotf,fdotfall;
|
double vmax,vdotf,vdotfall,vdotv,vdotvall,fdotf,fdotfall;
|
||||||
double scale1,scale2;
|
double scale1,scale2;
|
||||||
double dtvone,dtv,dtfm;
|
double dtvone,dtv,dtfm;
|
||||||
@ -173,11 +178,40 @@ int MinFire::iterate(int maxiter)
|
|||||||
eprevious = ecurrent;
|
eprevious = ecurrent;
|
||||||
ecurrent = energy_force(0);
|
ecurrent = energy_force(0);
|
||||||
neval++;
|
neval++;
|
||||||
|
|
||||||
// force tolerance criterion
|
|
||||||
|
|
||||||
//fdotf = fnorm_sqr();
|
// energy tolerance criterion
|
||||||
//if (fdotf < update->ftol*update->ftol) return FTOL;
|
// 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
|
// output for thermo, dump, restart files
|
||||||
|
|
||||||
|
|||||||
@ -11,8 +11,10 @@
|
|||||||
See the README file in the top-level LAMMPS directory.
|
See the README file in the top-level LAMMPS directory.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "mpi.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "min_quickmin.h"
|
#include "min_quickmin.h"
|
||||||
|
#include "universe.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
@ -22,6 +24,10 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
// EPS_ENERGY = minimum normalization for energy tolerance
|
||||||
|
|
||||||
|
#define EPS_ENERGY 1.0e-8
|
||||||
|
|
||||||
// same as in other min classes
|
// same as in other min classes
|
||||||
|
|
||||||
enum{MAXITER,MAXEVAL,ETOL,FTOL,DOWNHILL,ZEROALPHA,ZEROFORCE,ZEROQUAD};
|
enum{MAXITER,MAXEVAL,ETOL,FTOL,DOWNHILL,ZEROALPHA,ZEROFORCE,ZEROQUAD};
|
||||||
@ -65,11 +71,13 @@ void MinQuickMin::reset_vectors()
|
|||||||
if (nvec) fvec = atom->f[0];
|
if (nvec) fvec = atom->f[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
minimization via QuickMin damped dynamics
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
int MinQuickMin::iterate(int maxiter)
|
int MinQuickMin::iterate(int maxiter)
|
||||||
{
|
{
|
||||||
int ntimestep;
|
int ntimestep,flag,flagall;
|
||||||
double vmax,vdotf,vdotfall,fdotf,fdotfall,scale;
|
double vmax,vdotf,vdotfall,fdotf,fdotfall,scale;
|
||||||
double dtvone,dtv,dtfm;
|
double dtvone,dtv,dtfm;
|
||||||
|
|
||||||
@ -141,10 +149,39 @@ int MinQuickMin::iterate(int maxiter)
|
|||||||
ecurrent = energy_force(0);
|
ecurrent = energy_force(0);
|
||||||
neval++;
|
neval++;
|
||||||
|
|
||||||
// force tolerance criterion
|
// energy tolerance criterion
|
||||||
|
// sync across replicas if running multi-replica minimization
|
||||||
|
|
||||||
//fdotf = fnorm_sqr();
|
if (update->etol > 0.0) {
|
||||||
//if (fdotf < update->ftol*update->ftol) return FTOL;
|
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
|
// output for thermo, dump, restart files
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ void Minimize::command(int narg, char **arg)
|
|||||||
update->minimize->setup();
|
update->minimize->setup();
|
||||||
|
|
||||||
timer->barrier_start(TIME_LOOP);
|
timer->barrier_start(TIME_LOOP);
|
||||||
update->minimize->run(update->nsteps,0);
|
update->minimize->run(update->nsteps);
|
||||||
timer->barrier_stop(TIME_LOOP);
|
timer->barrier_stop(TIME_LOOP);
|
||||||
|
|
||||||
update->minimize->cleanup();
|
update->minimize->cleanup();
|
||||||
|
|||||||
@ -43,6 +43,7 @@ Update::Update(LAMMPS *lmp) : Pointers(lmp)
|
|||||||
firststep = laststep = 0;
|
firststep = laststep = 0;
|
||||||
beginstep = endstep = 0;
|
beginstep = endstep = 0;
|
||||||
setupflag = 0;
|
setupflag = 0;
|
||||||
|
multireplica = 0;
|
||||||
|
|
||||||
restrict_output = 0;
|
restrict_output = 0;
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class Update : protected Pointers {
|
|||||||
int max_eval; // max force evaluations for minimizer
|
int max_eval; // max force evaluations for minimizer
|
||||||
int restrict_output; // 1 if output should not write dump/restart
|
int restrict_output; // 1 if output should not write dump/restart
|
||||||
int setupflag; // set when setup() is computing forces
|
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 eflag_global,eflag_atom; // timestep global/peratom eng is tallied on
|
||||||
int vflag_global,vflag_atom; // ditto for virial
|
int vflag_global,vflag_atom; // ditto for virial
|
||||||
|
|||||||
Reference in New Issue
Block a user