Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ ignore_missing_imports = true
disable_error_code = ["union-attr"]

[tool.pytest.ini_options]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
]
filterwarnings = [
"error",
"ignore:custom data:UserWarning",
Expand Down
43 changes: 43 additions & 0 deletions tests/test_edge_cases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import ase.build
import ase.io
import ase.units
import torch
from ase.md import VelocityVerlet

from flashmd import get_pretrained
from flashmd.ase import EnergyCalculator


def test_isolated_atom(monkeypatch, tmp_path):
"""Test that a short MD run completes without errors on an isolated atom."""
monkeypatch.chdir(tmp_path)

atoms = ase.Atoms("O", positions=[[0, 0, 0]])

time_step = 64
device = "cuda" if torch.cuda.is_available() else "cpu"
energy_model, _ = get_pretrained("pet-omatpes-v2", time_step)
calculator = EnergyCalculator(energy_model, device=device)
atoms.calc = calculator

dyn = VelocityVerlet(atoms=atoms, timestep=time_step * ase.units.fs)
dyn.run(10)


def test_slab_plus_isolated_atom(monkeypatch, tmp_path):
"""Test that a short MD run completes without errors on a slab plus an isolated atom."""
monkeypatch.chdir(tmp_path)

# Create a slab and an isolated atom
slab = ase.build.fcc111("Al", size=(2, 2, 3), vacuum=10)
isolated_atom = ase.Atoms("O", positions=[[0, 0, 24]])
atoms = slab + isolated_atom

time_step = 64
device = "cuda" if torch.cuda.is_available() else "cpu"
energy_model, _ = get_pretrained("pet-omatpes-v2", time_step)
calculator = EnergyCalculator(energy_model, device=device)
atoms.calc = calculator

dyn = VelocityVerlet(atoms=atoms, timestep=time_step * ase.units.fs)
dyn.run(10)