Spaces:
Running
Running
Yuan (Cyrus) Chiang
commited on
Commit
•
1c7cd6c
1
Parent(s):
cf512f3
Add calculator test (#6)
Browse files* add files
* resolve dgl issue
* fix typos; remove poetry
* miss dgl in test
* fix farichem version
* spearate mace from other dependencies
* use scripts to install pyg and dgl
* fix typo
* fix another typo
* add pynanoflann dependency
* install pynanoflann separately in test workflow
* change alignn downlaod method; update all diatomic curve stats
- .github/workflows/test.yaml +34 -0
- mlip_arena/models/externals.py +6 -4
- mlip_arena/tasks/diatomics/alignn/homonuclear-diatomics.json +0 -0
- mlip_arena/tasks/diatomics/chgnet/homonuclear-diatomics.json +0 -0
- mlip_arena/tasks/diatomics/equiformer/homonuclear-diatomics.json +0 -0
- mlip_arena/tasks/diatomics/escn/homonuclear-diatomics.json +0 -0
- mlip_arena/tasks/diatomics/m3gnet/homonuclear-diatomics.json +0 -0
- mlip_arena/tasks/diatomics/mace-mp/homonuclear-diatomics.json +0 -0
- mlip_arena/tasks/diatomics/mace-off/homonuclear-diatomics.json +0 -0
- mlip_arena/tasks/diatomics/orb/homonuclear-diatomics.json +0 -0
- mlip_arena/tasks/diatomics/run.ipynb +0 -0
- mlip_arena/tasks/diatomics/sevennet/homonuclear-diatomics.json +0 -0
- pyproject.toml +7 -5
- scripts/install-dgl.sh +6 -0
- scripts/install-pyg.sh +1 -6
- tests/test_external_calculators.py +21 -0
.github/workflows/test.yaml
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Python Test
|
2 |
+
|
3 |
+
on: [push, pull_request]
|
4 |
+
|
5 |
+
jobs:
|
6 |
+
test:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
|
9 |
+
strategy:
|
10 |
+
matrix:
|
11 |
+
python-version: ["3.9", "3.10", "3.11"]
|
12 |
+
|
13 |
+
steps:
|
14 |
+
- name: Checkout repository
|
15 |
+
uses: actions/checkout@v2
|
16 |
+
|
17 |
+
- name: Set up Python ${{ matrix.python-version }}
|
18 |
+
uses: actions/setup-python@v2
|
19 |
+
with:
|
20 |
+
python-version: ${{ matrix.python-version }}
|
21 |
+
|
22 |
+
- name: Install dependencies
|
23 |
+
run: |
|
24 |
+
python -m pip install --upgrade pip
|
25 |
+
pip install torch==2.2.0
|
26 |
+
bash scripts/install-pyg.sh
|
27 |
+
bash scripts/install-dgl.sh
|
28 |
+
pip install .[test]
|
29 |
+
pip install mace-torch
|
30 |
+
pip install "pynanoflann@git+https://github.com/dwastberg/pynanoflann#egg=af434039ae14bedcbb838a7808924d6689274168"
|
31 |
+
|
32 |
+
- name: Run tests
|
33 |
+
run: |
|
34 |
+
pytest tests
|
mlip_arena/models/externals.py
CHANGED
@@ -7,7 +7,7 @@ from typing import Literal
|
|
7 |
import matgl
|
8 |
import requests
|
9 |
import torch
|
10 |
-
from alignn.ff.ff import AlignnAtomwiseCalculator, get_figshare_model_ff
|
11 |
from ase import Atoms
|
12 |
from chgnet.model.dynamics import CHGNetCalculator
|
13 |
from chgnet.model.model import CHGNet as CHGNetModel
|
@@ -232,11 +232,13 @@ class eSCN(OCPCalculator):
|
|
232 |
|
233 |
|
234 |
class ALIGNN(AlignnAtomwiseCalculator):
|
235 |
-
def __init__(self, device=None,
|
236 |
# TODO: cannot control version
|
237 |
-
_ = get_figshare_model_ff(dir_path=dir_path)
|
|
|
|
|
238 |
device = device or get_freer_device()
|
239 |
-
super().__init__(path=
|
240 |
|
241 |
|
242 |
class SevenNet(SevenNetCalculator):
|
|
|
7 |
import matgl
|
8 |
import requests
|
9 |
import torch
|
10 |
+
from alignn.ff.ff import AlignnAtomwiseCalculator, get_figshare_model_ff, default_path
|
11 |
from ase import Atoms
|
12 |
from chgnet.model.dynamics import CHGNetCalculator
|
13 |
from chgnet.model.model import CHGNet as CHGNetModel
|
|
|
232 |
|
233 |
|
234 |
class ALIGNN(AlignnAtomwiseCalculator):
|
235 |
+
def __init__(self, device=None, **kwargs) -> None:
|
236 |
# TODO: cannot control version
|
237 |
+
# _ = get_figshare_model_ff(dir_path=dir_path)
|
238 |
+
model_path = default_path()
|
239 |
+
|
240 |
device = device or get_freer_device()
|
241 |
+
super().__init__(path=model_path, device=device, **kwargs)
|
242 |
|
243 |
|
244 |
class SevenNet(SevenNetCalculator):
|
mlip_arena/tasks/diatomics/alignn/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/chgnet/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/equiformer/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/escn/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/m3gnet/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/mace-mp/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/mace-off/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/orb/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/run.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
mlip_arena/tasks/diatomics/sevennet/homonuclear-diatomics.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
pyproject.toml
CHANGED
@@ -41,10 +41,10 @@ run = [
|
|
41 |
"torch==2.2.0",
|
42 |
"e3nn==0.5.1",
|
43 |
"matgl==1.1.2",
|
44 |
-
"dgl==2.4.0
|
45 |
"mace-torch==0.3.4",
|
46 |
"chgnet==0.3.8",
|
47 |
-
"fairchem-core==
|
48 |
"sevenn==0.9.3.post1",
|
49 |
"orb-models==0.3.1",
|
50 |
"alignn==2024.5.27"
|
@@ -59,15 +59,17 @@ test = [
|
|
59 |
"torch==2.2.0",
|
60 |
"e3nn==0.5.1",
|
61 |
"matgl==1.1.2",
|
62 |
-
"dgl==2.4.0
|
63 |
-
"mace-torch==0.3.4",
|
64 |
"chgnet==0.3.8",
|
65 |
-
"fairchem-core==
|
66 |
"sevenn==0.9.3.post1",
|
67 |
"orb-models==0.3.1",
|
68 |
"alignn==2024.5.27",
|
69 |
"pytest"
|
70 |
]
|
|
|
|
|
|
|
71 |
|
72 |
[project.urls]
|
73 |
Homepage = "https://github.com/atomind-ai/mlip-arena"
|
|
|
41 |
"torch==2.2.0",
|
42 |
"e3nn==0.5.1",
|
43 |
"matgl==1.1.2",
|
44 |
+
"dgl==2.4.0",
|
45 |
"mace-torch==0.3.4",
|
46 |
"chgnet==0.3.8",
|
47 |
+
"fairchem-core==1.1.0",
|
48 |
"sevenn==0.9.3.post1",
|
49 |
"orb-models==0.3.1",
|
50 |
"alignn==2024.5.27"
|
|
|
59 |
"torch==2.2.0",
|
60 |
"e3nn==0.5.1",
|
61 |
"matgl==1.1.2",
|
62 |
+
"dgl==2.4.0",
|
|
|
63 |
"chgnet==0.3.8",
|
64 |
+
"fairchem-core==1.1.0",
|
65 |
"sevenn==0.9.3.post1",
|
66 |
"orb-models==0.3.1",
|
67 |
"alignn==2024.5.27",
|
68 |
"pytest"
|
69 |
]
|
70 |
+
mace = [
|
71 |
+
"mace-torch==0.3.4",
|
72 |
+
]
|
73 |
|
74 |
[project.urls]
|
75 |
Homepage = "https://github.com/atomind-ai/mlip-arena"
|
scripts/install-dgl.sh
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DGL (M3GNet, ALIGNN)
|
2 |
+
|
3 |
+
TORCH=2.2
|
4 |
+
CUDA=cu121
|
5 |
+
|
6 |
+
pip install dgl -U -f https://data.dgl.ai/wheels/torch-${TORCH}/${CUDA}/repo.html
|
scripts/install-pyg.sh
CHANGED
@@ -1,11 +1,6 @@
|
|
1 |
-
|
2 |
-
|
3 |
# PyTorch Geometric (OCP)
|
4 |
-
TORCH=2.
|
5 |
CUDA=cu121
|
6 |
|
7 |
pip install --verbose --no-cache torch-scatter -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
|
8 |
pip install --verbose --no-cache torch-sparse -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
|
9 |
-
|
10 |
-
# DGL (M3GNet, ALIGNN)
|
11 |
-
pip install dgl -U -f https://data.dgl.ai/wheels/torch-2.3/cu121/repo.html
|
|
|
|
|
|
|
1 |
# PyTorch Geometric (OCP)
|
2 |
+
TORCH=2.2.0
|
3 |
CUDA=cu121
|
4 |
|
5 |
pip install --verbose --no-cache torch-scatter -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
|
6 |
pip install --verbose --no-cache torch-sparse -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
|
|
|
|
|
|
tests/test_external_calculators.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pytest
|
2 |
+
from ase import Atoms
|
3 |
+
|
4 |
+
from mlip_arena.models.utils import MLIPEnum
|
5 |
+
|
6 |
+
|
7 |
+
@pytest.mark.parametrize("model", MLIPEnum)
|
8 |
+
def test_calculate(model):
|
9 |
+
calc = MLIPEnum[model.name].value()
|
10 |
+
|
11 |
+
atoms = Atoms(
|
12 |
+
"OO",
|
13 |
+
positions=[[0, 0, 0], [1.5, 0, 0]],
|
14 |
+
cell=[10, 10 + 0.001, 10 + 0.002],
|
15 |
+
pbc=True,
|
16 |
+
)
|
17 |
+
|
18 |
+
atoms.calc = calc
|
19 |
+
|
20 |
+
print(atoms.get_potential_energy())
|
21 |
+
assert isinstance(atoms.get_potential_energy(), float)
|