diff --git a/src/pymatgen/io/vasp/outputs.py b/src/pymatgen/io/vasp/outputs.py index 841f28c1070..caf3f2c5b56 100644 --- a/src/pymatgen/io/vasp/outputs.py +++ b/src/pymatgen/io/vasp/outputs.py @@ -5765,6 +5765,7 @@ class VaspDir(collections.abc.Mapping): "POSCAR": Poscar, "CONTCAR": Poscar, "KPOINTS": Kpoints, + "IBZKPT": Kpoints, "POTCAR": Potcar, "vasprun": Vasprun, "OUTCAR": Outcar, @@ -5786,8 +5787,8 @@ def __init__(self, dirname: str | Path): Args: dirname: The directory containing the VASP calculation as a string or Path. """ - self.path = Path(dirname) - self.files = [f.name for f in self.path.iterdir() if f.is_file()] + self.path = Path(dirname).absolute() + self.files = [Path(d) / f for d, subd, fnames in os.walk(self.path) for f in fnames] self._parsed_files: dict[str, Any] = {} def reset(self): @@ -5795,7 +5796,7 @@ def reset(self): Reset all loaded files and recheck the directory for files. Use this when the contents of the directory has changed. """ - self.files = [f for f in self.path.iterdir() if f.is_file()] + self.files = [Path(d) / f for d, subd, fnames in os.walk(self.path) for f in fnames] self._parsed_files = {} def __len__(self): diff --git a/tests/io/vasp/test_outputs.py b/tests/io/vasp/test_outputs.py index 56c8e2d493d..f20605720ff 100644 --- a/tests/io/vasp/test_outputs.py +++ b/tests/io/vasp/test_outputs.py @@ -2196,6 +2196,12 @@ def test_getitem(self): with pytest.raises(ValueError, match="hello not found"): d["hello"] - d = VaspDir(f"{TEST_FILES_DIR}/io/vasp/outputs") - with pytest.warns(UserWarning, match=r"No parser defined for IBZKPT.*"): - assert isinstance(d["IBZKPT.lobster"], str) + d = VaspDir(f"{TEST_FILES_DIR}/io/pwscf") + with pytest.warns(UserWarning, match=r"No parser defined for Si.pwscf.out"): + assert isinstance(d["Si.pwscf.out"], str) + + # Test NEB directories. + d = VaspDir(f"{TEST_FILES_DIR}/io/vasp/fixtures/neb_analysis/neb1/neb") + assert len(d) == 10 + + assert isinstance(d["00/POSCAR"], Poscar)