Skip to content

Commit

Permalink
remove old tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz committed Jul 27, 2024
1 parent 4eee408 commit 606181b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 450 deletions.
38 changes: 36 additions & 2 deletions source/tests/infer/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class TestDeepPot(unittest.TestCase):
def setUpClass(cls):
key, extension = cls.param
cls.case = get_cases()[key]
model_name = cls.case.get_model(extension)
cls.dp = DeepEval(model_name)
cls.model_name = cls.case.get_model(extension)
cls.dp = DeepEval(cls.model_name)

@classmethod
def tearDownClass(cls):
Expand Down Expand Up @@ -207,6 +207,40 @@ def test_zero_input(self):
np.testing.assert_almost_equal(ee.ravel(), 0, default_places)
np.testing.assert_almost_equal(vv.ravel(), 0, default_places)

def test_ase(self):
from ase import (
Atoms,
)

from deepmd.calculator import (
DP,
)

for ii, result in enumerate(self.case.results):
water = Atoms(
np.array(self.case.type_map)[result.atype].tolist(),
positions=result.coord.reshape((-1, 3)),
cell=result.box.reshape((3, 3)) if result.box is not None else None,
calculator=DP(self.model_name),
pbc=result.box is not None,
)
ee = water.get_potential_energy()
ff = water.get_forces()
nframes = 1
np.testing.assert_almost_equal(
ff.ravel(),
result.force.ravel(),
default_places,
err_msg=f"Result {ii} force",
)
expected_se = np.sum(result.atomic_energy.reshape([nframes, -1]), axis=1)
np.testing.assert_almost_equal(
ee.ravel(),
expected_se.ravel(),
default_places,
err_msg=f"Result {ii} energy",
)

def test_dpdata_driver(self):
for ii, result in enumerate(self.case.results):
nframes = 1
Expand Down
Loading

0 comments on commit 606181b

Please sign in to comment.