Skip to content

Commit 233c2a9

Browse files
jmmshnjmmshn-msJaGeo
authored
allow newer pymatgen verions (#1105)
Co-authored-by: Jimmy Shen <[email protected]> Co-authored-by: J. George <[email protected]>
1 parent edbd0b1 commit 233c2a9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/atomate2/vasp/sets/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,18 @@ def incar_updates(self) -> dict:
687687
@staticmethod
688688
def _get_ensemble_defaults(structure: Structure, ensemble: str) -> dict[str, Any]:
689689
"""Get default params for the ensemble."""
690+
# Handle both old (ntypesp) and new (n_elems) pymatgen versions
691+
n_types = getattr(structure, "n_elems", None)
692+
if n_types is None:
693+
n_types = structure.ntypesp
694+
690695
defaults = {
691696
"nve": {"MDALGO": 1, "ISIF": 2, "ANDERSEN_PROB": 0.0},
692697
"nvt": {"MDALGO": 2, "ISIF": 2, "SMASS": 0},
693698
"npt": {
694699
"MDALGO": 3,
695700
"ISIF": 3,
696-
"LANGEVIN_GAMMA": [10] * structure.ntypesp,
701+
"LANGEVIN_GAMMA": [10] * n_types,
697702
"LANGEVIN_GAMMA_L": 1,
698703
"PMASS": 10,
699704
"PSTRESS": 0,

0 commit comments

Comments
 (0)