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

Replace eigensolver code in LAMMPS with math_eigen.h and updated docs #2347

Merged
merged 31 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7f6fc8a
updated math_eigen.h and moved it into the main "src" directory
jewettaij Sep 4, 2020
57f82ab
updated all code in LAMMPS to use the open-source "math_eigen.h" inst…
jewettaij Sep 5, 2020
58fa72d
replaced all numerical recipes jacobi() code with code from "math_eig…
jewettaij Sep 5, 2020
4b66414
fixed a type error in math_eigen.h
jewettaij Sep 5, 2020
7cb774e
some corrections before rewriting the doxygen comments to comply with…
jewettaij Sep 5, 2020
4ad6d99
updated documentation files: "pg_developer.rst", "math_eigen.h", and …
jewettaij Sep 6, 2020
c16321e
purged greek characters from "pd_developer.rst"
jewettaij Sep 6, 2020
2ee2009
removed assert() statements from "superpose3d.h"
jewettaij Sep 6, 2020
b295222
changed the "trim_and_count_words()" function declaration in "utils.h…
jewettaij Sep 6, 2020
d97e8d8
fixed linker problems in "utils.h" and "utils.cpp"
jewettaij Sep 6, 2020
eb6f7f9
Merge branch 'master' into math_eigen
jewettaij Sep 6, 2020
fabf762
reverting to previous version of util.h and util.cpp
jewettaij Sep 6, 2020
a57a140
bug fix fix unit tests, improve doc readability, and to prevent accid…
jewettaij Sep 7, 2020
f329d56
updated pg_developer.rst
jewettaij Sep 7, 2020
6ade5dd
changed the default sorting options in "jacobi3()" to be more similar…
jewettaij Sep 9, 2020
56b1300
reverted the default behavior of "jacobi3()". By default it now sort…
jewettaij Sep 9, 2020
2ab0878
remreduced compile time by removing unnecessary instantiations from m…
jewettaij Sep 9, 2020
3bacf97
Merge branch 'master' into math_eigen
jewettaij Sep 9, 2020
ed14793
moved eigensolver documentation into pg_dev_utils.rst
jewettaij Sep 9, 2020
f599869
Merge branch 'master' into math_eigen
akohlmey Sep 16, 2020
48ad860
only do Zstd tests if it is enabled/found.
akohlmey Sep 16, 2020
981d60f
update rigid tests for new eigensolver
akohlmey Sep 16, 2020
f7a939d
update atom_style tester for new jacobi implementation
akohlmey Sep 16, 2020
10991ee
separate the MathEigen implementation into its own header file
akohlmey Sep 16, 2020
fd9e39b
update docs
akohlmey Sep 16, 2020
0931cdd
relax epsilon for rigid body integrators
akohlmey Sep 16, 2020
bd542ef
include math_eigen.h, remove it from .gitignore
akohlmey Sep 16, 2020
942ed3a
update copyright headers to match LAMMPS' conventions
akohlmey Sep 16, 2020
96f4178
add URLs to upstream projects for eigensolvers
akohlmey Sep 16, 2020
a8a9fb6
adapt unit test for Jacobi class
akohlmey Sep 16, 2020
b176cdf
remove trailing whitespace
akohlmey Sep 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/doxygen/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ INPUT = @LAMMPS_SOURCE_DIR@/utils.cpp \
@LAMMPS_SOURCE_DIR@/my_page.h \
@LAMMPS_SOURCE_DIR@/my_pool_chunk.cpp \
@LAMMPS_SOURCE_DIR@/my_pool_chunk.h \
@LAMMPS_SOURCE_DIR@/math_eigen.h \

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down
49 changes: 47 additions & 2 deletions doc/src/pg_dev_utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ strings into specific types of numbers with checking for validity. This
reduces redundant implementations and encourages consistent behavior.

I/O with status check
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^

These are wrappers around the corresponding C library calls like
``fgets()`` or ``fread()``. They will check if there were errors
Expand All @@ -26,6 +26,8 @@ indicating the name of the problematic file, if possible.
.. doxygenfunction:: sfread
:project: progguide

----------

String to number conversions with validity check
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -281,6 +283,8 @@ This code example should produce the following output:
:project: progguide
:members: what

----------

File reader classes
====================

Expand Down Expand Up @@ -333,6 +337,8 @@ convert numbers, so that LAMMPS will be aborted.

A file that would be parsed by the reader code fragment looks like this:

.. parsed-literal::

# DATE: 2015-02-19 UNITS: metal CONTRIBUTOR: Ray Shan CITATION: Streitz and Mintmire, Phys Rev B, 50, 11996-12003 (1994)
#
# X (eV) J (eV) gamma (1/\AA) zeta (1/\AA) Z (e)
Expand All @@ -351,7 +357,6 @@ A file that would be parsed by the reader code fragment looks like this:
:project: progguide
:members:


----------

Memory pool classes
Expand Down Expand Up @@ -415,3 +420,43 @@ its size is registered later with :cpp:func:`vgot()
.. doxygenclass:: LAMMPS_NS::MyPoolChunk
:project: progguide
:members:

----------

Eigensolver functions
=====================

The ``MathEigen`` sub-namespace of the ``LAMMPS_NS`` namespace contains
functions and classes for eigensolvers. Currently only the
:cpp:func:`jacobi3 function <MathEigen::jacobi3>` is used in various
places in LAMMPS. That function is built on top of a group of more
generic eigensolvers that are maintained in the ``math_eigen_impl.h``
header file. This header contains the implementation of three template
classes:

#. "Jacobi" calculates all of the eigenvalues and eigenvectors
of a dense, symmetric, real matrix.

#. The "PEigenDense" class only calculates the principal eigenvalue
(ie. the largest or smallest eigenvalue), and its corresponding
eigenvector. However it is much more efficient than "Jacobi" when
applied to large matrices (larger than 13x13). PEigenDense also can
understand complex-valued Hermitian matrices.

#. The "LambdaLanczos" class is a generalization of "PEigenDense" which can be
applied to arbitrary sparse matrices.

The "math_eigen_impl.h" code is an amalgamation of `jacobi_pd
<https://github.com/jewettaij/jacobi_pd>`_ by Andrew Jewett at Scripps
Research (under CC0-1.0 license) and `Lambda Lanczos
<https://github.com/mrcdr/lambda-lanczos>`_ by Yuya Kurebayashi at
Tohoku University (under MIT license)

----------

.. doxygenfunction:: MathEigen::jacobi3(double const *const *mat, double *eval, double **evec)
:project: progguide

.. doxygenfunction:: MathEigen::jacobi3(double const mat[3][3], double *eval, double evec[3][3])
:project: progguide

41 changes: 39 additions & 2 deletions doc/utils/sphinx-config/false_positives.txt
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ Buyl
Bybee
bz
cadetblue
calc
calibre
caltech
Caltech
Expand Down Expand Up @@ -397,6 +398,7 @@ ChiralIDs
chiralIDs
chirality
Cho
ChooseOffset
chris
Christoph
Chu
Expand Down Expand Up @@ -469,6 +471,7 @@ config
configfile
configurational
conformational
ConstMatrix
Contrib
cooperativity
coord
Expand Down Expand Up @@ -639,7 +642,10 @@ dhex
dia
diag
diagonalization
diagonalize
diagonalized
diagonalizers
diagonalizing
Diallo
diel
differentiable
Expand Down Expand Up @@ -778,8 +784,15 @@ Eggebrecht
ehex
eHEX
Ei
Eigen
Eigensolve
eigen
eigensolve
eigensolver
eigensolvers
eigendecomposition
eigenvalue
eigenvalues
eigenvector
eigenvectors
eij
Eij
Eijnden
Expand Down Expand Up @@ -893,6 +906,11 @@ eV
evalue
Evanseck
evdwl
evector
evec
evecs
eval
evals
Everaers
Evgeny
evirials
Expand Down Expand Up @@ -1069,6 +1087,7 @@ Germann
Germano
gerolf
Gerolf
Gershgorin
gettimeofday
gewald
Gezelter
Expand Down Expand Up @@ -1184,6 +1203,7 @@ Henkelman
Henkes
henrich
Henrich
Hermitian
Herrmann
Hertizian
hertzian
Expand Down Expand Up @@ -1257,6 +1277,7 @@ icosahedral
idealgas
IDR
idx
ie
ielement
ieni
ifdefs
Expand All @@ -1279,6 +1300,7 @@ Imageint
Imagemagick
imd
Impey
impl
impropers
Impropers
includelink
Expand Down Expand Up @@ -1348,6 +1370,8 @@ isothermal
isotropically
isovolume
Isralewitz
iter
iters
iteratively
Ith
Itsets
Expand Down Expand Up @@ -1524,6 +1548,7 @@ Kub
Kubo
Kumagai
Kumar
Kurebayashi
Kuronen
Kusters
Kutta
Expand All @@ -1534,12 +1559,14 @@ Ladd
lagrangian
lambdai
lamda
LambdaLanczos
lammps
Lammps
LAMMPS
lammpsplot
Lampis
Lamoureux
Lanczos
Lande
Landron
langevin
Expand Down Expand Up @@ -1847,6 +1874,7 @@ Microscale
midnightblue
mie
Mie
Mij
Mikami
Militzer
Minary
Expand Down Expand Up @@ -1945,6 +1973,7 @@ Muccioli
mui
Mukherjee
Mulders
mult
multi
multibody
Multibody
Expand Down Expand Up @@ -2331,6 +2360,7 @@ peachpuff
Pearlman
Pedersen
peID
PEigenDense
Peng
peptide
peratom
Expand Down Expand Up @@ -2559,6 +2589,8 @@ rdf
RDideal
rdx
reacter
realTypeMap
real_t
README
realtime
reamin
Expand Down Expand Up @@ -2741,6 +2773,7 @@ Schuring
Schwen
screenshot
screenshots
Scripps
Scripta
sdk
sdpd
Expand Down Expand Up @@ -3069,6 +3102,7 @@ Tmin
tmp
tN
Tobias
Tohoku
tokenizer
tokyo
tol
Expand Down Expand Up @@ -3132,6 +3166,8 @@ tu
Tuckerman
tue
tunable
tuple
tuples
Turkand
Tutein
tweakable
Expand Down Expand Up @@ -3425,6 +3461,7 @@ Yuh
yukawa
Yukawa
Yusof
Yuya
yx
yy
yz
Expand Down
1 change: 0 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/pair_kim.h

/superpose3d.h
/math_eigen.h

/kokkos.cpp
/kokkos.h
Expand Down
3 changes: 2 additions & 1 deletion src/BODY/body_nparticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "atom_vec_body.h"
#include "error.h"
#include "math_extra.h"
#include "math_eigen.h"
#include "memory.h"
#include "my_pool_chunk.h"

Expand Down Expand Up @@ -136,7 +137,7 @@ void BodyNparticle::data_body(int ibonus, int ninteger, int ndouble,

double *inertia = bonus->inertia;
double evectors[3][3];
int ierror = MathExtra::jacobi(tensor,inertia,evectors);
int ierror = MathEigen::jacobi3(tensor,inertia,evectors);
if (ierror) error->one(FLERR,
"Insufficient Jacobi rotations for body nparticle");

Expand Down
3 changes: 2 additions & 1 deletion src/BODY/body_rounded_polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "domain.h"
#include "error.h"
#include "math_extra.h"
#include "math_eigen.h"
#include "memory.h"
#include "my_pool_chunk.h"

Expand Down Expand Up @@ -198,7 +199,7 @@ void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,

double *inertia = bonus->inertia;
double evectors[3][3];
int ierror = MathExtra::jacobi(tensor,inertia,evectors);
int ierror = MathEigen::jacobi3(tensor,inertia,evectors);
if (ierror) error->one(FLERR,
"Insufficient Jacobi rotations for body nparticle");

Expand Down
3 changes: 2 additions & 1 deletion src/BODY/body_rounded_polyhedron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "atom_vec_body.h"
#include "error.h"
#include "math_extra.h"
#include "math_eigen.h"
#include "memory.h"
#include "my_pool_chunk.h"

Expand Down Expand Up @@ -242,7 +243,7 @@ void BodyRoundedPolyhedron::data_body(int ibonus, int ninteger, int ndouble,

double *inertia = bonus->inertia;
double evectors[3][3];
int ierror = MathExtra::jacobi(tensor,inertia,evectors);
int ierror = MathEigen::jacobi3(tensor,inertia,evectors);
if (ierror) error->one(FLERR,
"Insufficient Jacobi rotations for body nparticle");

Expand Down
Loading