Skip to content
Open
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
6 changes: 6 additions & 0 deletions dpgen2/conf/file_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ def generate_mixed(
assert "deepmd/npy/mixed" == self.fmt
ms = dpdata.MultiSystems(type_map=type_map)
ms.from_deepmd_npy_mixed(self.files[0], fmt="deepmd/npy/mixed", labeled=False) # type: ignore
if self.remove_pbc:
# Keep mixed-format configurations consistent with the standard
# file path: every reconstructed chemical system must receive the
# requested non-periodic cell transformation.
for system in ms.systems.values():
system.remove_pbc()
return ms

@staticmethod
Expand Down
16 changes: 16 additions & 0 deletions tests/conf/test_file_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ def test_deepmd_mixed(self):
np.testing.assert_almost_equal(ms[1][tt], ms1[1][tt])
shutil.rmtree("test_mixed")

def test_deepmd_mixed_remove_pbc(self):
type_map = ["Cu", "Al", "Mg"]
ms = dpdata.MultiSystems(type_map=type_map)
ms.append(dpdata.System(Path(self.prefix) / "poscar.foo.0", fmt="vasp/poscar"))
ms.to("deepmd/npy/mixed", "test_mixed_remove_pbc")
self.addCleanup(shutil.rmtree, "test_mixed_remove_pbc", ignore_errors=True)

loaded = FileConfGenerator(
"test_mixed_remove_pbc",
fmt="deepmd/npy/mixed",
remove_pbc=True,
).generate(type_map)

np.testing.assert_allclose(loaded[0]["cells"][0], np.eye(3) * 18.0)
np.testing.assert_allclose(loaded[0]["coords"][0, 0], np.full(3, 9.0))


class TestFileConfGeneratorContent(unittest.TestCase):
def test_list_1(self):
Expand Down