Commit JT 092319

- modified norm input in min_modify
- corrected doc/src/min_modify.txt
- added expression of the norms
- added a min max method in src/min.h
This commit is contained in:
julient31
2019-09-23 11:12:31 -06:00
parent f1563ed988
commit 56e1a05287
13 changed files with 109 additions and 46 deletions

View File

@ -35,7 +35,7 @@ MinCG::MinCG(LAMMPS *lmp) : MinLineSearch(lmp) {}
int MinCG::iterate(int maxiter)
{
int i,m,n,fail,ntimestep;
double beta,gg,dot[2],dotall[2],fmax,fmaxall;
double beta,gg,dot[2],dotall[2],fmax;
double *fatom,*gatom,*hatom;
// nlimit = max # of CG iterations before restarting
@ -85,13 +85,12 @@ int MinCG::iterate(int maxiter)
// force tolerance criterion
fmax = fmaxall = 0.0;
dot[0] = dot[1] = 0.0;
for (i = 0; i < nvec; i++) {
dot[0] += fvec[i]*fvec[i];
dot[1] += fvec[i]*g[i];
fmax = MAX(fmax,fvec[i]*fvec[i]);
}
if (nextra_atom)
for (m = 0; m < nextra_atom; m++) {
fatom = fextra_atom[m];
@ -104,16 +103,17 @@ int MinCG::iterate(int maxiter)
}
}
MPI_Allreduce(dot,dotall,2,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(&fmax,&fmaxall,2,MPI_DOUBLE,MPI_MAX,world);
if (nextra_global)
for (i = 0; i < nextra_global; i++) {
dotall[0] += fextra[i]*fextra[i];
dotall[1] += fextra[i]*gextra[i];
}
if (normstyle == 1) { // max force norm
fmax = 0.0;
if (normstyle == MAX) { // max force norm
fmax = fnorm_max();
if (fmax < update->ftol*update->ftol) return FTOL;
} else { // Euclidean force norm
} else { // Euclidean force 2-norm
if (dotall[0] < update->ftol*update->ftol) return FTOL;
}