Skip to content

Commit

Permalink
Merge pull request #157 from usnistgov/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
knc6 authored Jun 28, 2024
2 parents 9841c25 + dd25fc8 commit f280865
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 62 deletions.
41 changes: 10 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@

<a name="intro"></a>
# ALIGNN (Introduction)
The Atomistic Line Graph Neural Network (https://www.nature.com/articles/s41524-021-00650-1) introduces a new graph convolution layer that explicitly models both two and three body interactions in atomistic systems.
The Atomistic Line Graph Neural Network (https://www.nature.com/articles/s41524-021-00650-1) introduces a new graph convolution layer that explicitly models both two and three body interactions in atomistic systems. This is achieved by composing two edge-gated graph convolution layers, the first applied to the atomistic line graph *L(g)* (representing triplet interactions) and the second applied to the atomistic bond graph *g* (representing pair interactions).

This is achieved by composing two edge-gated graph convolution layers, the first applied to the atomistic line graph *L(g)* (representing triplet interactions) and the second applied to the atomistic bond graph *g* (representing pair interactions).

The atomistic graph *g* consists of a node for each atom *i* (with atom/node representations *h<sub>i</sub>*), and one edge for each atom pair within a cutoff radius (with bond/pair representations *e<sub>ij</sub>*).

The atomistic line graph *L(g)* represents relationships between atom triplets: it has nodes corresponding to bonds (sharing representations *e<sub>ij</sub>* with those in *g*) and edges corresponding to bond angles (with angle/triplet representations *t<sub>ijk</sub>*).

The line graph convolution updates the triplet representations and the pair representations; the direct graph convolution further updates the pair representations and the atom representations.

![ALIGNN layer schematic](https://github.com/usnistgov/alignn/blob/main/alignn/tex/alignn2.png)
![ALIGNN layer schematic](https://github.com/usnistgov/alignn/blob/develop/alignn/tex/schematic_lg.jpg)

<a name="install"></a>
Installation
Expand All @@ -55,38 +48,26 @@ bash Miniconda3-latest-Linux-x86_64.sh (for linux)
bash Miniconda3-latest-MacOSX-x86_64.sh (for Mac)
```
Download 32/64 bit python 3.10 miniconda exe and install (for windows)

#### Method 1 (conda based installation)

Now, let's make a conda environment, say "my_alignn", choose other name as you like::
```
conda create --name my_alignn python=3.10
conda activate my_alignn
conda install alignn
conda install alignn -y
```
Starting version 2024.3.24, we have developed a conda package for alignn: [https://anaconda.org/conda-forge/alignn](https://anaconda.org/conda-forge/alignn)

#### optional GPU dependencies notes

If you need CUDA support, it's best to install PyTorch and DGL before installing alignn to ensure that you get a CUDA-enabled version of DGL.

To [install the stable release of PyTorch] on linux with cudatoolkit 11.8 run

```
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
```

Then [install the matching DGL version](https://www.dgl.ai/pages/start.html)

```
conda install -c dglteam/label/cu118 dgl
```

Some of our models may not be stable with the latest DGL release (v1.1.0) so you may wish to install v1.0.2 instead:

```
conda install -c dglteam/label/cu118 dgl==1.0.2.cu118
conda install dgl=2.1.0 pytorch torchvision torchaudio pytorch-cuda -c pytorch -c nvidia
```


#### Method 1 (editable in-place install)
#### Method 2 (edit/debug in-place install)

You can laso install a development version of alignn by cloning the repository and installing in place with pip:

Expand All @@ -97,21 +78,19 @@ python -m pip install -e .
```


#### Method 2 (using pypi):
#### Method 3 (using pypi):

As an alternate method, ALIGNN can also be installed using `pip` command as follows:
```
pip install alignn
pip install dgl==1.0.1+cu117 -f https://data.dgl.ai/wheels/cu117/repo.html
pip install dgl -f https://data.dgl.ai/wheels/torch-2.1/cu121/repo.html
```

<a name="example"></a>
Examples
---------




| Notebooks | Google&nbsp;Colab | Descriptions |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Regression model](https://colab.research.google.com/github/knc6/jarvis-tools-notebooks/blob/master/jarvis-tools-notebooks/alignn_jarvis_leaderboard.ipynb) | [![Open in Google Colab]](https://colab.research.google.com/github/knc6/jarvis-tools-notebooks/blob/master/jarvis-tools-notebooks/alignn_jarvis_leaderboard.ipynb) | Examples for developing single output regression model for exfoliation energies of 2D materials. |
Expand Down
2 changes: 1 addition & 1 deletion alignn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version number."""

__version__ = "2024.4.20"
__version__ = "2024.5.27"
1 change: 1 addition & 0 deletions alignn/ff/all_models_ff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v5.27.2024": "https://figshare.com/ndownloader/files/47286127", "alignnff_fmult": "https://figshare.com/ndownloader/files/41583585", "alignnff_wt10": "https://figshare.com/ndownloader/files/41583594", "alignnff_fd": "https://figshare.com/ndownloader/files/41583582", "alignnff_wt01": "https://figshare.com/ndownloader/files/41583588", "alignnff_wt1": "https://figshare.com/ndownloader/files/41583591", "fmult_mlearn_only": "https://figshare.com/ndownloader/files/41583597", "aff_Oct23": "https://figshare.com/ndownloader/files/42880573", "revised": "https://figshare.com/ndownloader/files/41583600", "scf_fd_top_10_en_42_fmax_600_wt01": "https://figshare.com/ndownloader/files/41967375", "scf_fd_top_10_en_42_fmax_600_wt10": "https://figshare.com/ndownloader/files/41967372"}
40 changes: 11 additions & 29 deletions alignn/ff/ff.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""Module for running ALIGNN-FF."""

from ase.md import MDLogger
from jarvis.core.atoms import Atoms as JarvisAtoms
import os

# import json
import requests
from ase.md.nvtberendsen import NVTBerendsen
from ase.md.nptberendsen import NPTBerendsen
Expand Down Expand Up @@ -42,8 +41,6 @@
from jarvis.analysis.defects.surface import Surface
from jarvis.core.kpoints import Kpoints3D as Kpoints
import zipfile

# from jarvis.core.atoms import get_supercell_dims
from ase import Atoms as AseAtoms
from ase.phonons import Phonons
import matplotlib.pyplot as plt # noqa
Expand All @@ -58,36 +55,20 @@
except Exception:
pass
plt.switch_backend("agg")
# from ase.optimize.optimize import Optimizer
# from ase.io import Trajectory
# from ase.neighborlist import NeighborList

__author__ = "Kamal Choudhary, Brian DeCost, Keith Butler, Lily Major"
# Cite: https://doi.org/10.1039/D2DD00096B

scf_fd_top_10_en_42_fmax_600_wt01 = (
"https://figshare.com/ndownloader/files/41967375"
)
scf_fd_top_10_en_42_fmax_600_wt10 = (
"https://figshare.com/ndownloader/files/41967372"
)
all_models_ff = {
"alignnff_fmult": "https://figshare.com/ndownloader/files/41583585",
"alignnff_wt10": "https://figshare.com/ndownloader/files/41583594",
"alignnff_fd": "https://figshare.com/ndownloader/files/41583582",
"alignnff_wt01": "https://figshare.com/ndownloader/files/41583588",
"alignnff_wt1": "https://figshare.com/ndownloader/files/41583591",
"fmult_mlearn_only": "https://figshare.com/ndownloader/files/41583597",
"aff_Oct23": "https://figshare.com/ndownloader/files/42880573",
"revised": "https://figshare.com/ndownloader/files/41583600",
"scf_fd_top_10_en_42_fmax_600_wt01": scf_fd_top_10_en_42_fmax_600_wt01,
"scf_fd_top_10_en_42_fmax_600_wt10": scf_fd_top_10_en_42_fmax_600_wt10,
}

def get_all_models():
json_path = os.path.join(os.path.dirname(__file__), "all_models_ff.json")
return loadjson(json_path)


def get_figshare_model_ff(
model_name="alignnff_fmult", dir_path=None, filename="best_model.pt"
model_name="v5.27.2024", dir_path=None, filename="best_model.pt"
):
"""Get ALIGNN-FF torch models from figshare."""
all_models_ff = get_all_models()
# https://doi.org/10.6084/m9.figshare.23695695
if dir_path is None:
dir_path = str(os.path.join(os.path.dirname(__file__), model_name))
Expand Down Expand Up @@ -145,9 +126,10 @@ def get_figshare_model_ff(

def default_path():
"""Get default model path."""
dpath = get_figshare_model_ff(model_name="alignnff_wt10")
dpath = get_figshare_model_ff(model_name="v5.27.2024")
# dpath = get_figshare_model_ff(model_name="alignnff_wt10")
# dpath = get_figshare_model_ff(model_name="alignnff_fmult")
print("model_path", dpath)
# print("model_path", dpath)
return dpath


Expand Down
Binary file added alignn/tex/schematic_lg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setuptools.setup(
name="alignn",
version="2024.4.20",
version="2024.5.27",
author="Kamal Choudhary, Brian DeCost",
author_email="[email protected]",
description="alignn",
Expand Down Expand Up @@ -47,6 +47,7 @@
long_description_content_type="text/markdown",
url="https://github.com/usnistgov/alignn",
packages=setuptools.find_packages(),
package_data={"alignn.ff": ["all_models_ff.json"]},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit f280865

Please sign in to comment.