Commit2 JT 092319

- added enum to min.h (for norm choice)
- completed doc min_modify
- corrected torque tol issue in spin/min
This commit is contained in:
julient31 2019-09-23 13:48:33 -06:00
parent 56e1a05287
commit bc0ff0db61
7 changed files with 21 additions and 46 deletions

View File

@ -86,6 +86,9 @@ all atoms
:c,image(Eqs/norm_max.jpg)
For the min styles {spin}, {spin/cg} and {spin/lbfgs}, the force
norm is replaced by the spin-torque norm.
Keywords {alpha_damp} and {discrete_factor} only make sense when
a "min_spin"_min_spin.html command is declared.
Keyword {alpha_damp} defines an analog of a magnetic Gilbert

View File

@ -51,4 +51,5 @@ dump 1 all custom 50 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3
min_style spin/lbfgs
# min_modify line spin_cubic discrete_factor 10.0
min_modify norm max
minimize 1.0e-15 1.0e-10 10000 1000

View File

@ -116,7 +116,7 @@ void MinSpin::reset_vectors()
int MinSpin::iterate(int maxiter)
{
bigint ntimestep;
double fmdotfm,fmsq,fmsqall;
double fmdotfm,fmsq;
int flag,flagall;
for (int iter = 0; iter < maxiter; iter++) {
@ -163,20 +163,11 @@ int MinSpin::iterate(int maxiter)
// magnetic torque tolerance criterion
// sync across replicas if running multi-replica minimization
fmdotfm = fmsq = fmsqall = 0.0;
fmdotfm = fmsq = 0.0;
if (update->ftol > 0.0) {
if (normstyle == 1) { // max torque norm
fmsq = max_torque();
fmsqall = fmsq;
if (update->multireplica == 0)
MPI_Allreduce(&fmsq,&fmsqall,1,MPI_INT,MPI_MAX,universe->uworld);
} else { // Euclidean torque norm
fmsq = total_torque();
fmsqall = fmsq;
if (update->multireplica == 0)
MPI_Allreduce(&fmsq,&fmsqall,1,MPI_INT,MPI_SUM,universe->uworld);
}
fmdotfm = fmsqall*fmsqall;
if (normstyle == MAX) fmsq = max_torque(); // max norm
else fmsq = total_torque(); // Euclidean 2-norm
fmdotfm = fmsq*fmsq;
if (update->multireplica == 0) {
if (fmdotfm < update->ftol*update->ftol) return FTOL;
} else {

View File

@ -60,7 +60,6 @@ static const char cite_minstyle_spin_cg[] =
#define DELAYSTEP 5
/* ---------------------------------------------------------------------- */
MinSpinCG::MinSpinCG(LAMMPS *lmp) :
@ -183,7 +182,7 @@ int MinSpinCG::iterate(int maxiter)
{
int nlocal = atom->nlocal;
bigint ntimestep;
double fmdotfm,fmsq,fmsqall;
double fmdotfm,fmsq;
int flag, flagall;
double **sp = atom->sp;
double der_e_cur_tmp = 0.0;
@ -269,20 +268,11 @@ int MinSpinCG::iterate(int maxiter)
// magnetic torque tolerance criterion
// sync across replicas if running multi-replica minimization
fmdotfm = fmsq = fmsqall = 0.0;
fmdotfm = fmsq = 0.0;
if (update->ftol > 0.0) {
if (normstyle == 1) { // max torque norm
fmsq = max_torque();
fmsqall = fmsq;
if (update->multireplica == 0)
MPI_Allreduce(&fmsq,&fmsqall,1,MPI_INT,MPI_MAX,universe->uworld);
} else { // Euclidean torque norm
fmsq = total_torque();
fmsqall = fmsq;
if (update->multireplica == 0)
MPI_Allreduce(&fmsq,&fmsqall,1,MPI_INT,MPI_SUM,universe->uworld);
}
fmdotfm = fmsqall*fmsqall;
if (normstyle == MAX) fmsq = max_torque(); // max norm
else fmsq = total_torque(); // Euclidean 2-norm
fmdotfm = fmsq*fmsq;
if (update->multireplica == 0) {
if (fmdotfm < update->ftol*update->ftol) return FTOL;
} else {

View File

@ -59,7 +59,6 @@ static const char cite_minstyle_spin_lbfgs[] =
#define DELAYSTEP 5
/* ---------------------------------------------------------------------- */
MinSpinLBFGS::MinSpinLBFGS(LAMMPS *lmp) :
@ -192,7 +191,7 @@ int MinSpinLBFGS::iterate(int maxiter)
{
int nlocal = atom->nlocal;
bigint ntimestep;
double fmdotfm,fmsq,fmsqall;
double fmdotfm,fmsq;
int flag, flagall;
double **sp = atom->sp;
double der_e_cur_tmp = 0.0;
@ -284,20 +283,11 @@ int MinSpinLBFGS::iterate(int maxiter)
// magnetic torque tolerance criterion
// sync across replicas if running multi-replica minimization
fmdotfm = fmsq = fmsqall = 0.0;
fmdotfm = fmsq = 0.0;
if (update->ftol > 0.0) {
if (normstyle == 1) { // max torque norm
fmsq = max_torque();
fmsqall = fmsq;
if (update->multireplica == 0)
MPI_Allreduce(&fmsq,&fmsqall,1,MPI_INT,MPI_MAX,universe->uworld);
} else { // Euclidean torque norm
fmsq = total_torque();
fmsqall = fmsq;
if (update->multireplica == 0)
MPI_Allreduce(&fmsq,&fmsqall,1,MPI_INT,MPI_SUM,universe->uworld);
}
fmdotfm = fmsqall*fmsqall;
if (normstyle == MAX) fmsq = max_torque(); // max norm
else fmsq = total_torque(); // Euclidean 2-norm
fmdotfm = fmsq*fmsq;
if (update->multireplica == 0) {
if (fmdotfm < update->ftol*update->ftol) return FTOL;
} else {

View File

@ -49,8 +49,6 @@
using namespace LAMMPS_NS;
using namespace MathConst;
enum{TWO,MAX}
/* ---------------------------------------------------------------------- */
Min::Min(LAMMPS *lmp) : Pointers(lmp)

View File

@ -43,6 +43,8 @@ class Min : protected Pointers {
double fnorm_inf();
double fnorm_max();
enum{TWO,MAX};
// methods for spin minimizers
double max_torque();
double total_torque();