diff --git a/doc/src/min_modify.txt b/doc/src/min_modify.txt index b941a33559..b7c85a190b 100644 --- a/doc/src/min_modify.txt +++ b/doc/src/min_modify.txt @@ -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 diff --git a/examples/SPIN/spinmin/in.spinmin_lbfgs.bfo b/examples/SPIN/spinmin/in.spinmin_lbfgs.bfo index a73b863b11..56cd6b8fae 100644 --- a/examples/SPIN/spinmin/in.spinmin_lbfgs.bfo +++ b/examples/SPIN/spinmin/in.spinmin_lbfgs.bfo @@ -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 diff --git a/src/SPIN/min_spin.cpp b/src/SPIN/min_spin.cpp index 947e281b42..5c7e7eee30 100644 --- a/src/SPIN/min_spin.cpp +++ b/src/SPIN/min_spin.cpp @@ -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 { diff --git a/src/SPIN/min_spin_cg.cpp b/src/SPIN/min_spin_cg.cpp index 322915c0f3..a87d3aaa36 100644 --- a/src/SPIN/min_spin_cg.cpp +++ b/src/SPIN/min_spin_cg.cpp @@ -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 { diff --git a/src/SPIN/min_spin_lbfgs.cpp b/src/SPIN/min_spin_lbfgs.cpp index 891dec5c93..e161aa2a30 100644 --- a/src/SPIN/min_spin_lbfgs.cpp +++ b/src/SPIN/min_spin_lbfgs.cpp @@ -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 { diff --git a/src/min.cpp b/src/min.cpp index 33643d4837..23c3021010 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -49,8 +49,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -enum{TWO,MAX} - /* ---------------------------------------------------------------------- */ Min::Min(LAMMPS *lmp) : Pointers(lmp) diff --git a/src/min.h b/src/min.h index ac7a3c1e9b..303e2123d8 100644 --- a/src/min.h +++ b/src/min.h @@ -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();