Renamed: adaptglok -> fire2
This commit is contained in:
143
src/min.cpp
143
src/min.cpp
@ -42,10 +42,12 @@
|
||||
#include "output.h"
|
||||
#include "thermo.h"
|
||||
#include "timer.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -54,6 +56,7 @@ Min::Min(LAMMPS *lmp) : Pointers(lmp)
|
||||
dmax = 0.1;
|
||||
searchflag = 0;
|
||||
linestyle = 1;
|
||||
normstyle = TWO;
|
||||
|
||||
delaystep = 20;
|
||||
dtgrow = 1.1;
|
||||
@ -731,6 +734,15 @@ void Min::modify_params(int narg, char **arg)
|
||||
if (strcmp(arg[iarg+1],"backtrack") == 0) linestyle = 0;
|
||||
else if (strcmp(arg[iarg+1],"quadratic") == 0) linestyle = 1;
|
||||
else if (strcmp(arg[iarg+1],"forcezero") == 0) linestyle = 2;
|
||||
else if (strcmp(arg[iarg+1],"spin_cubic") == 0) linestyle = 3;
|
||||
else if (strcmp(arg[iarg+1],"spin_none") == 0) linestyle = 4;
|
||||
else error->all(FLERR,"Illegal min_modify command");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"norm") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal min_modify command");
|
||||
if (strcmp(arg[iarg+1],"two") == 0) normstyle = TWO;
|
||||
else if (strcmp(arg[iarg+1],"max") == 0) normstyle = MAX;
|
||||
else if (strcmp(arg[iarg+1],"inf") == 0) normstyle = INF;
|
||||
else error->all(FLERR,"Illegal min_modify command");
|
||||
iarg += 2;
|
||||
} else {
|
||||
@ -894,6 +906,137 @@ double Min::fnorm_inf()
|
||||
return norm_inf;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute and return ||force||_max (inf norm per-vector)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double Min::fnorm_max()
|
||||
{
|
||||
int i,n;
|
||||
double fdotf,*fatom;
|
||||
|
||||
double local_norm_max = 0.0;
|
||||
for (i = 0; i < nvec; i+=3) {
|
||||
fdotf = fvec[i]*fvec[i]+fvec[i+1]*fvec[i+1]+fvec[i+2]*fvec[i+2];
|
||||
local_norm_max = MAX(fdotf,local_norm_max);
|
||||
}
|
||||
if (nextra_atom) {
|
||||
for (int m = 0; m < nextra_atom; m++) {
|
||||
fatom = fextra_atom[m];
|
||||
n = extra_nlen[m];
|
||||
for (i = 0; i < n; i+=3)
|
||||
fdotf = fvec[i]*fvec[i]+fvec[i+1]*fvec[i+1]+fvec[i+2]*fvec[i+2];
|
||||
local_norm_max = MAX(fdotf,local_norm_max);
|
||||
}
|
||||
}
|
||||
|
||||
double norm_max = 0.0;
|
||||
MPI_Allreduce(&local_norm_max,&norm_max,1,MPI_DOUBLE,MPI_MAX,world);
|
||||
|
||||
if (nextra_global)
|
||||
for (i = 0; i < n; i+=3)
|
||||
fdotf = fvec[i]*fvec[i]+fvec[i+1]*fvec[i+1]+fvec[i+2]*fvec[i+2];
|
||||
norm_max = MAX(fdotf,norm_max);
|
||||
|
||||
return norm_max;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute and return sum_i||mag. torque_i||_2 (in eV)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double Min::total_torque()
|
||||
{
|
||||
double fmsq,ftotsqone,ftotsqall;
|
||||
int nlocal = atom->nlocal;
|
||||
double hbar = force->hplanck/MY_2PI;
|
||||
double tx,ty,tz;
|
||||
double **sp = atom->sp;
|
||||
double **fm = atom->fm;
|
||||
|
||||
fmsq = ftotsqone = ftotsqall = 0.0;
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
tx = fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1];
|
||||
ty = fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2];
|
||||
tz = fm[i][0]*sp[i][1] - fm[i][1]*sp[i][0];
|
||||
fmsq = tx*tx + ty*ty + tz*tz;
|
||||
ftotsqone += fmsq;
|
||||
}
|
||||
|
||||
// summing all fmsqtot on this replica
|
||||
|
||||
MPI_Allreduce(&ftotsqone,&ftotsqall,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
|
||||
// multiply it by hbar so that units are in eV
|
||||
|
||||
return sqrt(ftotsqall) * hbar;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute and return max_i ||mag. torque components|| (in eV)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double Min::inf_torque()
|
||||
{
|
||||
double fmsq,fmaxsqone,fmaxsqall;
|
||||
int nlocal = atom->nlocal;
|
||||
double hbar = force->hplanck/MY_2PI;
|
||||
double tx,ty,tz;
|
||||
double **sp = atom->sp;
|
||||
double **fm = atom->fm;
|
||||
|
||||
fmsq = fmaxsqone = fmaxsqall = 0.0;
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
tx = fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1];
|
||||
ty = fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2];
|
||||
tz = fm[i][0]*sp[i][1] - fm[i][1]*sp[i][0];
|
||||
fmaxsqone = MAX(fmaxsqone,tx*tx);
|
||||
fmaxsqone = MAX(fmaxsqone,ty*ty);
|
||||
fmaxsqone = MAX(fmaxsqone,tz*tz);
|
||||
}
|
||||
|
||||
// finding max fm on this replica
|
||||
|
||||
fmaxsqall = fmaxsqone;
|
||||
MPI_Allreduce(&fmaxsqone,&fmaxsqall,1,MPI_DOUBLE,MPI_MAX,world);
|
||||
|
||||
// multiply it by hbar so that units are in eV
|
||||
|
||||
return sqrt(fmaxsqall) * hbar;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute and return max_i ||mag. torque_i|| (in eV)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double Min::max_torque()
|
||||
{
|
||||
double fmsq,fmaxsqone,fmaxsqall;
|
||||
int nlocal = atom->nlocal;
|
||||
double hbar = force->hplanck/MY_2PI;
|
||||
double tx,ty,tz;
|
||||
double **sp = atom->sp;
|
||||
double **fm = atom->fm;
|
||||
|
||||
fmsq = fmaxsqone = fmaxsqall = 0.0;
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
tx = fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1];
|
||||
ty = fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2];
|
||||
tz = fm[i][0]*sp[i][1] - fm[i][1]*sp[i][0];
|
||||
fmsq = tx*tx + ty*ty + tz*tz;
|
||||
fmaxsqone = MAX(fmaxsqone,fmsq);
|
||||
}
|
||||
|
||||
// finding max fm on this replica
|
||||
|
||||
fmaxsqall = fmaxsqone;
|
||||
MPI_Allreduce(&fmaxsqone,&fmaxsqall,1,MPI_DOUBLE,MPI_MAX,world);
|
||||
|
||||
// multiply it by hbar so that units are in eV
|
||||
|
||||
return sqrt(fmaxsqall) * hbar;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
possible stop conditions
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user