Skip to content

Commit

Permalink
merge master into lmpotf
Browse files Browse the repository at this point in the history
  • Loading branch information
anjohan committed Jun 7, 2024
2 parents 3457c30 + 700f2c8 commit d4281e7
Show file tree
Hide file tree
Showing 43 changed files with 1,427 additions and 2,781 deletions.
83 changes: 51 additions & 32 deletions .github/workflows/flare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
matrix:
omp: [OFF, ON]
lapack: [OFF, ON]
name: "(OpenMP, Lapack) ="
python-version: ["3.7", "3.8"]
name: "(OpenMP, Lapack, Python) ="

# The type of runner that the job will run on
runs-on: ubuntu-latest
Expand All @@ -30,35 +31,10 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Install Sphinx and Breathe
run: |
sudo apt-get update
sudo apt-get install python3-sphinx python3-sphinx-rtd-theme python3-breathe python3-nbsphinx
- name: Run Doxygen
uses: mattnotmitt/[email protected]
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
# Path to Doxyfile
doxyfile-path: "./Doxyfile" # default is ./Doxyfile
# Working directory
working-directory: "./docs" # default is .

- name: Run Sphinx
run: |
cd docs
pwd
ls
make html
- name: Publish the docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Default Doxyfile build documentation to html directory.
# Change the directory if changes in Doxyfile
publish_dir: ./docs/build/html
if: github.event_name == 'pull_request' && matrix.lapack == 'on' && matrix.omp == 'on'
python-version: ${{ matrix.python-version }}

- name: Build
run: |
Expand All @@ -82,27 +58,41 @@ jobs:
echo "Lapack ${{ matrix.lapack }}"
cmake ..
cmake --build . -j
cmake --build . -j4
cp _C_flare* ../flare/bffs/sgp
cd ctests
./tests
- name: Install LAMMPS
run: |
git clone --depth 1 https://github.com/lammps/lammps.git lammps
cd lammps/src
cp pair_hybrid.* pair_lj_cut.* ..
rm pair_*.cpp pair_*.h
mv ../pair_hybrid.* ../pair_lj_cut.* .
cp MANYBODY/pair_tersoff.* .
rm MANYBODY/pair_*.*
rm MANYBODY/fix_*.*
mv pair_tersoff.* MANYBODY/
cp KOKKOS/pair_kokkos.* .
rm KOKKOS/pair_*.*
mv pair_kokkos.* KOKKOS/
cd ../..
cd lammps_plugins
./install.sh $(pwd)/../lammps
cd ..
sudo cp -r ${BUILD_DIR}/External/Eigen3/Eigen /usr/include
cd lammps
mkdir build
cd build
cmake ../cmake -DPKG_KOKKOS=ON -DKokkos_ENABLE_OPENMP=ON -DPKG_MANYBODY=yes
cmake ../cmake -DPKG_KOKKOS=ON -DKokkos_ENABLE_OPENMP=ON -DPKG_MANYBODY=ON
make -j4
- name: Pip install
run: |
pip install -U codecov pytest pytest-cov pytest_mock
pip install -U codecov pytest pytest-cov pytest_mock Sphinx sphinx-rtd-theme breathe nbsphinx
pip install -r requirements.txt
- name: Patch ASE
Expand All @@ -122,6 +112,35 @@ jobs:
cd tests
pytest test_lammps.py
- name: Install Sphinx and Breathe
run: |
sudo apt-get update
sudo apt-get install python3-sphinx python3-sphinx-rtd-theme python3-breathe python3-nbsphinx
- name: Run Doxygen
uses: mattnotmitt/[email protected]
with:
# Path to Doxyfile
doxyfile-path: "./Doxyfile" # default is ./Doxyfile
# Working directory
working-directory: "./docs" # default is .

- name: Run Sphinx
run: |
cd docs
pwd
ls
make html
- name: Publish the docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Default Doxyfile build documentation to html directory.
# Change the directory if changes in Doxyfile
publish_dir: ./docs/build/html
if: github.event_name == 'pull_request' && matrix.lapack == 'on' && matrix.omp == 'on'

# - name: Run tutorial
# run: |
# cd tests
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ set(FLARE_SOURCES
src/flare_pp/descriptors/four_body.cpp
src/flare_pp/kernels/kernel.cpp
src/flare_pp/kernels/normalized_dot_product.cpp
src/flare_pp/kernels/dot_product.cpp
src/flare_pp/kernels/norm_dot_icm.cpp
src/flare_pp/kernels/squared_exponential.cpp)

Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![Build Status](https://github.com/mir-group/flare/actions/workflows/main.yml/badge.svg)](https://github.com/mir-group/flare/actions) [![documentation](https://readthedocs.org/projects/flare/badge/?version=latest)](https://readthedocs.org/projects/flare) [![pypi](https://img.shields.io/pypi/v/mir-flare)](https://pypi.org/project/mir-flare/) [![activity](https://img.shields.io/github/commit-activity/m/mir-group/flare)](https://github.com/mir-group/flare/commits/master) [![codecov](https://codecov.io/gh/mir-group/flare/branch/master/graph/badge.svg)](https://codecov.io/gh/mir-group/flare)
[![Build Status](https://github.com/mir-group/flare/actions/workflows/flare.yml/badge.svg)](https://github.com/mir-group/flare/actions) [![pypi](https://img.shields.io/pypi/v/mir-flare)](https://pypi.org/project/mir-flare/) [![activity](https://img.shields.io/github/commit-activity/m/mir-group/flare)](https://github.com/mir-group/flare/commits/master) [![codecov](https://codecov.io/gh/mir-group/flare/branch/master/graph/badge.svg)](https://codecov.io/gh/mir-group/flare)

***NOTE: This is the latest release [1.3.3](https://github.com/mir-group/flare/releases/tag/1.3.3) which includes significant changes compared to the previous version [0.2.4](https://github.com/mir-group/flare/releases/tag/0.2.4). Please check the updated tutorials and documentations from the links below.***

# FLARE: Fast Learning of Atomistic Rare Events

Expand Down Expand Up @@ -88,14 +90,22 @@ pytest
```

## References
- If you use FLARE++ including B2 descriptors, NormalizedDotProduct kernel and Sparse GP, please cite the following paper:
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.* [arXiv preprint arXiv:2106.01949](https://arxiv.org/abs/2106.01949).
> [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:
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
- If you use FLARE LAMMPS pair style or MGP (mapped Gaussian process), please cite the following paper:
If you use FLARE LAMMPS pair style or MGP (mapped Gaussian process), please cite the following paper:

> [3] Xie, Y., Vandermause, J., Sun, L. et al. *Bayesian force fields from active learning for simulation of inter-dimensional transformation of stanene.* npj Comput Mater 7, 40 (2021). https://doi.org/10.1038/s41524-021-00510-y
If you use FLARE PyLAMMPS for training, please cite the following paper:

> [4] Xie, Y., Vandermause, J., Ramakers, S., Protik, N.H., Johansson, A. and Kozinsky, B., 2022. *Uncertainty-aware molecular dynamics from Bayesian active learning: Phase Transformations and Thermal Transport in SiC.* npj Comput. Mater. 9(1), 36 (2023).
If you use FLARE LAMMPS Kokkos pair style with GPU acceleration, please cite the following paper:

> [5] Johansson, A., Xie, Y., Owen, C.J., Soo, J., Sun, L., Vandermause, J. and Kozinsky, B., 2022. *Micron-scale heterogeneous catalysis with Bayesian force fields from first principles and active learning.* arXiv preprint arXiv:2204.12573.
2 changes: 1 addition & 1 deletion ctests/test_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class KernelTest : public StructureTest {

};

using KernelTypes = ::testing::Types<SquaredExponential, NormalizedDotProduct>;
using KernelTypes = ::testing::Types<SquaredExponential, NormalizedDotProduct, DotProduct>;
TYPED_TEST_SUITE(KernelTest, KernelTypes);

TYPED_TEST(KernelTest, TimeSelfKernel) {
Expand Down
32 changes: 23 additions & 9 deletions ctests/test_sparse_gp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ TEST_F(StructureTest, LikeGrad) {
test_struc.forces = forces;
test_struc.stresses = stresses;

sparse_gp.add_training_structure(test_struc);
sparse_gp.add_training_structure(test_struc, {-1}, 0.4, 0.2, 0.3);
sparse_gp.add_all_environments(test_struc);

// TODO: add another test structure

EXPECT_EQ(sparse_gp.Sigma.rows(), 0);
EXPECT_EQ(sparse_gp.Kuu_inverse.rows(), 0);

Expand Down Expand Up @@ -194,8 +196,9 @@ TEST_F(StructureTest, LikeGrad) {
like_down = sparse_gp.compute_likelihood_gradient(hyps_down);

fin_diff = (like_up - like_down) / (2 * pert);
printf("like_grad=%lg, fin_diff=%lg\n", like_grad(i), fin_diff);

EXPECT_NEAR(like_grad(i), fin_diff, 1e-3 * abs(fin_diff));
EXPECT_NEAR(like_grad(i), fin_diff, 5e-3 * abs(fin_diff));
}
}

Expand Down Expand Up @@ -230,8 +233,19 @@ TEST_F(StructureTest, LikeGradStable) {
test_struc.forces = forces;
test_struc.stresses = stresses;

sparse_gp.add_training_structure(test_struc, {0, 1, 3, 5});
test_struc_2 = Structure(cell_2, species_2, positions_2, cutoff, dc);

Eigen::VectorXd energy_2 = Eigen::VectorXd::Random(1);
Eigen::VectorXd forces_2 = Eigen::VectorXd::Random(n_atoms * 3);
Eigen::VectorXd stresses_2 = Eigen::VectorXd::Random(6);
test_struc_2.energy = energy_2;
test_struc_2.forces = forces_2;
test_struc_2.stresses = stresses_2;

sparse_gp.add_training_structure(test_struc, {-1}, 0.4, 0.2, 0.3);
sparse_gp.add_specific_environments(test_struc, {0, 1, 3});
sparse_gp.add_training_structure(test_struc_2, {0, 1, 3, 5}, 0.64, 0.55, 0.45);
sparse_gp.add_specific_environments(test_struc_2, {2, 3, 4});

EXPECT_EQ(sparse_gp.Sigma.rows(), 0);
EXPECT_EQ(sparse_gp.Kuu_inverse.rows(), 0);
Expand Down Expand Up @@ -282,8 +296,8 @@ TEST_F(StructureTest, LikeGradStable) {
fin_diff = (like_up - like_down) / (2 * pert);

std::cout << like_grad(i) << " " << fin_diff << std::endl;
EXPECT_NEAR(like_grad(i), fin_diff, 1e-5);
EXPECT_NEAR(like_grad(i), like_grad_original(i), 1e-6);
EXPECT_NEAR(like_grad(i), fin_diff, 1e-5 * abs(fin_diff));
EXPECT_NEAR(like_grad(i), like_grad_original(i), 1e-6 * abs(fin_diff));
}
}

Expand Down Expand Up @@ -320,14 +334,14 @@ TEST_F(StructureTest, Set_Hyps) {

// Add sparse environments and training structures.
std::cout << "adding training structure" << std::endl;
sparse_gp_1.add_training_structure(test_struc);
sparse_gp_1.add_training_structure(test_struc_2);
sparse_gp_1.add_training_structure(test_struc, {-1}, 0.1, 0.2, 0.3);
sparse_gp_1.add_training_structure(test_struc_2, {-1}, 0.5, 0.4, 0.6);
sparse_gp_1.add_all_environments(test_struc);
sparse_gp_1.add_all_environments(test_struc_2);

std::cout << "adding training structure" << std::endl;
sparse_gp_2.add_training_structure(test_struc);
sparse_gp_2.add_training_structure(test_struc_2);
sparse_gp_2.add_training_structure(test_struc, {-1}, 0.1, 0.2, 0.3);
sparse_gp_2.add_training_structure(test_struc_2, {-1}, 0.5, 0.4, 0.6);
sparse_gp_2.add_all_environments(test_struc);
sparse_gp_2.add_all_environments(test_struc_2);

Expand Down
1 change: 1 addition & 0 deletions ctests/test_structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "structure.h"
#include "four_body.h"
#include "normalized_dot_product.h"
#include "dot_product.h"
#include "norm_dot_icm.h"
#include "squared_exponential.h"
#include "structure.h"
Expand Down
10 changes: 9 additions & 1 deletion docs/source/citing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ How to Cite

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.* [arXiv preprint arXiv:2106.01949](https://arxiv.org/abs/2106.01949).
[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:

Expand All @@ -13,4 +13,12 @@ If you use FLARE LAMMPS pair style or MGP (mapped Gaussian process), please cite

[3] Xie, Y., Vandermause, J., Sun, L. et al. *Bayesian force fields from active learning for simulation of inter-dimensional transformation of stanene.* npj Comput Mater 7, 40 (2021). https://doi.org/10.1038/s41524-021-00510-y

If you use FLARE PyLAMMPS for training, please cite the following paper:

[4] Xie, Y., Vandermause, J., Ramakers, S., Protik, N.H., Johansson, A. and Kozinsky, B., 2022. *Uncertainty-aware molecular dynamics from Bayesian active learning: Phase Transformations and Thermal Transport in SiC.* npj Comput. Mater. 9(1), 36 (2023).

If you use FLARE LAMMPS Kokkos pair style with GPU acceleration, please cite the following paper:

[5] Johansson, A., Xie, Y., Owen, C.J., Soo, J., Sun, L., Vandermause, J. and Kozinsky, B., 2022. *Micron-scale heterogeneous catalysis with Bayesian force fields from first principles and active learning.* arXiv preprint arXiv:2204.12573.

Thank you for using FLARE!
23 changes: 15 additions & 8 deletions docs/source/installation/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ Requirements
2. Use conda to install compilers and dependencies for flare

* Option 1: If you want to install flare with mkl
* Option 1: You can load modules if your machine have already installed them (with mkl)

.. code-block:: bash
module load cmake/3.17.3 gcc/9.3.0 intel-mkl/2017.2.174
* Option 2: If you want to install flare with mkl

.. code-block:: bash
conda install -y gcc gxx cmake mkl-devel mkl-service mkl_fft openmp -c conda-forge
* Option 2: If you want to install flare with openblas + lapacke
* Option 3: If you want to install flare with openblas + lapacke

.. code-block:: bash
conda install -y gcc gxx cmake openmp liblapacke openblas -c conda-forge
* Option 3: You can load modules if your machine have already installed them

.. code-block:: bash
module load cmake/3.17.3 gcc/9.3.0 intel-mkl/2017.2.174
3. Download flare code from github repo and pip install

.. code-block:: bash
Expand Down Expand Up @@ -107,6 +107,13 @@ Trouble shooting

* the `ldd` command above should show the linked libraries in the `.conda/envs/flare` directory

* If you encounter `Intel MKL FATAL ERROR` when running flare (after the compilation has done), this is likely a static library linkage issue. You can set up the environmental variable

.. code-block:: bash
export LD_PRELOAD=${CONDA_PREFIX}/lib/libmkl_core.so:${CONDA_PREFIX}/lib/libmkl_intel_thread.so:${CONDA_PREFIX}/lib/libiomp5.so
as instructed in `this discussion <https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-fails-to-load/m-p/1155538>`_.

*****************************************
Acceleration with multiprocessing and MKL
Expand Down
Loading

0 comments on commit d4281e7

Please sign in to comment.