diff --git a/doc/src/min_modify.txt b/doc/src/min_modify.txt index 857c3551aa..22ee232467 100644 --- a/doc/src/min_modify.txt +++ b/doc/src/min_modify.txt @@ -72,7 +72,7 @@ that difference may be smaller than machine epsilon even if atoms could move in the gradient direction to reduce forces further. The choice of a norm can be modified for the min styles {cg}, {sd}, -{quickmin}, {fire}, {spin}, {spin_oso_cg} and {spin_oso_lbfgs} using +{quickmin}, {fire}, {spin}, {spin/cg} and {spin/lbfgs} using the {norm} keyword. The default {euclidean} norm computes the 2-norm (length) of the global force vector. The {max} norm computes the maximum value @@ -88,19 +88,19 @@ adaptive timestep used in the {spin} minimization. See "min_spin"_min_spin.html for more information about those quantities. -The choice of a line search algorithm for the {spin_oso_cg} and -{spin_oso_lbfgs} styles can be specified via the {line} keyword. +The choice of a line search algorithm for the {spin/cg} and +{spin/lbfgs} styles can be specified via the {line} keyword. The {spin_cubic} and {spin_none} only make sense when one of those two minimization styles is declared. The {spin_cubic} performs the line search based on a cubic interpolation of the energy along the search direction. The {spin_none} keyword deactivates the line search procedure. -The {spin_none} is a default value for {line} keyword for both {spin_oso_lbfgs} -and {spin_oso_cg}. Convergence of {spin_oso_lbfgs} can be more robust if +The {spin_none} is a default value for {line} keyword for both {spin/lbfgs} +and {spin/cg}. Convergence of {spin/lbfgs} can be more robust if {spin_cubic} line search is used. [Restrictions:] The line search procedure of styles -{spin_oso_cg} and {spin_oso_lbfgs} cannot be used for magnetic +{spin/cg} and {spin/lbfgs} cannot be used for magnetic GNEB calculations. See "neb/spin"_neb_spin.html for more explanation. @@ -112,6 +112,6 @@ explanation. The option defaults are dmax = 0.1, line = quadratic and norm = euclidean. -For the {spin}, {spin_oso_cg} and {spin_oso_lbfgs} styles, the +For the {spin}, {spin/cg} and {spin/lbfgs} styles, the option defaults are alpha_damp = 1.0, discrete_factor = 10.0, line = spin_none, and norm = euclidean. diff --git a/doc/src/min_spin.txt b/doc/src/min_spin.txt index 575db2dc74..ba034cfbb9 100644 --- a/doc/src/min_spin.txt +++ b/doc/src/min_spin.txt @@ -6,18 +6,18 @@ :line min_style spin command :h3 -min_style spin_oso_cg command :h3 -min_style spin_oso_lbfgs command :h3 +min_style spin/cg command :h3 +min_style spin/lbfgs command :h3 [Syntax:] min_style spin -min_style spin_oso_cg -min_style spin_oso_lbfgs :pre +min_style spin/cg +min_style spin/lbfgs :pre [Examples:] -min_style spin_oso_lbfgs +min_style spin/lbfgs min_modify line spin_cubic discrete_factor 10.0 :pre [Description:] @@ -51,35 +51,35 @@ definition of this timestep. {discrete_factor} can be defined with the "min_modify"_min_modify.html command. -Style {spin_oso_cg} defines an orthogonal spin optimization +Style {spin/cg} defines an orthogonal spin optimization (OSO) combined to a conjugate gradient (CG) algorithm. The "min_modify"_min_modify.html command can be used to -couple the {spin_oso_cg} to a line search procedure, and to modify the +couple the {spin/cg} to a line search procedure, and to modify the discretization factor {discrete_factor}. -By default, style {spin_oso_cg} does not employ the line search procedure +By default, style {spin/cg} does not employ the line search procedure and uses the adaptive time-step technique in the same way as style {spin}. -Style {spin_oso_lbfgs} defines an orthogonal spin optimization +Style {spin/lbfgs} defines an orthogonal spin optimization (OSO) combined to a limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS) algorithm. -By default, style {spin_oso_lbfgs} does not employ line search procedure. +By default, style {spin/lbfgs} does not employ line search procedure. If the line search procedure is not used then the discrete factor defines the maximum root mean squared rotation angle of spins by equation {pi/(5*Kappa)}. The default value for Kappa is 10. The {spin_cubic} line search can improve the convergence of the -{spin_oso_lbfgs} algorithm. +{spin/lbfgs} algorithm. The "min_modify"_min_modify.html command can be used to activate the line search procedure, and to modify the discretization factor {discrete_factor}. -For more information about styles {spin_oso_cg} and {spin_oso_lbfgs}, +For more information about styles {spin/cg} and {spin/lbfgs}, see their implementation reported in "(Ivanov)"_#Ivanov1. NOTE: All the {spin} styles replace the force tolerance by a torque tolerance. See "minimize"_minimize.html for more explanation. -NOTE: The {spin_oso_cg} and {spin_oso_lbfgs} styles can be used +NOTE: The {spin/cg} and {spin/lbfgs} styles can be used for magnetic NEB calculations only if the line search procedure is deactivated. See "neb/spin"_neb_spin.html for more explanation. diff --git a/doc/src/min_style.txt b/doc/src/min_style.txt index 7c40fd4947..9613da7b13 100644 --- a/doc/src/min_style.txt +++ b/doc/src/min_style.txt @@ -11,7 +11,7 @@ min_style command :h3 min_style style :pre -style = {cg} or {hftn} or {sd} or {quickmin} or {fire} or {spin} or {spin_oso_cg} or {spin_oso_lbfgs} :ul +style = {cg} or {hftn} or {sd} or {quickmin} or {fire} or {spin} or {spin/cg} or {spin/lbfgs} :ul [Examples:] @@ -65,21 +65,21 @@ a minimization. Style {spin} is a damped spin dynamics with an adaptive timestep. -Style {spin_oso_cg} uses an orthogonal spin optimization (OSO) +Style {spin/cg} uses an orthogonal spin optimization (OSO) combined to a conjugate gradient (CG) approach to minimize spin configurations. -Style {spin_oso_lbfgs} uses an orthogonal spin optimization (OSO) +Style {spin/lbfgs} uses an orthogonal spin optimization (OSO) combined to a limited-memory Broyden-Fletcher-Goldfarb-Shanno (LBFGS) approach to minimize spin configurations. See the "min/spin"_min_spin.html doc page for more information -about the {spin}, {spin_oso_cg} and {spin_oso_lbfgs} styles. +about the {spin}, {spin/cg} and {spin/lbfgs} styles. Either the {quickmin} and {fire} styles are useful in the context of nudged elastic band (NEB) calculations via the "neb"_neb.html command. -Either the {spin}, {spin_oso_cg} and {spin_oso_lbfgs} styles are useful +Either the {spin}, {spin/cg} and {spin/lbfgs} styles are useful in the context of magnetic geodesic nudged elastic band (GNEB) calculations via the "neb/spin"_neb_spin.html command. diff --git a/doc/src/minimize.txt b/doc/src/minimize.txt index 1de925d6c8..bfdc02bedf 100644 --- a/doc/src/minimize.txt +++ b/doc/src/minimize.txt @@ -104,7 +104,7 @@ the number of outer iterations or timesteps exceeds {maxiter} the number of total force evaluations exceeds {maxeval} :ul NOTE: the "minimization style"_min_style.html {spin}, -{spin_oso_cg}, and {spin_oso_lbfgs} replace +{spin/cg}, and {spin/lbfgs} replace the force tolerance {ftol} by a torque tolerance. The minimization procedure stops if the 2-norm (length) of the torque vector on atom (defined as the cross product between the diff --git a/doc/src/neb_spin.txt b/doc/src/neb_spin.txt index 2fdfda8c66..b64df39219 100644 --- a/doc/src/neb_spin.txt +++ b/doc/src/neb_spin.txt @@ -173,7 +173,7 @@ A NEB calculation proceeds in two stages, each of which is a minimization procedure. To enable this, you must first define a "min_style"_min_style.html, using either the {spin}, -{spin_oso_cg}, or {spin_oso_lbfgs} style (see +{spin/cg}, or {spin/lbfgs} style (see "min_spin"_min_spin.html for more information). The other styles cannot be used, since they relax the lattice degrees of freedom instead of the spins. @@ -359,7 +359,7 @@ This command can only be used if LAMMPS was built with the SPIN package. See the "Build package"_Build_package.html doc page for more info. -The line search procedures of the {spin_oso_cg} and {spin_oso_lbfgs} +The line search procedures of the {spin/cg} and {spin/lbfgs} minimization styles cannot be used in a GNEB calculation. :line diff --git a/examples/SPIN/spinmin/in.spinmin_cg.bfo b/examples/SPIN/spinmin/in.spinmin_cg.bfo index 8c288763c4..9d57399a56 100644 --- a/examples/SPIN/spinmin/in.spinmin_cg.bfo +++ b/examples/SPIN/spinmin/in.spinmin_cg.bfo @@ -49,6 +49,6 @@ thermo_modify format float %20.15g compute outsp all property/atom spx spy spz sp fmx fmy fmz dump 1 all custom 50 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] c_outsp[4] c_outsp[5] c_outsp[6] c_outsp[7] -min_style spin_oso_cg +min_style spin/cg # min_modify line spin_none discrete_factor 10.0 minimize 1.0e-10 1.0e-10 10000 10000 diff --git a/examples/SPIN/spinmin/in.spinmin_lbfgs.bfo b/examples/SPIN/spinmin/in.spinmin_lbfgs.bfo index 6a9104cc9c..a73b863b11 100644 --- a/examples/SPIN/spinmin/in.spinmin_lbfgs.bfo +++ b/examples/SPIN/spinmin/in.spinmin_lbfgs.bfo @@ -49,6 +49,6 @@ thermo_modify format float %20.15g compute outsp all property/atom spx spy spz sp fmx fmy fmz dump 1 all custom 50 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] c_outsp[4] c_outsp[5] c_outsp[6] c_outsp[7] -min_style spin_oso_lbfgs +min_style spin/lbfgs # min_modify line spin_cubic discrete_factor 10.0 minimize 1.0e-15 1.0e-10 10000 1000 diff --git a/src/.gitignore b/src/.gitignore index 595276853c..5848874d94 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -161,10 +161,10 @@ /fix_setforce_spin.h /min_spin.cpp /min_spin.h -/min_spin_oso_cg.cpp -/min_spin_oso_cg.h -/min_spin_oso_lbfgs.cpp -/min_spin_oso_lbfgs.h +/min_spin_cg.cpp +/min_spin_cg.h +/min_spin_lbfgs.cpp +/min_spin_lbfgs.h /neb_spin.cpp /neb_spin.h /pair_spin.cpp diff --git a/src/SPIN/min_spin_oso_cg.cpp b/src/SPIN/min_spin_cg.cpp similarity index 91% rename from src/SPIN/min_spin_oso_cg.cpp rename to src/SPIN/min_spin_cg.cpp index f1f2f72436..322915c0f3 100644 --- a/src/SPIN/min_spin_oso_cg.cpp +++ b/src/SPIN/min_spin_cg.cpp @@ -25,7 +25,7 @@ #include #include #include -#include "min_spin_oso_cg.h" +#include "min_spin_cg.h" #include "universe.h" #include "atom.h" #include "citeme.h" @@ -44,8 +44,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -static const char cite_minstyle_spin_oso_cg[] = - "min_style spin/oso_cg command:\n\n" +static const char cite_minstyle_spin_cg[] = + "min_style spin/cg command:\n\n" "@article{ivanov2019fast,\n" "title={Fast and Robust Algorithm for the Minimisation of the Energy of " "Spin Systems},\n" @@ -63,10 +63,10 @@ static const char cite_minstyle_spin_oso_cg[] = /* ---------------------------------------------------------------------- */ -MinSpinOSO_CG::MinSpinOSO_CG(LAMMPS *lmp) : +MinSpinCG::MinSpinCG(LAMMPS *lmp) : Min(lmp), g_old(NULL), g_cur(NULL), p_s(NULL), sp_copy(NULL) { - if (lmp->citeme) lmp->citeme->add(cite_minstyle_spin_oso_cg); + if (lmp->citeme) lmp->citeme->add(cite_minstyle_spin_cg); nlocal_max = 0; // nreplica = number of partitions @@ -81,7 +81,7 @@ MinSpinOSO_CG::MinSpinOSO_CG(LAMMPS *lmp) : /* ---------------------------------------------------------------------- */ -MinSpinOSO_CG::~MinSpinOSO_CG() +MinSpinCG::~MinSpinCG() { memory->destroy(g_old); memory->destroy(g_cur); @@ -92,7 +92,7 @@ MinSpinOSO_CG::~MinSpinOSO_CG() /* ---------------------------------------------------------------------- */ -void MinSpinOSO_CG::init() +void MinSpinCG::init() { local_iter = 0; der_e_cur = 0.0; @@ -120,16 +120,16 @@ void MinSpinOSO_CG::init() // allocate tables nlocal_max = atom->nlocal; - memory->grow(g_old,3*nlocal_max,"min/spin/oso/cg:g_old"); - memory->grow(g_cur,3*nlocal_max,"min/spin/oso/cg:g_cur"); - memory->grow(p_s,3*nlocal_max,"min/spin/oso/cg:p_s"); + memory->grow(g_old,3*nlocal_max,"min/spin/cg:g_old"); + memory->grow(g_cur,3*nlocal_max,"min/spin/cg:g_cur"); + memory->grow(p_s,3*nlocal_max,"min/spin/cg:p_s"); if (use_line_search) - memory->grow(sp_copy,nlocal_max,3,"min/spin/oso/cg:sp_copy"); + memory->grow(sp_copy,nlocal_max,3,"min/spin/cg:sp_copy"); } /* ---------------------------------------------------------------------- */ -void MinSpinOSO_CG::setup_style() +void MinSpinCG::setup_style() { double **v = atom->v; int nlocal = atom->nlocal; @@ -137,7 +137,7 @@ void MinSpinOSO_CG::setup_style() // check if the atom/spin style is defined if (!atom->sp_flag) - error->all(FLERR,"min/spin_oso_cg requires atom/spin style"); + error->all(FLERR,"min spin/cg requires atom/spin style"); for (int i = 0; i < nlocal; i++) v[i][0] = v[i][1] = v[i][2] = 0.0; @@ -145,7 +145,7 @@ void MinSpinOSO_CG::setup_style() /* ---------------------------------------------------------------------- */ -int MinSpinOSO_CG::modify_param(int narg, char **arg) +int MinSpinCG::modify_param(int narg, char **arg) { if (strcmp(arg[0],"discrete_factor") == 0) { if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); @@ -160,7 +160,7 @@ int MinSpinOSO_CG::modify_param(int narg, char **arg) called after atoms have migrated ------------------------------------------------------------------------- */ -void MinSpinOSO_CG::reset_vectors() +void MinSpinCG::reset_vectors() { // atomic dof @@ -179,7 +179,7 @@ void MinSpinOSO_CG::reset_vectors() minimization via orthogonal spin optimisation ------------------------------------------------------------------------- */ -int MinSpinOSO_CG::iterate(int maxiter) +int MinSpinCG::iterate(int maxiter) { int nlocal = atom->nlocal; bigint ntimestep; @@ -191,11 +191,11 @@ int MinSpinOSO_CG::iterate(int maxiter) if (nlocal_max < nlocal) { local_iter = 0; nlocal_max = nlocal; - memory->grow(g_old,3*nlocal_max,"min/spin/oso/cg:g_old"); - memory->grow(g_cur,3*nlocal_max,"min/spin/oso/cg:g_cur"); - memory->grow(p_s,3*nlocal_max,"min/spin/oso/cg:p_s"); + memory->grow(g_old,3*nlocal_max,"min/spin/cg:g_old"); + memory->grow(g_cur,3*nlocal_max,"min/spin/cg:g_cur"); + memory->grow(p_s,3*nlocal_max,"min/spin/cg:p_s"); if (use_line_search) - memory->grow(sp_copy,nlocal_max,3,"min/spin/oso/cg:sp_copy"); + memory->grow(sp_copy,nlocal_max,3,"min/spin/cg:sp_copy"); } for (int iter = 0; iter < maxiter; iter++) { @@ -309,7 +309,7 @@ int MinSpinOSO_CG::iterate(int maxiter) calculate gradients ---------------------------------------------------------------------- */ -void MinSpinOSO_CG::calc_gradient() +void MinSpinCG::calc_gradient() { int nlocal = atom->nlocal; double **sp = atom->sp; @@ -337,7 +337,7 @@ void MinSpinOSO_CG::calc_gradient() Optimization' Second Edition, 2006 (p. 121) ---------------------------------------------------------------------- */ -void MinSpinOSO_CG::calc_search_direction() +void MinSpinCG::calc_search_direction() { int nlocal = atom->nlocal; double g2old = 0.0; @@ -398,7 +398,7 @@ void MinSpinOSO_CG::calc_search_direction() rotation of spins along the search direction ---------------------------------------------------------------------- */ -void MinSpinOSO_CG::advance_spins() +void MinSpinCG::advance_spins() { int nlocal = atom->nlocal; double **sp = atom->sp; @@ -429,7 +429,7 @@ void MinSpinOSO_CG::advance_spins() [-y, -z, 0]] ------------------------------------------------------------------------- */ -void MinSpinOSO_CG::rodrigues_rotation(const double *upp_tr, double *out) +void MinSpinCG::rodrigues_rotation(const double *upp_tr, double *out) { double theta,A,B,D,x,y,z; double s1,s2,s3,a1,a2,a3; @@ -490,7 +490,7 @@ void MinSpinOSO_CG::rodrigues_rotation(const double *upp_tr, double *out) m -- 3x3 matrix , v -- 3-d vector ------------------------------------------------------------------------- */ -void MinSpinOSO_CG::vm3(const double *m, const double *v, double *out) +void MinSpinCG::vm3(const double *m, const double *v, double *out) { for(int i = 0; i < 3; i++){ out[i] = 0.0; @@ -502,7 +502,7 @@ void MinSpinOSO_CG::vm3(const double *m, const double *v, double *out) advance spins ------------------------------------------------------------------------- */ -void MinSpinOSO_CG::make_step(double c, double *energy_and_der) +void MinSpinCG::make_step(double c, double *energy_and_der) { double p_scaled[3]; int nlocal = atom->nlocal; @@ -549,7 +549,7 @@ void MinSpinOSO_CG::make_step(double c, double *energy_and_der) using the cubic interpolation ------------------------------------------------------------------------- */ -int MinSpinOSO_CG::calc_and_make_step(double a, double b, int index) +int MinSpinCG::calc_and_make_step(double a, double b, int index) { double e_and_d[2] = {0.0,0.0}; double alpha,c1,c2,c3; @@ -601,7 +601,7 @@ int MinSpinOSO_CG::calc_and_make_step(double a, double b, int index) Approximate descent ------------------------------------------------------------------------- */ -int MinSpinOSO_CG::adescent(double phi_0, double phi_j){ +int MinSpinCG::adescent(double phi_0, double phi_j){ double eps = 1.0e-6; @@ -615,7 +615,7 @@ int MinSpinOSO_CG::adescent(double phi_0, double phi_j){ evaluate max timestep ---------------------------------------------------------------------- */ -double MinSpinOSO_CG::evaluate_dt() +double MinSpinCG::evaluate_dt() { double dtmax; double fmsq; diff --git a/src/SPIN/min_spin_oso_cg.h b/src/SPIN/min_spin_cg.h similarity index 90% rename from src/SPIN/min_spin_oso_cg.h rename to src/SPIN/min_spin_cg.h index d6dc7c03d0..0eed7a61e6 100644 --- a/src/SPIN/min_spin_oso_cg.h +++ b/src/SPIN/min_spin_cg.h @@ -13,21 +13,21 @@ #ifdef MINIMIZE_CLASS -MinimizeStyle(spin_oso_cg, MinSpinOSO_CG) +MinimizeStyle(spin/cg, MinSpinCG) #else -#ifndef LMP_MIN_SPIN_OSO_CG_H -#define LMP_MIN_SPIN_OSO_CG_H +#ifndef LMP_MIN_SPIN_CG_H +#define LMP_MIN_SPIN_CG_H #include "min.h" namespace LAMMPS_NS { -class MinSpinOSO_CG: public Min { +class MinSpinCG: public Min { public: - MinSpinOSO_CG(class LAMMPS *); - virtual ~MinSpinOSO_CG(); + MinSpinCG(class LAMMPS *); + virtual ~MinSpinCG(); void init(); void setup_style(); void reset_vectors(); diff --git a/src/SPIN/min_spin_oso_lbfgs.cpp b/src/SPIN/min_spin_lbfgs.cpp similarity index 90% rename from src/SPIN/min_spin_oso_lbfgs.cpp rename to src/SPIN/min_spin_lbfgs.cpp index 8623a8bb29..891dec5c93 100644 --- a/src/SPIN/min_spin_oso_lbfgs.cpp +++ b/src/SPIN/min_spin_lbfgs.cpp @@ -25,7 +25,7 @@ #include #include #include -#include "min_spin_oso_lbfgs.h" +#include "min_spin_lbfgs.h" #include "atom.h" #include "citeme.h" #include "comm.h" @@ -43,8 +43,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -static const char cite_minstyle_spin_oso_lbfgs[] = - "min_style spin/oso_lbfgs command:\n\n" +static const char cite_minstyle_spin_lbfgs[] = + "min_style spin/lbfgs command:\n\n" "@article{ivanov2019fast,\n" "title={Fast and Robust Algorithm for the Minimisation of the Energy of " "Spin Systems},\n" @@ -62,10 +62,10 @@ static const char cite_minstyle_spin_oso_lbfgs[] = /* ---------------------------------------------------------------------- */ -MinSpinOSO_LBFGS::MinSpinOSO_LBFGS(LAMMPS *lmp) : +MinSpinLBFGS::MinSpinLBFGS(LAMMPS *lmp) : Min(lmp), g_old(NULL), g_cur(NULL), p_s(NULL), rho(NULL), ds(NULL), dy(NULL), sp_copy(NULL) { - if (lmp->citeme) lmp->citeme->add(cite_minstyle_spin_oso_lbfgs); + if (lmp->citeme) lmp->citeme->add(cite_minstyle_spin_lbfgs); nlocal_max = 0; // nreplica = number of partitions @@ -81,7 +81,7 @@ MinSpinOSO_LBFGS::MinSpinOSO_LBFGS(LAMMPS *lmp) : /* ---------------------------------------------------------------------- */ -MinSpinOSO_LBFGS::~MinSpinOSO_LBFGS() +MinSpinLBFGS::~MinSpinLBFGS() { memory->destroy(g_old); memory->destroy(g_cur); @@ -95,7 +95,7 @@ MinSpinOSO_LBFGS::~MinSpinOSO_LBFGS() /* ---------------------------------------------------------------------- */ -void MinSpinOSO_LBFGS::init() +void MinSpinLBFGS::init() { num_mem = 3; local_iter = 0; @@ -123,20 +123,20 @@ void MinSpinOSO_LBFGS::init() // allocate tables nlocal_max = atom->nlocal; - memory->grow(g_old,3*nlocal_max,"min/spin/oso/lbfgs:g_old"); - memory->grow(g_cur,3*nlocal_max,"min/spin/oso/lbfgs:g_cur"); - memory->grow(p_s,3*nlocal_max,"min/spin/oso/lbfgs:p_s"); - memory->grow(rho,num_mem,"min/spin/oso/lbfgs:rho"); - memory->grow(ds,num_mem,3*nlocal_max,"min/spin/oso/lbfgs:ds"); - memory->grow(dy,num_mem,3*nlocal_max,"min/spin/oso/lbfgs:dy"); + memory->grow(g_old,3*nlocal_max,"min/spin/lbfgs:g_old"); + memory->grow(g_cur,3*nlocal_max,"min/spin/lbfgs:g_cur"); + memory->grow(p_s,3*nlocal_max,"min/spin/lbfgs:p_s"); + memory->grow(rho,num_mem,"min/spin/lbfgs:rho"); + memory->grow(ds,num_mem,3*nlocal_max,"min/spin/lbfgs:ds"); + memory->grow(dy,num_mem,3*nlocal_max,"min/spin/lbfgs:dy"); if (use_line_search) - memory->grow(sp_copy,nlocal_max,3,"min/spin/oso/lbfgs:sp_copy"); + memory->grow(sp_copy,nlocal_max,3,"min/spin/lbfgs:sp_copy"); } /* ---------------------------------------------------------------------- */ -void MinSpinOSO_LBFGS::setup_style() +void MinSpinLBFGS::setup_style() { double **v = atom->v; int nlocal = atom->nlocal; @@ -144,7 +144,7 @@ void MinSpinOSO_LBFGS::setup_style() // check if the atom/spin style is defined if (!atom->sp_flag) - error->all(FLERR,"min/spin_oso_lbfgs requires atom/spin style"); + error->all(FLERR,"min spin/lbfgs requires atom/spin style"); for (int i = 0; i < nlocal; i++) v[i][0] = v[i][1] = v[i][2] = 0.0; @@ -152,7 +152,7 @@ void MinSpinOSO_LBFGS::setup_style() /* ---------------------------------------------------------------------- */ -int MinSpinOSO_LBFGS::modify_param(int narg, char **arg) +int MinSpinLBFGS::modify_param(int narg, char **arg) { if (strcmp(arg[0],"discrete_factor") == 0) { if (narg < 2) error->all(FLERR,"Illegal min_modify command"); @@ -169,7 +169,7 @@ int MinSpinOSO_LBFGS::modify_param(int narg, char **arg) called after atoms have migrated ------------------------------------------------------------------------- */ -void MinSpinOSO_LBFGS::reset_vectors() +void MinSpinLBFGS::reset_vectors() { // atomic dof @@ -188,7 +188,7 @@ void MinSpinOSO_LBFGS::reset_vectors() minimization via damped spin dynamics ------------------------------------------------------------------------- */ -int MinSpinOSO_LBFGS::iterate(int maxiter) +int MinSpinLBFGS::iterate(int maxiter) { int nlocal = atom->nlocal; bigint ntimestep; @@ -200,14 +200,14 @@ int MinSpinOSO_LBFGS::iterate(int maxiter) if (nlocal_max < nlocal) { nlocal_max = nlocal; local_iter = 0; - memory->grow(g_old,3*nlocal_max,"min/spin/oso/lbfgs:g_old"); - memory->grow(g_cur,3*nlocal_max,"min/spin/oso/lbfgs:g_cur"); - memory->grow(p_s,3*nlocal_max,"min/spin/oso/lbfgs:p_s"); - memory->grow(rho,num_mem,"min/spin/oso/lbfgs:rho"); - memory->grow(ds,num_mem,3*nlocal_max,"min/spin/oso/lbfgs:ds"); - memory->grow(dy,num_mem,3*nlocal_max,"min/spin/oso/lbfgs:dy"); + memory->grow(g_old,3*nlocal_max,"min/spin/lbfgs:g_old"); + memory->grow(g_cur,3*nlocal_max,"min/spin/lbfgs:g_cur"); + memory->grow(p_s,3*nlocal_max,"min/spin/lbfgs:p_s"); + memory->grow(rho,num_mem,"min/spin/lbfgs:rho"); + memory->grow(ds,num_mem,3*nlocal_max,"min/spin/lbfgs:ds"); + memory->grow(dy,num_mem,3*nlocal_max,"min/spin/lbfgs:dy"); if (use_line_search) - memory->grow(sp_copy,nlocal_max,3,"min/spin/oso/lbfgs:sp_copy"); + memory->grow(sp_copy,nlocal_max,3,"min/spin/lbfgs:sp_copy"); } for (int iter = 0; iter < maxiter; iter++) { @@ -324,7 +324,7 @@ int MinSpinOSO_LBFGS::iterate(int maxiter) calculate gradients ---------------------------------------------------------------------- */ -void MinSpinOSO_LBFGS::calc_gradient() +void MinSpinLBFGS::calc_gradient() { int nlocal = atom->nlocal; double **sp = atom->sp; @@ -347,7 +347,7 @@ void MinSpinOSO_LBFGS::calc_gradient() Optimization' Second Edition, 2006 (p. 177) ---------------------------------------------------------------------- */ -void MinSpinOSO_LBFGS::calc_search_direction() +void MinSpinLBFGS::calc_search_direction() { int nlocal = atom->nlocal; @@ -531,7 +531,7 @@ void MinSpinOSO_LBFGS::calc_search_direction() rotation of spins along the search direction ---------------------------------------------------------------------- */ -void MinSpinOSO_LBFGS::advance_spins() +void MinSpinLBFGS::advance_spins() { int nlocal = atom->nlocal; double **sp = atom->sp; @@ -562,7 +562,7 @@ void MinSpinOSO_LBFGS::advance_spins() [-y, -z, 0]] ------------------------------------------------------------------------- */ -void MinSpinOSO_LBFGS::rodrigues_rotation(const double *upp_tr, double *out) +void MinSpinLBFGS::rodrigues_rotation(const double *upp_tr, double *out) { double theta,A,B,D,x,y,z; double s1,s2,s3,a1,a2,a3; @@ -622,7 +622,7 @@ void MinSpinOSO_LBFGS::rodrigues_rotation(const double *upp_tr, double *out) m -- 3x3 matrix , v -- 3-d vector ------------------------------------------------------------------------- */ -void MinSpinOSO_LBFGS::vm3(const double *m, const double *v, double *out) +void MinSpinLBFGS::vm3(const double *m, const double *v, double *out) { for(int i = 0; i < 3; i++){ out[i] = 0.0; @@ -632,7 +632,7 @@ void MinSpinOSO_LBFGS::vm3(const double *m, const double *v, double *out) } -void MinSpinOSO_LBFGS::make_step(double c, double *energy_and_der) +void MinSpinLBFGS::make_step(double c, double *energy_and_der) { double p_scaled[3]; int nlocal = atom->nlocal; @@ -679,7 +679,7 @@ void MinSpinOSO_LBFGS::make_step(double c, double *energy_and_der) using the cubic interpolation ------------------------------------------------------------------------- */ -int MinSpinOSO_LBFGS::calc_and_make_step(double a, double b, int index) +int MinSpinLBFGS::calc_and_make_step(double a, double b, int index) { double e_and_d[2] = {0.0,0.0}; double alpha,c1,c2,c3; @@ -731,7 +731,7 @@ int MinSpinOSO_LBFGS::calc_and_make_step(double a, double b, int index) Approximate descent ------------------------------------------------------------------------- */ -int MinSpinOSO_LBFGS::adescent(double phi_0, double phi_j){ +int MinSpinLBFGS::adescent(double phi_0, double phi_j){ double eps = 1.0e-6; @@ -741,7 +741,7 @@ int MinSpinOSO_LBFGS::adescent(double phi_0, double phi_j){ return 0; } -double MinSpinOSO_LBFGS::maximum_rotation(double *p) +double MinSpinLBFGS::maximum_rotation(double *p) { double norm2,norm2_global,scaling,alpha; int nlocal = atom->nlocal; diff --git a/src/SPIN/min_spin_oso_lbfgs.h b/src/SPIN/min_spin_lbfgs.h similarity index 90% rename from src/SPIN/min_spin_oso_lbfgs.h rename to src/SPIN/min_spin_lbfgs.h index 68fa10921e..cead605b32 100644 --- a/src/SPIN/min_spin_oso_lbfgs.h +++ b/src/SPIN/min_spin_lbfgs.h @@ -13,21 +13,21 @@ #ifdef MINIMIZE_CLASS -MinimizeStyle(spin_oso_lbfgs, MinSpinOSO_LBFGS) +MinimizeStyle(spin/lbfgs, MinSpinLBFGS) #else -#ifndef LMP_MIN_SPIN_OSO_LBFGS_H -#define LMP_MIN_SPIN_OSO_LBFGS_H +#ifndef LMP_MIN_SPIN_LBFGS_H +#define LMP_MIN_SPIN_LBFGS_H #include "min.h" namespace LAMMPS_NS { -class MinSpinOSO_LBFGS: public Min { +class MinSpinLBFGS: public Min { public: - MinSpinOSO_LBFGS(class LAMMPS *); - virtual ~MinSpinOSO_LBFGS(); + MinSpinLBFGS(class LAMMPS *); + virtual ~MinSpinLBFGS(); void init(); void setup_style(); int modify_param(int, char **);