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

Implementation of pair_style uf3 and uf3/kk #4110

Open
wants to merge 77 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
6dded43
Added ml-uf3 src files
monk-04 Mar 25, 2024
53c6959
Added src files for uf3/kk
monk-04 Mar 25, 2024
9a23ddf
Added ml-uf3 to cmake and make files
monk-04 Mar 25, 2024
923e251
Added documentation for ml-uf3
monk-04 Mar 25, 2024
a720d0d
Added ml-uf3 potential files
monk-04 Mar 25, 2024
5c536c8
Added ml-uf3 unittest
monk-04 Mar 25, 2024
d55f750
Fixed typos in the UF3 equation
monk-04 Mar 25, 2024
de43263
Fixed lammps developer email-id and contributing authors section. Rem…
monk-04 Mar 25, 2024
06c4fc6
Removed LAMMPS errordocs
monk-04 Mar 25, 2024
b280999
fixed trailing whitespaces
monk-04 Mar 25, 2024
4e95db1
Added uf3 details to Commands_pair, Packages_details and Packages_list
monk-04 Mar 26, 2024
3a34b3e
Added uf3 examples to the examples directory
monk-04 Mar 26, 2024
ff39a03
Removed trailing whitespaces
monk-04 Mar 26, 2024
dc0b0d8
Added example potential files for W
monk-04 Mar 26, 2024
7e09353
add ML-UF3 to compatible CMake preset files
akohlmey Mar 27, 2024
f9a0ec8
update .gitignore
akohlmey Mar 27, 2024
0d7c41b
update code owners list
akohlmey Mar 27, 2024
7323364
move examples
akohlmey Mar 27, 2024
fda433a
reformat and fix spelling and related issues
akohlmey Mar 27, 2024
713b308
update ML-UF3 examples
akohlmey Mar 27, 2024
fca23da
some style cleanup and simplified pair_style and pair_coeff input
akohlmey Mar 27, 2024
eb89c7a
examples folder was moved
akohlmey Mar 28, 2024
392c3b6
manybody and single flag need to be changed from the default when 2-b…
akohlmey Mar 28, 2024
a6e5c8b
update more files and docs for .uf3 potential file extension
akohlmey Mar 28, 2024
ecb5704
some formatting and logic cleanup.
akohlmey Mar 28, 2024
a26c281
Merge pull request #1 from akohlmey/ml-uf3
monk-04 Mar 28, 2024
34f8884
update example logs
akohlmey Mar 29, 2024
7c3ac31
remove dead code
akohlmey Mar 29, 2024
379e212
add system error message with failure to open potential
akohlmey Mar 29, 2024
3aae2d0
apply clang-format
akohlmey Mar 29, 2024
2219e76
call utils::logmesg() only on rank 0, use c++ string comparisons, rem…
akohlmey Mar 29, 2024
6bdf981
don't use pow() function for simple square
akohlmey Mar 29, 2024
584137f
remove num_of_elements class variable, just use local copy of atom->n…
akohlmey Mar 29, 2024
c526287
initialize all class pointers to null, delete all allocated storage
akohlmey Mar 29, 2024
1fff0a3
drop log messages
akohlmey Mar 29, 2024
a6230ba
replace pow(x,2) and pow(x,3) with square() and cube()
akohlmey Mar 29, 2024
42dcc76
Merge pull request #2 from akohlmey/ml-uf3
monk-04 Apr 1, 2024
801ceea
Pimplifying the code Attempt-1
monk-04 Apr 1, 2024
72772c1
Merge branch 'lammps:develop' into ml-uf3
monk-04 Apr 1, 2024
d3bc4c7
Removed commented out code
monk-04 Apr 2, 2024
7281f93
Added code to check if 'UNITS:' metadata is present in the pot file o…
monk-04 Apr 2, 2024
3734252
Replaced the A_A.uf3 and A_A_A.uf3 with uf3 lammps pot files for Nb
monk-04 Apr 2, 2024
1ef7b81
Updated A_A.uf3 to Nb_Nb.uf3 and A_A_A.uf3 to Nb_Nb_Nb.uf3
monk-04 Apr 2, 2024
887ce49
Removed old pot files
monk-04 Apr 2, 2024
0809d8b
Updated documentation about METADATA in the uf3 lammps pot files
monk-04 Apr 2, 2024
c502dd4
Fixed trailing whitespace
monk-04 Apr 2, 2024
01b1d04
Merge branch 'lammps:develop' into ml-uf3
monk-04 Apr 13, 2024
fcf8500
Added uf3_read_unified_pot_file() to read single potential file on ra…
monk-04 Apr 15, 2024
cf729fc
Added new constructor functions in uf3_pair_bspline and uf3_triplet_b…
monk-04 Apr 15, 2024
f6c8bd1
Updated pair_coeff in unittest to read only one potential file; added…
monk-04 Apr 15, 2024
d468ee8
Updated the code as we are no longer using std::vector for knots and …
monk-04 Apr 15, 2024
4c1be99
Removed reference to std::vector knots and coefficients; commented ou…
monk-04 Apr 15, 2024
18ae982
Updated the documentation about UF3 LAMMPS potential file
monk-04 Apr 17, 2024
8ceb6f0
Merge pull request #4 from monk-04/ml-uf3
monk-04 Apr 17, 2024
3310180
Fixed trailing whitespaces
monk-04 Apr 17, 2024
42a4e63
Merge branch 'lammps:develop' into ml-uf3
monk-04 Apr 17, 2024
dbca2b0
Made 'constants' variable public
monk-04 May 2, 2024
9915f86
Removed UFBS2b and UFBS3b std::vector objects.
monk-04 May 2, 2024
e55d774
Removed trailing whitespace
monk-04 May 2, 2024
49181bf
constants was changed from std::vector to fixed length array
monk-04 May 2, 2024
f02c65e
Removed uf3_pair_bspline and uf3_triplet_bspline
monk-04 May 2, 2024
5f2cae0
Commented out the uniform knot spacing logic as for more than 1 proce…
monk-04 May 2, 2024
3340dd5
Removed unused variables and reordered the code
monk-04 May 2, 2024
ab8e4b7
Fixed trailing whitespace
monk-04 May 2, 2024
4a8ed1b
Removed dead code, fixed trailing whitespace
monk-04 May 2, 2024
94ab3c2
Merge pull request #5 from monk-04/ml-uf3
monk-04 May 2, 2024
759ce70
Merge branch 'lammps:develop' into ml-uf3
monk-04 May 2, 2024
a7f4fc1
Fixed bug with uniform knot spacing
monk-04 May 3, 2024
1cfbc04
Initialize setflag, n2b_coeff_array_size, n2b_knots_array_size, n3b_c…
monk-04 May 3, 2024
fe24dde
Removed trailing whitespace
monk-04 May 3, 2024
2f488cc
Merge pull request #6 from monk-04/ml-uf3
monk-04 May 4, 2024
9e755cd
Merge branch 'lammps:develop' into ml-uf3
monk-04 May 13, 2024
49f2022
Merge branch 'develop' into ml-uf3
akohlmey May 14, 2024
4302d65
fix spelling
akohlmey May 14, 2024
17c0994
remove unused variables
akohlmey May 14, 2024
1f52d17
update ML-UF3 example
akohlmey May 14, 2024
991f4ed
Merge pull request #7 from akohlmey/ml-uf3
monk-04 May 14, 2024
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ src/ML-HDNNP/* @singraber
src/ML-IAP/* @athomps
src/ML-PACE/* @yury-lysogorskiy
src/ML-POD/* @exapde
src/ML-UF3/* @monk-04
src/MOFFF/* @hheenen
src/MOLFILE/* @akohlmey
src/NETCDF/* @pastewka
Expand Down
1 change: 1 addition & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ set(STANDARD_PACKAGES
ML-RANN
ML-SNAP
ML-POD
ML-UF3
MOFFF
MOLECULE
MOLFILE
Expand Down
1 change: 1 addition & 0 deletions cmake/presets/all_off.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ set(ALL_PACKAGES
ML-QUIP
ML-RANN
ML-SNAP
ML-UF3
MOFFF
MOLECULE
MOLFILE
Expand Down
1 change: 1 addition & 0 deletions cmake/presets/all_on.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ set(ALL_PACKAGES
ML-QUIP
ML-RANN
ML-SNAP
ML-UF3
MOFFF
MOLECULE
MOLFILE
Expand Down
1 change: 1 addition & 0 deletions cmake/presets/mingw-cross.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(WIN_PACKAGES
ML-POD
ML-RANN
ML-SNAP
ML-UF3
MOFFF
MOLECULE
MOLFILE
Expand Down
1 change: 1 addition & 0 deletions cmake/presets/most.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set(ALL_PACKAGES
ML-IAP
ML-POD
ML-SNAP
ML-UF3
MOFFF
MOLECULE
OPENMP
Expand Down
1 change: 1 addition & 0 deletions cmake/presets/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ set(WIN_PACKAGES
ML-IAP
ML-POD
ML-SNAP
ML-UF3
MOFFF
MOLECULE
MOLFILE
Expand Down
1 change: 1 addition & 0 deletions doc/src/Commands_pair.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ OPT.
* :doc:`tip4p/long/soft (o) <pair_fep_soft>`
* :doc:`tri/lj <pair_tri_lj>`
* :doc:`ufm (got) <pair_ufm>`
* :doc:`uf3 (k) <pair_uf3>`
* :doc:`vashishta (gko) <pair_vashishta>`
* :doc:`vashishta/table (o) <pair_vashishta>`
* :doc:`wf/cut <pair_wf_cut>`
Expand Down
26 changes: 26 additions & 0 deletions doc/src/Packages_details.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ page gives those details.
* :ref:`ML-QUIP <PKG-ML-QUIP>`
* :ref:`ML-RANN <PKG-ML-RANN>`
* :ref:`ML-SNAP <PKG-ML-SNAP>`
* :ref:`ML-UF3 <PKG-ML-UF3>`
* :ref:`MOFFF <PKG-MOFFF>`
* :ref:`MOLECULE <PKG-MOLECULE>`
* :ref:`MOLFILE <PKG-MOLFILE>`
Expand Down Expand Up @@ -1925,6 +1926,31 @@ computes which analyze attributes of the potential.

----------

.. _PKG-ML-UF3:

ML-UF3 package
--------------

**Contents:**

A pair style for the ultra-fast force field potentials (UF3). UF3 is a
methodology for deriving a highly accurate classical potential which is
fast to evaluate and is fitted to a large archives of quantum mechanical
(DFT) data. The use of b-spline basis set in UF3 enables the rapid
evaluation of 2-body and 3-body interactions.

**Authors:** Ajinkya C Hire (University of Florida),
Hendrik Krass (University of Constance),
Matthias Rupp (Luxembourg Institute of Science and Technology),
Richard Hennig (University of Florida)

**Supporting info:**

* src/ML-UF3: filenames -> commands
* :doc:`pair_style uf3 <pair_uf3>`
* examples/uf3
* https://github.com/uf3/uf3

.. _PKG-MOFFF:

MOFFF package
Expand Down
5 changes: 5 additions & 0 deletions doc/src/Packages_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ whether an extra library is needed to build and use the package:
- :doc:`pair_style snap <pair_snap>`
- snap
- no
* - :ref:`ML-UF3 <PKG-ML-UF3>`
- quantum-fitted ultra fast potentials
- :doc:`pair_style uf3 <pair_uf3>`
- PACKAGES/uf3
- no
* - :ref:`MOFFF <PKG-MOFFF>`
- styles for `MOF-FF <MOFplus_>`_ force field
- :doc:`pair_style buck6d/coul/gauss <pair_buck6d_coul_gauss>`
Expand Down
1 change: 1 addition & 0 deletions doc/src/pair_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ accelerated styles exist.
* :doc:`tracker <pair_tracker>` - monitor information about pairwise interactions
* :doc:`tri/lj <pair_tri_lj>` - LJ potential between triangles
* :doc:`ufm <pair_ufm>` -
* :doc:`uf3 <pair_uf3>` - UF3 machine-learning potential
* :doc:`vashishta <pair_vashishta>` - Vashishta 2-body and 3-body potential
* :doc:`vashishta/table <pair_vashishta>` -
* :doc:`wf/cut <pair_wf_cut>` - Wang-Frenkel Potential for short-ranged interactions
Expand Down
213 changes: 213 additions & 0 deletions doc/src/pair_uf3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
.. index:: pair_style uf3
.. index:: pair_style uf3/kk

pair_style uf3 command
======================

Accelerator Variants: *uf3/kk*

Syntax
""""""

.. code-block:: LAMMPS

pair_style style BodyFlag

* style = *uf3* or *uf3/kk*

.. parsed-literal::

BodyFlag = Indicates whether to calculate only 2-body or 2 and 3-body interactions. Possible values: 2 or 3

Examples
""""""""

.. code-block:: LAMMPS

pair_style uf3 3
pair_coeff * * Nb.uf3 Nb

pair_style uf3 2
pair_coeff * * NbSn.uf3 Nb Sn

pair_style uf3 3
pair_coeff * * NbSn.uf3 Nb Sn

Description
"""""""""""

.. versionadded:: TBD

The *uf3* style computes the :ref:`Ultra-Fast Force Fields (UF3)
<Xie23>` potential, a machine-learning interatomic potential. In UF3,
the total energy of the system is defined via two- and three-body
interactions:

.. math::

E & = \sum_{i,j} V_2(r_{ij}) + \sum_{i,j,k} V_3 (r_{ij},r_{ik},r_{jk}) \\
V_2(r_{ij}) & = \sum_{n=0}^N c_n B_n(r_{ij}) \\
V_3 (r_{ij},r_{ik},r_{jk}) & = \sum_{l=0}^{N_l} \sum_{m=0}^{N_m} \sum_{n=0}^{N_n} c_{l,m,n} B_l(r_{ij}) B_m(r_{ik}) B_n(r_{jk})

where :math:`V_2(r_{ij})` and :math:`V_3 (r_{ij},r_{ik},r_{jk})` are the
two- and three-body interactions, respectively. For the two-body the
summation is over all neighbors J and for the three-body the summation
is over all neighbors J and K of atom I within a cutoff distance
determined from the potential files. :math:`B_n(r_{ij})` are the cubic
b-spline basis, :math:`c_n` and :math:`c_{l,m,n}` are the machine-learned
interaction parameters and :math:`N`, :math:`N_l`, :math:`N_m`, and
:math:`N_n` denote the number of basis functions per spline or tensor
spline dimension.

With *uf3* style only a single pair_coeff command is used to indicate the
UF3 LAMMPS potential file containing all the two- and three-body interactions
followed by N additional arguments specifying the mapping of UF3 elements to
LAMMPS atom types, where N is the number of LAMMPS atom types:

* UF3 LAMMPS potential file
* N elements names = mapping of UF3 elements to atom types

As an example, if a LAMMPS simulation contains 2 atom types (elements
'A' and 'B'), the pair_coeff command will be:

.. code-block:: LAMMPS

pair_style uf3 3
pair_coeff * * AB.uf3 A B

The AB.uf3 file should contain all two-body (A-A, A-B, B-B) and three-body
(A-A-A, A-A-B, A-B-B, B-A-A, B-A-B, B-B-B).

If a value of "2" is specified in the :code:`pair_style uf3` command,
only the two-body potentials are needed. For 3-body interaction the
first atom type is the central atom. We recommend using the
:code:`generate_uf3_lammps_pots.py` script (found `here
<https://github.com/uf3/uf3/tree/develop/lammps_plugin/scripts>`_) for
generating the UF3 LAMMPS potential file from the UF3 JSON potentials.

----------

UF3 LAMMPS potential file in the *potentials* directory of the LAMMPS
distribution have a ".uf3" suffix. The interaction block in UF3 LAMMPS potential
file should start with :code:`#UF3 POT` and end with :code:`#` characters.
Following shows the format of a generic 2-body and 3-body potential block in
UF3 LAMMPS potential file-

.. code-block:: LAMMPS

#UF3 POT UNITS: units DATE: POT_GEN_DATE AUTHOR: AUTHOR_NAME CITATION: CITE
2B ELEMENT1 ELEMENT2 LEADING_TRIM TRAILING_TRIM
Rij_CUTOFF NUM_OF_KNOTS
BSPLINE_KNOTS
NUM_OF_COEFF
COEFF
#
#UF3 POT UNITS: units DATE: POT_GEN_DATE AUTHOR: AUTHOR_NAME CITATION: CITE
3B ELEMENT1 ELEMENT2 ELEMENT3 LEADING_TRIM TRAILING_TRIM
Rjk_CUTOFF Rik_CUTOFF Rij_CUTOFF NUM_OF_KNOTS_JK NUM_OF_KNOTS_IK NUM_OF_KNOTS_IJ
BSPLINE_KNOTS_FOR_JK
BSPLINE_KNOTS_FOR_IK
BSPLINE_KNOTS_FOR_IJ
SHAPE_OF_COEFF_MATRIX[I][J][K]
COEFF_MATRIX[0][0][K]
COEFF_MATRIX[0][1][K]
COEFF_MATRIX[0][2][K]
.
.
.
COEFF_MATRIX[1][0][K]
COEFF_MATRIX[1][1][K]
COEFF_MATRIX[1][2][K]
.
.
.
#

The second line indicates whether the block contains data for 2-body
(:code:`2B`) or 3-body (:code:`3B`) interaction. This is followed by element
combination interaction, :code:`LEADING_TRIM` and :code:`TRAILING_TRIM`
number on the same line. The current implementation is only tested for
:code:`LEADING_TRIM=0` and :code:`TRAILING_TRIM=3`.
If other values are used LAMMPS is terminated after issuing an error message.
The :code:`Rij_CUTOFF` sets the 2-body cutoff for the interaction described
by the potential block. :code:`NUM_OF_KNOTS` is the number of knots
(or the length of the knot vector) present on the very next line. The
:code:`BSPLINE_KNOTS` line should contain all the knots in ascending order.
:code:`NUM_OF_COEFF` is the number of coefficients in the :code:`COEFF` line.
All the numbers in the BSPLINE_KNOTS and COEFF line should be space-separated.
Similar to the 2-body potential block, the third line sets the cutoffs and
length of the knots. The cutoff distance between atom-type I and J is
:code:`Rij_CUTOFF`, atom-type I and K is :code:`Rik_CUTOFF` and between
J and K is :code:`Rjk_CUTOFF`.

.. note::

The current implementation only works for UF3 potentials with cutoff
distances for 3-body interactions that follows
:code:`2Rij_CUTOFF=2Rik_CUTOFF=Rjk_CUTOFF` relation.

The :code:`BSPLINE_KNOTS_FOR_JK`, :code:`BSPLINE_KNOTS_FOR_IK`, and
:code:`BSPLINE_KNOTS_FOR_IJ` lines (note the order) contain the knots in
increasing order for atoms J and K, I and K, and atoms I and J
respectively. The number of knots is defined by the
:code:`NUM_OF_KNOTS_*` characters in the previous line. The shape of
the coefficient matrix is defined on the
:code:`SHAPE_OF_COEFF_MATRIX[I][J][K]` line followed by the columns of
the coefficient matrix, one per line, as shown above. For example, if
the coefficient matrix has the shape of 8x8x13, then
:code:`SHAPE_OF_COEFF_MATRIX[I][J][K]` will be :code:`8 8 13` followed
by 64 (8x8) lines each containing 13 coefficients separated by space.

----------

.. include:: accel_styles.rst

----------

Mixing, shift, table, tail correction, restart, rRESPA info
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

For atom type pairs I,J and I != J, where types I and J correspond to
two different element types, mixing is performed by LAMMPS as described
above from values in the potential file.

This pair style does not support the :doc:`pair_modify <pair_modify>`
shift, table, and tail options.

This pair style does not write its information to :doc:`binary restart
files <restart>`, since it is stored in potential file.

This pair style can only be used via the *pair* keyword of the
:doc:`run_style respa <run_style>` command. It does not support the
*inner*, *middle*, *outer* keywords.

Restrictions
""""""""""""

The 'uf3' pair style is part of the ML-UF3 package. It is only enabled
if LAMMPS was built with that package. See the :doc:`Build package
<Build_package>` page for more info.

This pair style requires the :doc:`newton <newton>` setting to be "on".

The UF3 LAMMPS potential file provided with LAMMPS (see the potentials
directory) are parameterized for metal :doc:`units <units>`.

The single() function of 'uf3' pair style only return the 2-body
interaction energy.

Related commands
""""""""""""""""

:doc:`pair_coeff <pair_coeff>`

Default
"""""""

none

----------

.. _Xie23:

**(Xie23)** Xie, S.R., Rupp, M. & Hennig, R.G. Ultra-fast interpretable machine-learning potentials. npj Comput Mater 9, 162 (2023). https://doi.org/10.1038/s41524-023-01092-7
6 changes: 6 additions & 0 deletions doc/utils/sphinx-config/false_positives.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ Hendrik
Henin
Henkelman
Henkes
Hennig
henrich
Henrich
Hermitian
Expand Down Expand Up @@ -1594,6 +1595,7 @@ interlayer
intermolecular
interoperable
Interparticle
interpretable
interstitials
intertube
Intr
Expand Down Expand Up @@ -1813,6 +1815,7 @@ Koziol
Kp
kradius
Kraker
Krass
Kraus
Kremer
Kress
Expand Down Expand Up @@ -3264,6 +3267,7 @@ Rudranarayan
Rudzinski
Runge
runtime
Rupp
Rutuparna
rx
rxd
Expand Down Expand Up @@ -3810,6 +3814,8 @@ uChem
uCond
uef
UEF
uf
uf3
ufm
Uhlenbeck
Ui
Expand Down
1 change: 1 addition & 0 deletions examples/PACKAGES/uf3/Nb.uf3