Skip to content

Commit

Permalink
Use test fixture for M3GNetUPCalc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyue Ping Ong committed Aug 1, 2023
1 parent 2580a6e commit be3a9cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@
from __future__ import annotations

import pytest
import matgl
from pymatgen.util.testing import PymatgenTest
from matgl.ext.ase import M3GNetCalculator


@pytest.fixture(scope="session")
def LiFePO4():
return PymatgenTest.get_structure("LiFePO4")


@pytest.fixture(scope="session")
def M3GNetUPCalc():
potential = matgl.load_model("M3GNet-MP-2021.2.8-PES")
return M3GNetCalculator(potential=potential, stress_weight=0.01)
5 changes: 4 additions & 1 deletion tests/test_phonon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

from matcalc.phonon import PhononCalc

def test_PhononCalc():

def test_PhononCalc(M3GNetUPCalc):
calc = PhononCalc(M3GNetUPCalc)
assert True
7 changes: 3 additions & 4 deletions tests/test_relaxation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

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


from matcalc.relaxation import RelaxCalc


def test_RelaxCalc(LiFePO4):
potential = matgl.load_model("M3GNet-MP-2021.2.8-PES")
calculator = M3GNetCalculator(potential=potential, stress_weight=0.01)
def test_RelaxCalc(LiFePO4, M3GNetUPCalc):
calculator = M3GNetUPCalc

pcalc = RelaxCalc(calculator, traj_file="lfp_relax.txt")
results = pcalc.calc(LiFePO4)
Expand Down

0 comments on commit be3a9cc

Please sign in to comment.