Skip to content

Commit

Permalink
Merge pull request #400 from mir-group/lmpotf
Browse files Browse the repository at this point in the history
LAMMPS-driven active learning
  • Loading branch information
anjohan authored Jun 11, 2024
2 parents 700f2c8 + 0eb5705 commit 01eb471
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 52 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/flare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install python3-sphinx python3-sphinx-rtd-theme python3-breathe python3-nbsphinx
- name: Run Doxygen
uses: mattnotmitt/doxygen-action@v1.1.0
with:
Expand All @@ -127,11 +127,12 @@ jobs:

- name: Run Sphinx
run: |
export PYTHONPATH=$PYTHONPATH:$PWD/lammps/python
cd docs
pwd
ls
make html
- name: Publish the docs
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
39 changes: 7 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,12 @@ include_directories(${SOURCE_DIR})

# pybind11
###############################################################################
ExternalProject_Add(
pybind11_project
SOURCE_DIR "${CMAKE_BINARY_DIR}/External/pybind11"
URL "https://github.com/pybind/pybind11/archive/v2.3.0.tar.gz"
URL_HASH MD5=e2120c5b0e3c20a93f2dfcdc55026ba8
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
set(PYBIND11_FINDPYTHON ON)
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11
)
if (NOT FLARE_PYTHON_VERSION)
set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5)
endif()
find_package(PythonLibsNew ${FLARE_PYTHON_VERSION} REQUIRED)

add_library(pybind11 INTERFACE)
ExternalProject_Get_Property(pybind11_project SOURCE_DIR)
target_include_directories(pybind11 SYSTEM INTERFACE ${SOURCE_DIR}/include)
target_include_directories(pybind11 SYSTEM INTERFACE ${PYTHON_INCLUDE_DIRS})

if(APPLE)
TARGET_LINK_LIBRARIES(pybind11 INTERFACE "-undefined dynamic_lookup")
message(STATUS "Building in conda environment on MAC")
else()
target_link_libraries(pybind11 INTERFACE ${PYTHON_LIBRARIES})
endif()

# Greatly reduces the code bloat
target_compile_options(pybind11 INTERFACE "-fvisibility=hidden")
FetchContent_MakeAvailable(pybind11)
###############################################################################

# Specify source files.
Expand Down Expand Up @@ -204,11 +182,8 @@ else()
endif()

# Create pybind module.
add_library(flare_module SHARED ${PYBIND_SOURCES})
target_link_libraries(flare_module PUBLIC flare pybind11)
set_target_properties(flare_module PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
SUFFIX "${PYTHON_MODULE_EXTENSION}")
add_dependencies(flare_module pybind11_project)
pybind11_add_module(flare_module ${PYBIND_SOURCES})
target_link_libraries(flare_module PUBLIC flare)
set_target_properties(flare_module PROPERTIES OUTPUT_NAME "_C_flare")

# Add test directory.
Expand Down
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<img width="527" height="242" src="https://github.com/mir-group/flare/blob/master/docs/images/Flare_logo.png?raw=true">
</p>

FLARE is an open-source Python package for creating fast and accurate interatomic potentials.
FLARE is an open-source Python package for creating fast and accurate interatomic potentials.

## Major Features

Expand All @@ -20,7 +20,7 @@ Note:

We implement Sparse GP, all the kernels and descriptors in C++ with Python interface.

We implement Full GP, Mapped GP, RBCM, Squared Exponential kernel and 2+3-body descriptors in Python.
We implement Full GP, Mapped GP, RBCM, Squared Exponential kernel and 2+3-body descriptors in Python.

Please do NOT mix them.

Expand All @@ -35,20 +35,16 @@ Documentation of the code can be accessed here: https://mir-group.github.io/flar
[FLARE (ACE descriptors + sparse GP)](https://colab.research.google.com/drive/1rZ-p3kN5CJbPJgD8HuQHSc7ecmwZYse6).
The tutorial shows how to run flare with ACE and SGP on energy and force data, demoing "offline" training on the MD17 dataset and "online" on-the-fly training of a simple aluminum force field. All the trainings use yaml files for configuration.

[FLARE (LAMMPS active learning)](https://bit.ly/flarelmpotf)
This tutorial demonstrates new functionality for running active learning all within LAMMPS, with LAMMPS running the dynamics to allow arbitrarily complex molecular dynamics workflows while maintaining a simple interface. This also demonstrates how to use the C++ API directly from Python through `pybind11`. Finally, there's a simple demonstration of phonon calculations with FLARE using `phonopy`.

[FLARE (ACE descriptors + sparse GP) with LAMMPS](https://colab.research.google.com/drive/1qgGlfu1BlXQgSrnolS4c4AYeZ-2TaX5Y).
The tutorial shows how to compile LAMMPS with FLARE pair style and uncertainty compute code, and use LAMMPS for Bayesian active learning and uncertainty-aware molecular dynamics.

[FLARE (ACE descriptors + sparse GP) Python API](https://colab.research.google.com/drive/18_pTcWM19AUiksaRyCgg9BCpVyw744xv).
The tutorial shows how to do the offline and online trainings with python scripts.
A video walkthrough of the tutorial, including detailed discussion of expected outputs, is available [here](https://youtu.be/-FH_VqRQrso).

[FLARE (2+3-body + GP)](https://colab.research.google.com/drive/1Q2NCCQWYQdTW9-e35v1W-mBlWTiQ4zfT).
The tutorial shows how to use flare 2+3 body descriptors and squared exponential kernel to train a Gaussian Process force field on-the-fly.

[Compute thermal conductivity from FLARE and Boltzmann transport equations](https://phoebe.readthedocs.io/en/develop/tutorials/mlPhononTransport.html).
The tutorial shows how to use FLARE (LAMMPS) potential to compute lattice thermal conductivity from Boltzmann transport equation method, with [Phono3py](https://phonopy.github.io/phono3py/) for force constants calculations and [Phoebe](https://mir-group.github.io/phoebe/) for thermal conductivities.

[Using your own customized descriptors with FLARE](https://colab.research.google.com/drive/1VzbIPmx1z-uygKstOYTj2Nqr53AMC5NL?usp=sharing).
[Using your own customized descriptors with FLARE](https://colab.research.google.com/drive/1VzbIPmx1z-uygKstOYTj2Nqr53AMC5NL?usp=sharing).
The tutorial shows how to attach your own descriptors with FLARE sparse GP model and do training and testing.

All the tutorials take a few minutes to run on a normal desktop computer or laptop (excluding installation time).
Expand Down Expand Up @@ -82,7 +78,7 @@ flare++ is tested on a Linux operating system (Ubuntu 20.04.3), but should also

### Hardware requirements
There are no non-standard hardware requirements to download the software and train simple models&mdash;the introductory tutorial can be run on a single cpu. To train large models (10k+ sparse environments), we recommend using a compute node with at least 100GB of RAM.

## Tests
We recommend running unit tests to confirm that FLARE is running properly on your machine. We have implemented our tests using the pytest suite. You can call `pytest` from the command line in the tests directory.

Expand All @@ -94,11 +90,10 @@ pytest
```

## References

If you use FLARE++ including B2 descriptors, NormalizedDotProduct kernel and Sparse GP, please cite the following paper:

> [1] Vandermause, J., Xie, Y., Lim, J.S., Owen, C.J. and Kozinsky, B., 2021. *Active learning of reactive Bayesian force fields: Application to heterogeneous hydrogen-platinum catalysis dynamics.* Nature Communications 13.1 (2022): 5183. https://www.nature.com/articles/s41467-022-32294-0
If you use FLARE active learning workflow, full Gaussian process or 2-body/3-body kernel in your research, please cite the following paper:

> [2] Vandermause, J., Torrisi, S. B., Batzner, S., Xie, Y., Sun, L., Kolpak, A. M. & Kozinsky, B. *On-the-fly active learning of interpretable Bayesian force fields for atomistic rare events.* npj Comput Mater 6, 20 (2020). https://doi.org/10.1038/s41524-020-0283-z
Expand Down
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
breathe_projects = {"flare_pp": "xml"}
breathe_default_project = "flare_pp"
breathe_default_members = ("members", "undoc-members")
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_use_param = False

# Add any paths that contain templates here, relative to this directory.
Expand Down
1 change: 1 addition & 0 deletions docs/source/flare/learners/learners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ Bayesian Active Learning
:maxdepth: 2

otf
lmpotf
gp_from_aimd
utils
5 changes: 5 additions & 0 deletions docs/source/flare/learners/lmpotf.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
On-the-Fly Training in LAMMPS
=============================

.. automodule:: flare.learners.lmpotf
:members:
2 changes: 1 addition & 1 deletion flare/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.3.3"
__version__ = "1.4.0"
Loading

0 comments on commit 01eb471

Please sign in to comment.