File size: 1,025 Bytes
1c7cd6c
 
 
52c1bfb
1c7cd6c
f1eddde
 
1c7cd6c
 
5b87ae4
e59afe6
 
 
 
8396dce
 
 
f1eddde
 
 
 
 
 
1c7cd6c
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pytest
from ase import Atoms

from mlip_arena.models import MLIPEnum

from requests import HTTPError
from huggingface_hub.errors import LocalTokenNotFoundError

@pytest.mark.parametrize("model", MLIPEnum)
def test_calculate(model: MLIPEnum):

    if model.name == "ALIGNN":
        pytest.xfail("ALIGNN has poor file download mechanism")

    if model.name == "ORB":
        pytest.xfail("Orbital Materials deprecated the model a month after its premature release in favor of ORBv2")

    try:
        calc = MLIPEnum[model.name].value()

    except (LocalTokenNotFoundError, HTTPError):
        # Gracefully skip the test if HF_TOKEN is not available
        pytest.skip("Skipping test because HF_TOKEN is not available for downloading the model.")

    atoms = Atoms(
        "OO",
        positions=[[0, 0, 0], [1.5, 0, 0]],
        cell=[10, 10 + 0.001, 10 + 0.002],
        pbc=True,
    )

    atoms.calc = calc

    print(atoms.get_potential_energy())
    assert isinstance(atoms.get_potential_energy(), float)