Skip to content

Commit 9f3baf9

Browse files
Add initial examples (#1)
Co-authored-by: ElliottKasoar <ElliottKasoar@users.noreply.github.com> Co-authored-by: joehart2001 <jh2536@cam.ac.uk>
1 parent 26f9cea commit 9f3baf9

50 files changed

Lines changed: 4112 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.venv

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
*.json
2+
*.html
13
*.dat
24
*.lock
5+
!*dvc.lock
36
*.log
47
*.pyc
58
*.swo
@@ -10,6 +13,7 @@
1013
*.extxyz
1114
*.yml
1215
*.yaml
16+
!dvc.yaml
1317
*.pdf
1418
*.hdf5
1519
*.traj

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors:
77
given-names: Elliott
88
orcid: "https://orcid.org/0009-0005-2015-9478"
99
- family-names: Hart
10-
given-names: Joe
10+
given-names: Joseph
1111
identifiers:
1212
- type: doi
1313
value: 10.5281/zenodo.16904444

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Install uv
2+
FROM python:3.12-slim
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
4+
5+
# Install git, gcc etc.
6+
RUN apt-get update && apt-get upgrade -y && apt-get install -y git build-essential
7+
8+
# Change the working directory to the `app` directory
9+
WORKDIR /app
10+
11+
# Enable bytecode compilation
12+
ENV UV_COMPILE_BYTECODE=1
13+
14+
# Copy from the cache instead of linking since it's a mounted volume
15+
ENV UV_LINK_MODE=copy
16+
17+
# Install dependencies
18+
RUN --mount=type=cache,target=/root/.cache/uv \
19+
--mount=type=bind,source=uv.lock,target=uv.lock \
20+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
21+
uv sync -v --locked --no-install-project
22+
23+
# Copy contents into the image
24+
ADD . /app
25+
26+
# Sync the project
27+
RUN --mount=type=cache,target=/root/.cache/uv \
28+
uv sync --locked
29+
30+
# Run app.py
31+
CMD ["uv", "run", "run_app.py"]

compose.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
app:
3+
image: benchmark-app
4+
ports:
5+
- 8050:8050
6+
working_dir: /app
7+
volumes:
8+
- ./:/app

conftest.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Configure pytest.
3+
4+
Based on https://docs.pytest.org/en/latest/example/simple.html.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
import pytest
10+
11+
12+
def pytest_addoption(parser):
13+
"""Add flag to run tests for extra MLIPs."""
14+
parser.addoption(
15+
"--run-slow",
16+
action="store_true",
17+
default=False,
18+
help="Run slow benchmarks",
19+
)
20+
21+
22+
def pytest_configure(config):
23+
"""Configure pytest to include marker for extra MLIPs."""
24+
config.addinivalue_line("markers", "slow: mark test as slow calculations")
25+
26+
27+
def pytest_collection_modifyitems(config, items):
28+
"""Skip tests if marker applied to unit tests."""
29+
if config.getoption("--run-slow"):
30+
# --run-slow given in cli: do not skip tests
31+
return
32+
skip_slow = pytest.mark.skip(reason="need --run-slow option to run")
33+
for item in items:
34+
if "slow" in item.keywords:
35+
item.add_marker(skip_slow)

docs/source/developer_guide/add_benchmarks.rst

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ Running Calculations
4444
2. Write a script that will run the MLIP calculations of interest for each model being tested.
4545

4646
The file should be named ``calc_[benchmark_name].py``,
47-
and placed in ``mlip_testing/calcs/[benchmark_name]``.
47+
and placed in ``mlip_testing/calcs/[category]/[benchmark_name]``.
4848

4949
While not a requirement, we recommend placing input files in
50-
``mlip_testing/calcs/[benchmark_name]/data``, and output files in
51-
``mlip_testing/calcs/[benchmark_name]/outputs``, for consistency.
50+
``mlip_testing/calcs/[category]/[benchmark_name]/data``, and output files in
51+
``mlip_testing/calcs/[category]/[benchmark_name]/outputs``, for consistency.
5252

5353
The test contained in this file may be runnable as a standalone script,
5454
but it should also be possible to run with ``pytest``, e.g.:
5555

5656
.. code-block:: bash
5757
58-
pytest -v -s mlip_testing/calcs/[benchmark_name]/calc_[benchmark_name].py
58+
pytest -v -s mlip_testing/calcs/[category]/[benchmark_name]/calc_[benchmark_name].py
5959
6060
6161
.. note::
@@ -121,7 +121,7 @@ b. Defining a ``ZnTrack`` node to run via ``mlipx``:
121121

122122
The process of running these is largely as
123123
`described by mlipx <https://mlipx.readthedocs.io/en/latest/quickstart/cli.html>`_,
124-
including running ``dvc init`` in ``mlip_testing/calcs/[benchmark_name]``.
124+
including running ``dvc init`` in ``mlip_testing/calcs/[category]/[benchmark_name]``.
125125

126126
.. note::
127127

@@ -229,12 +229,13 @@ directory to be accessed by the app.
229229
As with the script created in :ref:`calculations`, we create a new file to be run by ``pytest``,
230230
containing a function beginning with ``test_`` to launch the analysis.
231231

232-
In this case, we name the file ``mlip_testing/analysis/[benchmark_name]/analyse_[benchmark_name].py``,
232+
In this case, we name the file
233+
``mlip_testing/analysis/[category]/[benchmark_name]/analyse_[benchmark_name].py``,
233234
such that it can be run using:
234235

235236
.. code-block:: bash
236237
237-
pytest -v -s mlip_testing/analysis/[benchmark_name]/analyse_[benchmark_name].py
238+
pytest -v -s mlip_testing/analysis/[category]/[benchmark_name]/analyse_[benchmark_name].py
238239
239240
240241
In order to automatically generate the components for our application, we will make use
@@ -256,7 +257,7 @@ For ``@build_table``, the value returned should be of the form:
256257
This will generate a table with columns for each metric, as well as "MLIP", "Score",
257258
and "Rank" columns. Tooltips for each column header can also be set by the decorator,
258259
as well as the location to save the JSON file to be loaded when building the app,
259-
which typically would be placed in ``mlip_testing/app/data/[benchmark_name]``.
260+
which typically would be placed in ``mlip_testing/app/data/[category]/[benchmark_name]``.
260261

261262
Every benchmark should have at least one of these tables, which includes
262263
the score for each metric, and allowing the table to calculate an overall score for the
@@ -308,8 +309,11 @@ which allows the value returned by a function to be used directly as a parameter
308309
for other functions.
309310

310311
If your benchmark contains structures to be visualised, or images to be loaded, these
311-
should be saved to ``mlip_testing/app/data/[benchmark_name]``, as they must be added as
312-
``assets`` to be loaded into the app.
312+
should be saved to ``mlip_testing/app/data/[category]/[benchmark_name]``, as they must
313+
be added as ``assets`` to be loaded into the app.
314+
315+
Absolute paths to ``mlip_testing/app`` and ``mlip_testing/calcs`` can be imported for
316+
convenience.
313317

314318
.. note::
315319

@@ -320,10 +324,12 @@ should be saved to ``mlip_testing/app/data/[benchmark_name]``, as they must be a
320324
321325
from mlip_testing.analysis.utils.decorators import build_table, plot_parity
322326
from mlip_testing.analysis.utils.utils import mae
327+
from mlip_testing.app import APP_ROOT
328+
from mlip_testing.calcs import CALCS_ROOT
323329
from mlip_testing.calcs.models.models import MODELS
324330
325-
CALC_PATH = Path(__file__).parent.parent.parent / "calcs" / [benchmark_name] / "outputs"
326-
OUT_PATH = Path(__file__).parent.parent.parent / "app" / "data" / [benchmark_name]
331+
CALC_PATH = CALCS_ROOT / [category] / [benchmark_name] / "outputs"
332+
OUT_PATH = APP_ROOT / "data" / [category] / [benchmark_name]
327333
328334
REF_VALUES = {"path_b": 0.27, "path_c": 2.5}
329335
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
==========
2+
Benchmarks
3+
==========
4+
5+
.. toctree::
6+
:maxdepth: 3
7+
8+
surfaces
9+
nebs
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
====
2+
NEBs
3+
====
4+
5+
Li diffusion
6+
============
7+
8+
Summary
9+
-------
10+
11+
Performance in predicting activation energies of Li diffusion along the [010] and [001]
12+
directions of LiFePO_4.
13+
14+
Metrics
15+
-------
16+
17+
1. [010] (path B) energy barrier error
18+
19+
The initial and final structures for the diffusion of lithium along [010] are created
20+
through deletion an atom from the initial structure. These structures are relaxed,
21+
and the Nudged Elastic Band method is used to calculate the energy barrier. This is
22+
compared to the reference activation energy for this path.
23+
24+
25+
2. [001] (path C) energy barrier error
26+
27+
The initial and final structures for the diffusion of lithium along [001] are created
28+
through deletion an atom from the initial structure. These structures are relaxed,
29+
and the Nudged Elastic Band method is used to calculate the energy barrier. This is
30+
compared to the reference activation energy for this path.
31+
32+
Computational cost
33+
------------------
34+
35+
Medium: tests are likely to take several minutes to run on CPU.
36+
37+
38+
Data availability
39+
-----------------
40+
41+
Input structure:
42+
43+
* Downloaded from Materials Project (mp-19017): https://doi.org/10.17188/1193803
44+
45+
Reference data:
46+
47+
* Manually taken from https://doi.org/10.1149/1.1633511.
48+
* Meta-GGA (Perdew-Wang) exchange correlation functional
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
========
2+
Surfaces
3+
========
4+
5+
OC157
6+
=====
7+
8+
Summary
9+
-------
10+
11+
Performance in predicting relative energies between three configurations for 157
12+
molecule-surface combinations.
13+
14+
Metrics
15+
-------
16+
17+
1. Energy error
18+
19+
How accurate all relatve energy predictions are.
20+
21+
For each group of three structures, the relative energies are calculated for all pairs
22+
of structures. Models receive a score based on the mean difference between these
23+
predictions and the reference, averaged over all pairs and over all combinations.
24+
25+
2. Ranking error
26+
27+
Whether the most and least stable strucutres are predicted.
28+
29+
For each group of three structures, the relative energies are calculated for all pairs
30+
of structures. Models receive a score of 0, 0.5, or 1, based on whether the predicted
31+
lowest and highest energy pairs match the reference predictions, and this is averaged
32+
for all 157 combinations.
33+
34+
Computational cost
35+
------------------
36+
37+
Low: tests are likely to take a couple of minutes to run on CPU.
38+
39+
Data availability
40+
-----------------
41+
42+
Input data:
43+
44+
* Surfaces were taken from the Open Catalyst Challenge 2023
45+
46+
* L. Chanussot, A. Das, S. Goyal, T. Lavril, M. Shuaibi, M. Riviere, K. Tran, J. Heras-Domingo, C. Ho, W. Hu, A. Palizhati, A. Sriram, B. Wood, J. Yoon, D. Parikh, C. L. Zitnick, and Z. Ulissi, “Open Catalyst 2020 (OC20) dataset and community challenges,” ACS Catal., vol. 11, pp. 6059–6072, May 2021.
47+
* R. Tran, J. Lan, M. Shuaibi, B. M. Wood, S. Goyal, A. Das, J. Heras-Domingo, A. Kolluru, A. Rizvi, N. Shoghi, A. Sriram, F. Therrien, J. Abed, O. Voznyy, E. H. Sargent, Z. Ulissi, and C. L. Zitnick, “The Open Catalyst 2022 (OC22) data set and challenges for oxide electro catalysts,” ACS Catal., vol.13, pp. 3066–3084, Mar. 2023.
48+
49+
* Structures containing oxygen (O) and several transition metals (Co, Cr, Fe, Mn, Mo,
50+
Ni, V and W) were exlcuded due to Hubbard U correction
51+
52+
Reference data:
53+
54+
* Same as input data
55+
* PBE-D3(BJ), MPRelaxSet settings
56+
57+
58+
S24
59+
===
60+
61+
Summary
62+
-------
63+
64+
Performance in predicting adsorption energies for a diverse set of surfaces and adsorbates.
65+
66+
Metrics
67+
-------
68+
69+
Adsorption energy error
70+
71+
For each combination of surface, molecule, and surface + molecule, the adsorption
72+
energy is calculated by taking the difference between the energy of the surface +
73+
molecule and the sum of individual surface and molecule energies. This is compared to
74+
the reference adsorption energy, calculated in the same way.
75+
76+
Computational cost
77+
------------------
78+
79+
Very low: tests are likely to take less than a minute to run on CPU.
80+
81+
Data availability
82+
-----------------
83+
84+
Input data:
85+
86+
* Structures were taken from an amalgamation of published and unpublished works, including:
87+
88+
* Y. S. Al-Hamdani, M. Rossi, D. Alfè, T. Tsatsoulis, B. Ramberger, J. G. Brandenburg, A. Zen, G. Kresse, A. Grüneis, A. Tkatchenko, and A. Michaelides, “Properties of the water to boron nitride interaction: From zero to two dimensions with benchmark accuracy,” J. Chem. Phys., vol. 147, p. 044710, July 2017. 35
89+
* J. G. Brandenburg, A. Zen, M. Fitzner, B. Ramberger, G. Kresse, T. Tsatsoulis, A. Grüneis, A. Michaelides, and D. Alfè, “Physisorption of water on graphene: Subchemical accuracy from many- body electronic structure methods,” J. Phys. Chem. Lett., vol. 10, pp. 358–368, Feb. 2019.
90+
* C. Ehlert, A. Piras, and G. Gryn’ova, “CO2 on graphene: Benchmarking computational approaches to noncovalent interactions,” ACS Omega, vol. 8, pp. 35768–35778, Oct. 2023.
91+
* T. Tsatsoulis, S. Sakong, A. Groß, and A. Grüneis, “Reaction energetics of hydrogen on Si(100) surface: A periodic many-electron theory study,” J. Chem. Phys., vol. 149, p. 244105, Dec. 2018.
92+
* T. Tsatsoulis, F. Hummel, D. Usvyat, M. Schütz, G. H. Booth, S. S. Binnie, M. J. Gillan, D. Alfè, A. Michaelides, and A. Grüneis, “A comparison between quantum chemistry and quantum Monte Carlo techniques for the adsorption of water on the (001) LiH surface,” J. Chem. Phys., vol. 146, p. 204108, May 2017.
93+
* H.-Z. Ye and T. C. Berkelbach, “Ab initio surface chemistry with chemical accuracy,” arXiv preprint arXiv:2309.14640, 2023.
94+
* P. G. Lustemberg, P. N. Plessow, Y. Wang, C. Yang, A. Nefedov, F. Studt, C. Wöll, and M. V. Ganduglia-Pirovano, “Vibrational frequencies of cerium-oxide-bound CO: A challenge for conventional dft methods,” Phys. Rev. Lett., vol. 125, p. 256101, Dec. 2020.
95+
* B. X. Shi, A. Zen, V. Kapil, P. R. Nagy, A. Grüneis, and A. Michaelides, “Many-body methods for surface chemistry come of age: Achieving consensus with experiments,” J. Am. Chem. Soc., vol. 145, pp. 25372–25381, Nov. 2023.
96+
* N. Hanikel, X. Pei, S. Chheda, H. Lyu, W. Jeong, J. Sauer, L. Gagliardi, and O. M. Yaghi, “Evolution of water structures in metal-organic frameworks for improved atmospheric water harvesting,” Science, vol. 374, pp. 454–459, 2021.
97+
* F. Berger, M. Rybicki, and J. Sauer, “Molecular dynamics with chemical accuracy–Alkane adsorption in acidic zeolites,” ACS Catal., vol. 13, pp. 2011–2024, 2023.
98+
* F. Berger and J. Sauer, “Dimerization of linear butenes and pentenes in an acidic zeolite (H-MFI),” Angew. Chem., Int. Ed., vol. 60, pp. 3529–3533, 2021.
99+
100+
Reference data:
101+
102+
* Same as input data
103+
* PBE-D3(BJ), MPRelaxSet settings

0 commit comments

Comments
 (0)