Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the conjugate gradient algorithm and L-BFGS to the SPIN package #1598

Merged
merged 87 commits into from Oct 5, 2019
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
588cce7
add min_spin_oso (just a copy of min_spin)
alxvov Jun 27, 2019
1eb8313
add gradient descent with rotation matrices with adaptive time step (…
alxvov Jun 27, 2019
f7ddf43
modify comment
alxvov Jun 27, 2019
589d0e2
add conjugate gradients with OSO
alxvov Jun 27, 2019
630ce7b
add contributing authors
alxvov Jun 27, 2019
2520eab
small typo
alxvov Jun 27, 2019
3e8ab7c
Commit JT 062719
julient31 Jun 27, 2019
5c8e812
Commit JT 062819
julient31 Jun 28, 2019
61b12a0
added lbfgs
alxvov Jul 1, 2019
cc698f0
Merge branch 'OSO' into OSO_LBFGS
alxvov Jul 1, 2019
89ecd5d
get rid off double loops in cg
alxvov Jul 1, 2019
0f29975
get rid off double loops in cg
alxvov Jul 1, 2019
5f74f6d
delete irrelevant comment
alxvov Jul 1, 2019
6a2a4d5
parallelisation of lbfgs
alxvov Jul 1, 2019
0a0e85a
rodr. rot. as in cg
alxvov Jul 1, 2019
1d64d78
handle memory in a right way
alxvov Jul 1, 2019
56c34e4
merge memory alloc for lbfgs
alxvov Jul 1, 2019
924c610
use for loop
alxvov Jul 1, 2019
3adc23a
Merge branch 'OSO_LBFGS' into OSO
alxvov Jul 1, 2019
398f33d
added cubic line search
alxvov Jul 2, 2019
ee8d3ce
change cg to lbfgs in oso_lbfgs
alxvov Jul 2, 2019
fd5bc85
calculate energy in the beginning only once
alxvov Jul 2, 2019
44ca54f
a bit more comments
alxvov Jul 2, 2019
707c5b1
Merge branch 'OSO' into OSO_LBFGS_LS
alxvov Jul 2, 2019
e3ed8d8
parallelisation of lbfgs, change indentation, more comments
alxvov Jul 2, 2019
66a5041
Commit1 JT 060219
julient31 Jul 2, 2019
cebed54
Merge branch 'OSO' of github.com:alxvov/lammps into OSO
julient31 Jul 2, 2019
8452afb
compare dyds_global instead
alxvov Jul 3, 2019
eaa542b
scale initial gradients with adaptive time step
alxvov Jul 3, 2019
48cc029
if g2 zero then beta is also zero
alxvov Jul 3, 2019
87fd17a
global dot products
alxvov Jul 3, 2019
747245e
sum beta over all replicas in cg. Good for GNEB
alxvov Jul 3, 2019
fb63c5a
Commit1 JT 070319
julient31 Jul 3, 2019
5924c55
Merge branch 'OSO' of github.com:alxvov/lammps into OSO
julient31 Jul 3, 2019
526e0da
reduce correctly over the universe
alxvov Jul 3, 2019
99e58d8
Commit2 JT 070319
julient31 Jul 3, 2019
3c3c789
use local iteration counter, needed for neb
alxvov Jul 3, 2019
fcf5e8c
Merge remote-tracking branch 'origin/OSO' into OSO
alxvov Jul 3, 2019
95cf85f
bug: forget to calculate beta..
alxvov Jul 3, 2019
e85bdd1
introduce cutoff step. make lbfgs stable
alxvov Jul 4, 2019
f3985c8
local iter instead of iter
alxvov Jul 4, 2019
79f8e42
indentation
alxvov Jul 4, 2019
bb325a3
Commit1 JT 070919
julient31 Jul 10, 2019
2b2a9e7
fix memory, add sp_copy
alxvov Jul 11, 2019
6238ad3
local iterator, broadcast more
alxvov Jul 11, 2019
45516e3
delete unused variables and function
alxvov Jul 19, 2019
7514eea
no line search option too
alxvov Jul 19, 2019
ad713d3
rename min_spin_oso_lbfgs_ls -> min_spin_oso_lbfgs
alxvov Jul 19, 2019
aa5263f
restructure a bit
alxvov Jul 19, 2019
b31548d
convergence criterion based on maximum toque at atom. Minor changes
alxvov Jul 19, 2019
3b7bb66
conjugate gradients with line search
alxvov Jul 19, 2019
473e64c
actual gradient of energy, not scaled by hbar.
alxvov Jul 22, 2019
e4001b0
change convergence criterion
alxvov Jul 22, 2019
65ac9f1
Merge branch 'OSO' into OSO_CG2_with_linesearch
alxvov Jul 22, 2019
fabe611
use line search or adaptive time step
alxvov Jul 22, 2019
31d2b23
rename cg2 -> cg
alxvov Jul 22, 2019
07f2f5e
no line search for multireplica
alxvov Jul 22, 2019
89bfe4a
change convergence criteria in min_spin
alxvov Jul 22, 2019
a9a2c7a
no line search as default option for CG
alxvov Jul 22, 2019
f0679cf
Commit JT 072319
julient31 Jul 23, 2019
f1c3b9d
Commit2 JT 072319
julient31 Jul 23, 2019
f9ed12b
modify line for spin_cubic, spin_none. edit docs a bit.
alxvov Jul 24, 2019
883f6d1
Commit1 JT 072619
julient31 Jul 26, 2019
7e5c293
delete comment. Add line option
alxvov Jul 26, 2019
c5b7a36
Commit JT 072619
julient31 Jul 26, 2019
1364329
Commit JT 072619
julient31 Jul 26, 2019
7df2ae3
Merge branch 'OSO' of github.com:alxvov/lammps into OSO
julient31 Jul 26, 2019
9609c75
Use descent condition, and no line search as a default option for
alxvov Jul 30, 2019
aa3c44a
modify documentation a bit
alxvov Jul 30, 2019
74fa4f7
Commit JT 073019
julient31 Jul 30, 2019
b5621b2
Merge branch 'master' of github.com:alxvov/lammps into OSO
julient31 Jul 30, 2019
f4e3186
Commit JT 073019
julient31 Jul 30, 2019
c71e869
define params in creator as init is called after modify
alxvov Aug 21, 2019
12c73e7
Merge branch 'upstream-master' into OSO
alxvov Aug 21, 2019
8ec4e3f
Commit JT 082219
julient31 Aug 22, 2019
f1563ed
Commit JT 082719
julient31 Aug 27, 2019
48ea1ee
make as in master
alxvov Sep 8, 2019
56e1a05
Commit JT 092319
julient31 Sep 23, 2019
bc0ff0d
Commit2 JT 092319
julient31 Sep 23, 2019
34f8104
Commit3 JT 092319
julient31 Sep 23, 2019
a31aa5d
Merge branch 'master' of github.com:alxvov/lammps into OSO
julient31 Sep 23, 2019
a0f0c23
Commit3 JT 092319
julient31 Sep 23, 2019
d9306a5
Commit JT 092419
julient31 Sep 24, 2019
1493395
change units
alxvov Sep 30, 2019
fc10817
Merge remote-tracking branch 'origin/OSO' into OSO
alxvov Sep 30, 2019
d117ed2
remove unnecessary operations. calloc only if rho is positive
alxvov Oct 3, 2019
ed467d8
Merge branch 'master' of github.com:alxvov/lammps into OSO
julient31 Oct 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added doc/src/Eqs/norm_inf.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions doc/src/Eqs/norm_inf.tex
@@ -0,0 +1,15 @@
\documentclass[preview]{standalone}
\usepackage{varwidth}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath, amssymb, graphics, setspace}

\begin{document}
\begin{varwidth}{50in}
\begin{equation}
|| \vec{F} ||_{inf}
= {\rm max}\left(|F_1^1|, |F_1^2|, |F_1^3| \cdots,
|F_N^1|, |F_N^2|, |F_N^3|\right)
\nonumber
\end{equation}
\end{varwidth}
\end{document}
Binary file added doc/src/Eqs/norm_max.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions doc/src/Eqs/norm_max.tex
@@ -0,0 +1,15 @@
\documentclass[preview]{standalone}
\usepackage{varwidth}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath, amssymb, graphics, setspace}

\begin{document}
\begin{varwidth}{50in}
\begin{equation}
% \left| \left| \vec{F} \right| \right|_2
|| \vec{F} ||_{max}
= {\rm max}\left(||\vec{F}_1||, \cdots, ||\vec{F}_N||\right)
\nonumber
\end{equation}
\end{varwidth}
\end{document}
Binary file added doc/src/Eqs/norm_two.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions doc/src/Eqs/norm_two.tex
@@ -0,0 +1,15 @@
\documentclass[preview]{standalone}
\usepackage{varwidth}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath, amssymb, graphics, setspace}

\begin{document}
\begin{varwidth}{50in}
\begin{equation}
% \left| \left| \vec{F} \right| \right|_2
|| \vec{F} ||_{2}
= \sqrt{\vec{F}_1+ \cdots + \vec{F}_N}
\nonumber
\end{equation}
\end{varwidth}
\end{document}
15 changes: 11 additions & 4 deletions doc/src/fix_nve_spin.txt
Expand Up @@ -27,10 +27,16 @@ fix 1 all nve/spin lattice no :pre

Perform a symplectic integration for the spin or spin-lattice system.

The {lattice} keyword defines if the spins are integrated on a lattice
of fixed atoms (lattice = no), or if atoms are moving (lattice = yes).
The {lattice} keyword defines whether the spins are integrated on a
fixed or moving lattice.

By default (lattice = yes), a spin-lattice integration is performed.
If {lattice}=yes, the equations of motion of the atoms are integrated,
and a combined spin and lattice calculation is performed.
This is the default option.

If {lattice}=no, the equations of motion of the atoms are not
integrated. The lattice degrees of freedom are frozen, and a
spin dynamics only calculation is performed.

The {nve/spin} fix applies a Suzuki-Trotter decomposition to
the equations of motion of the spin lattice system, following the scheme:
Expand Down Expand Up @@ -63,7 +69,8 @@ instead of "array" is also valid.

"atom_style spin"_atom_style.html, "fix nve"_fix_nve.html

[Default:] none
[Default:] By default (lattice = yes), a spin-lattice integration is
performed.

:line

Expand Down
58 changes: 51 additions & 7 deletions doc/src/min_modify.txt
Expand Up @@ -13,11 +13,15 @@ min_modify command :h3
min_modify keyword values ... :pre

one or more keyword/value pairs may be listed :ulb,l
keyword = {dmax} or {line} or {alpha_damp} or {discrete_factor}
keyword = {dmax} or {line} or {norm} or {alpha_damp} or {discrete_factor}
{dmax} value = max
max = maximum distance for line search to move (distance units)
{line} value = {backtrack} or {quadratic} or {forcezero}
backtrack,quadratic,forcezero = style of linesearch to use
{line} value = {backtrack} or {quadratic} or {forcezero} or {spin_cubic} or {spin_none}
backtrack,quadratic,forcezero,spin_cubic,spin_none = style of linesearch to use
{norm} value = {two} or {max}
two = Euclidean two-norm (length of 3N vector)
inf = max force component across all 3-vectors
max = max force norm across all 3-vectors
{alpha_damp} value = damping
damping = fictitious Gilbert damping for spin minimization (adim)
{discrete_factor} value = factor
Expand Down Expand Up @@ -69,6 +73,28 @@ difference of two large values (energy before and energy after) and
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/cg} and {spin/lbfgs} using
the {norm} keyword.
The default {two} norm computes the 2-norm (Euclidean length) of the
global force vector:

:c,image(Eqs/norm_two.jpg)

The {max} norm computes the length of the 3-vector force
for each atom (2-norm), and takes the maximum value of those across
all atoms

:c,image(Eqs/norm_max.jpg)

The {inf} norm takes the maximum component across the forces of
all atoms in the system:

:c,image(Eqs/norm_inf.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
Expand All @@ -77,15 +103,33 @@ a given magnetic system.
Keyword {discrete_factor} defines a discretization factor for the
adaptive timestep used in the {spin} minimization.
See "min_spin"_min_spin.html for more information about those
quantities.
Default values are {alpha_damp} = 1.0 and {discrete_factor} = 10.0.
quantities.

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/lbfgs}
and {spin/cg}. Convergence of {spin/lbfgs} can be more robust if
{spin_cubic} line search is used.

[Restrictions:] none
[Restrictions:]

For magnetic GNEB calculations, only {spin_none} value for {line} keyword can be used
when styles {spin/cg} and {spin/lbfgs} are employed.
See "neb/spin"_neb_spin.html for more explanation.

[Related commands:]

"min_style"_min_style.html, "minimize"_minimize.html

[Default:]

The option defaults are dmax = 0.1 and line = quadratic.
The option defaults are dmax = 0.1, line = quadratic and norm = two.

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.
53 changes: 46 additions & 7 deletions doc/src/min_spin.txt
Expand Up @@ -6,14 +6,19 @@
:line

min_style spin command :h3
min_style spin/cg command :h3
min_style spin/lbfgs command :h3

[Syntax:]

min_style spin :pre
min_style spin
min_style spin/cg
min_style spin/lbfgs :pre

[Examples:]

min_style spin :pre
min_style spin/lbfgs
min_modify line spin_cubic discrete_factor 10.0 :pre

[Description:]

Expand Down Expand Up @@ -46,10 +51,39 @@ definition of this timestep.
{discrete_factor} can be defined with the "min_modify"_min_modify.html
command.

NOTE: The {spin} style replaces the force tolerance by a torque
tolerance. See "minimize"_minimize.html for more explanation.
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/cg} to a line search procedure, and to modify the
discretization factor {discrete_factor}.
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}.

[Restrictions:]
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/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/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/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/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.

[Restrictions:]

This minimization procedure is only applied to spin degrees of
freedom for a frozen lattice configuration.
Expand All @@ -61,5 +95,10 @@ freedom for a frozen lattice configuration.

[Default:]

The option defaults are {alpha_damp} = 1.0 and {discrete_factor} =
10.0.
The option defaults are {alpha_damp} = 1.0, {discrete_factor} =
10.0, {line} = spin_none and {norm} = euclidean.

:line

:link(Ivanov1)
[(Ivanov)] Ivanov, Uzdin, Jonsson. arXiv preprint arXiv:1904.02669, (2019).
18 changes: 16 additions & 2 deletions doc/src/min_style.txt
Expand Up @@ -11,7 +11,7 @@ min_style command :h3

min_style style :pre

style = {cg} or {cg/kk} or {hftn} or {sd} or {quickmin} or {fire} or {spin} :ul
style = {cg} or {hftn} or {sd} or {quickmin} or {fire} or {spin} or {spin/cg} or {spin/lbfgs} :ul

[Examples:]

Expand Down Expand Up @@ -64,11 +64,25 @@ a minimization.

Style {spin} is a damped spin dynamics with an adaptive
timestep.
See the "min/spin"_min_spin.html doc page for more information.

Style {spin/cg} uses an orthogonal spin optimization (OSO)
combined to a conjugate gradient (CG) approach to minimize spin
configurations.

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/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/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.

NOTE: The damped dynamic minimizers use whatever timestep you have
defined via the "timestep"_timestep.html command. Often they will
converge more quickly if you use a timestep about 10x larger than you
Expand Down
11 changes: 6 additions & 5 deletions doc/src/minimize.txt
Expand Up @@ -104,12 +104,13 @@ the line search fails because the step distance backtracks to 0.0
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} replaces
NOTE: the "minimization style"_min_style.html {spin},
{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
global torque vector (defined as the cross product between the
spins and their precession vectors omega) is less than {ftol},
or if any of the other criteria are met.
The minimization procedure stops if the 2-norm (length) of the torque vector on atom
(defined as the cross product between the
atomic spin and its precession vectors omega) is less than {ftol},
or if any of the other criteria are met. Torque have the same units as the energy.

NOTE: You can also use the "fix halt"_fix_halt.html command to specify
a general criterion for exiting a minimization, that is a calculation
Expand Down
18 changes: 11 additions & 7 deletions doc/src/neb_spin.txt
Expand Up @@ -59,9 +59,9 @@ performance speed-up you would see with one or more physical
processors per replica. See the "Howto replica"_Howto_replica.html
doc page for further discussion.

NOTE: As explained below, a GNEB calculation performs a damped dynamics
minimization across all the replicas. The "spin"_min_spin.html
style minimizer has to be defined in your input script.
NOTE: As explained below, a GNEB calculation performs a
minimization across all the replicas. One of the "spin"_min_spin.html
style minimizers has to be defined in your input script.

When a GNEB calculation is performed, it is assumed that each replica
is running the same system, though LAMMPS does not check for this.
Expand Down Expand Up @@ -170,10 +170,11 @@ command is issued.
:line

A NEB calculation proceeds in two stages, each of which is a
minimization procedure, performed via damped dynamics. To enable
this, you must first define a damped spin dynamics
"min_style"_min_style.html, using the {spin} style (see
"min_spin"_min_spin.html for more information).
minimization procedure. To enable
this, you must first define a
"min_style"_min_style.html, using either the {spin},
{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.

Expand Down Expand Up @@ -358,6 +359,9 @@ 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.

For magnetic GNEB calculations, only {spin_none} value for {line} keyword can be used
when styles {spin/cg} and {spin/lbfgs} are employed.

:line

[Related commands:]
Expand Down
5 changes: 2 additions & 3 deletions doc/src/pair_spin_dipole.txt
Expand Up @@ -25,9 +25,8 @@ pair_coeff * * 10.0
pair_coeff 2 3 8.0 :pre

pair_style spin/dipole/long 9.0
pair_coeff * * 1.0 1.0
pair_coeff 2 3 1.0 1.0 2.5 4.0 scale 0.5
pair_coeff 2 3 1.0 1.0 2.5 4.0 :pre
pair_coeff * * 10.0
pair_coeff 2 3 6.0 :pre

[Description:]

Expand Down
5 changes: 5 additions & 0 deletions doc/utils/sphinx-config/false_positives.txt
Expand Up @@ -275,6 +275,7 @@ Broadwell
Broglie
brownian
brownw
Broyden
Bryantsev
Btarget
btype
Expand Down Expand Up @@ -988,6 +989,7 @@ gmask
Gmask
gneb
GNEB
Goldfarb
googlemail
Gordan
GPa
Expand Down Expand Up @@ -1405,6 +1407,7 @@ Laupretre
lavenderblush
lawngreen
lB
lbfgs
lbl
LBtype
lcbop
Expand Down Expand Up @@ -2041,6 +2044,7 @@ Orsi
ortho
orthonormal
orthorhombic
oso
ot
Otype
Ouldridge
Expand Down Expand Up @@ -2513,6 +2517,7 @@ setvel
sfftw
Sg
Shan
Shanno
shapex
shapey
shapez
Expand Down