Skip to content

Commit

Permalink
Add test for relaxation trajectory saving.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyue Ping Ong committed Jul 26, 2023
1 parent 7449a5b commit ebf7f3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 0 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@
from __future__ import annotations

import pytest
from pymatgen.core import Lattice, Molecule, Structure
from pymatgen.util.testing import PymatgenTest

from matgl.ext.pymatgen import Molecule2Graph, Structure2Graph, get_element_list
from matgl.graph.compute import (
compute_pair_vector_and_distance,
)


@pytest.fixture(scope="session")
def LiFePO4():
Expand Down
3 changes: 3 additions & 0 deletions tests/test_phonon.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
from __future__ import annotations


def test_PhononCalc():
assert True
10 changes: 7 additions & 3 deletions tests/test_relaxation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest
import matgl
from __future__ import annotations

import os

import matgl
import pytest
from matgl.ext.ase import M3GNetCalculator

from matcalc.relaxation import RelaxCalc
Expand All @@ -10,7 +13,7 @@ def test_RelaxCalc(LiFePO4):
potential = matgl.load_model("M3GNet-MP-2021.2.8-PES")
calculator = M3GNetCalculator(potential=potential, stress_weight=0.01)

pcalc = RelaxCalc(calculator)
pcalc = RelaxCalc(calculator, traj_file="lfp_relax.txt")
results = pcalc.calc(LiFePO4)
assert results["a"] == pytest.approx(4.755711375217371)
assert results["b"] == pytest.approx(6.131614236614623)
Expand All @@ -23,3 +26,4 @@ def test_RelaxCalc(LiFePO4):
results = list(pcalc.calc_many([LiFePO4] * 2))
assert len(results) == 2
assert results[-1]["a"] == pytest.approx(4.755711375217371)
os.remove("lfp_relax.txt")

0 comments on commit ebf7f3c

Please sign in to comment.