-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 781 pymatgen structure bug (#782)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced support for PyMatGen structure format conversion - Improved handling of periodic boundary conditions (PBC) - **Tests** - Added new test class for PyMatGen structure conversion - Expanded test data with additional element types (Fe, Li, O, P) - **Bug Fixes** - Refined atomic species list generation - Improved error handling for structure periodicity <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Han Wang <[email protected]>
- Loading branch information
1 parent
961b591
commit 5ebe959
Showing
11 changed files
with
177 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
1 | ||
1 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
3 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 | ||
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Fe | ||
Li | ||
O | ||
P |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
import unittest | ||
|
||
from comp_sys import CompSys, IsNoPBC, IsPBC | ||
from context import dpdata | ||
|
||
try: | ||
from pymatgen.core import Structure # noqa: F401 | ||
|
||
exist_module = True | ||
except Exception: | ||
exist_module = False | ||
|
||
|
||
@unittest.skipIf(not exist_module, "skip pymatgen") | ||
class TestFormPytmatgen(unittest.TestCase, CompSys): | ||
def setUp(self): | ||
structure = Structure.from_file(os.path.join("poscars", "POSCAR.P42nmc")) | ||
self.system_1 = dpdata.System(structure, fmt="pymatgen/structure") | ||
self.system_2 = dpdata.System( | ||
os.path.join("poscars", "POSCAR.P42nmc"), fmt="poscar" | ||
) | ||
self.places = 6 | ||
self.e_places = 6 | ||
self.f_places = 6 | ||
self.v_places = 6 | ||
|
||
|
||
@unittest.skipIf(not exist_module, "skip pymatgen") | ||
class TestFormToPytmatgen(unittest.TestCase, CompSys, IsPBC): | ||
def setUp(self): | ||
self.system = dpdata.System("pymatgen_data/deepmd/", fmt="deepmd/npy") | ||
self.system_1 = self.system | ||
self.system_2 = dpdata.System().from_pymatgen_structure( | ||
self.system.to("pymatgen/structure")[0] | ||
) | ||
self.places = 6 | ||
self.e_places = 6 | ||
self.f_places = 6 | ||
self.v_places = 6 | ||
|
||
|
||
@unittest.skipIf(not exist_module, "skip pymatgen") | ||
class TestFormToPytmatgenNopbc(unittest.TestCase, CompSys, IsNoPBC): | ||
def setUp(self): | ||
self.system = dpdata.System("pymatgen_data/deepmd/", fmt="deepmd/npy") | ||
self.system.data["nopbc"] = True | ||
self.system_1 = self.system | ||
self.system_2 = dpdata.System().from_pymatgen_structure( | ||
self.system.to("pymatgen/structure")[0] | ||
) | ||
self.places = 6 | ||
self.e_places = 6 | ||
self.f_places = 6 | ||
self.v_places = 6 | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |