Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vasprun parser raises a FileNotFoundError when searching for POTCARs with pymatgen 2024.1.26 #3586

Closed
Andrew-S-Rosen opened this issue Jan 26, 2024 · 2 comments
Labels

Comments

@Andrew-S-Rosen
Copy link
Member

Andrew-S-Rosen commented Jan 26, 2024

Python version

3.11

Pymatgen version

2024.1.26

Operating system version

Ubuntu

Current behavior

Do the following in a completed folder containing a VASP run.

from pymatgen.io.vasp.outputs import Vasprun

Vasprun('vasprun.xml')
File /scratch/network/asrosen/software/miniconda/envs/quacc/lib/python3.10/site-packages/pymatgen/i
o/vasp/outputs.py:296, in Vasprun.__init__(self, filename, ionic_step_skip, ionic_step_offset, pars
e_dos, parse_eigen, parse_projected_eigen, parse_potcar_file, occu_tol, separate_spins, exception_o
n_bad_xml)
    293         self.nionic_steps = len(self.ionic_steps)
    295     if parse_potcar_file:
--> 296         self.update_potcar_spec(parse_potcar_file)
    297         self.update_charge_from_potcar(parse_potcar_file)
    299 if self.incar.get("ALGO") not in ["CHI", "BSE"] and not self.converged and self.parameters.
get("IBRION") != 0:
File /scratch/network/asrosen/software/miniconda/envs/quacc/lib/python3.10/site-packages/pymatgen/i
o/vasp/outputs.py:1054, in Vasprun.update_potcar_spec(self, path)
   1046 def update_potcar_spec(self, path):
   1047     """
   1048     Args:
   1049         path: Path to search for POTCARs
   (...)
   1052         Potcar spec from path.
   1053     """
-> 1054     if potcar := self.get_potcars(path):
   1055         self.potcar_spec = [
   1056             {"titel": sym, "hash": ps.md5_header_hash, "summary_stats": ps._summary_stats}
   1057             for sym in self.potcar_symbols
   1058             for ps in potcar
   1059             if ps.symbol == sym.split()[1]
   1060         ]
File /scratch/network/asrosen/software/miniconda/envs/quacc/lib/python3.10/site-packages/pymatgen/i
o/vasp/outputs.py:1010, in Vasprun.get_potcars(self, path)
   1007 else:
   1008     search_path = os.path.split(self.filename)[0] if path is True else str(path)
   1009     potcar_paths = [
-> 1010         f"{search_path}/{fn}" for fn in os.listdir(search_path) if fn.startswith("POTCAR") 
and ".spec" not in fn
   1011     ]
   1013 for potcar_path in potcar_paths:
   1014     try:
FileNotFoundError: [Errno 2] No such file or directory: ''

Here are the files in my directory (can share over Slack since POTCAR is proprietary).

AECCAR0       CHGCAR          IBZKPT        OSZICAR      POTCAR       vasp.out
AECCAR1       CONTCAR         INCAR         OUTCAR       POTCAR.orig  vaspout.h5
AECCAR2       custodian.json  INCAR.orig    PCDAT        PROCAR       vasprun.xml
ase-sort.dat  DOSCAR          KPOINTS       POSCAR       REPORT       WAVECAR
CHG           EIGENVAL        KPOINTS.orig  POSCAR.orig  std_err.txt  XDATCAR

Likely introduced in #3491.

Expected Behavior

The Vasprun should correctly identify the POTCAR file in the present working directory.

@Andrew-S-Rosen Andrew-S-Rosen changed the title Vasprun parser raises a FileNotFoundError with pymatgen 2024.1.26 Vasprun parser raises a FileNotFoundError when searching for POTCARs with pymatgen 2024.1.26 Jan 26, 2024
@esoteric-ephemera
Copy link
Contributor

Thanks @Andrew-S-Rosen! If anyone else encounters this issue while using this release of pymatgen, please note that using Vasprun("./vasprun.xml") should correctly parse the POTCAR in the current (relative) working directory.

Fixed (hopefully) in #3587

@Andrew-S-Rosen
Copy link
Member Author

Andrew-S-Rosen commented Jan 27, 2024

Thanks! As a note, this workaround isn't possible when using several external codes depending on Pymatgen. For instance, Custodian by default will call Vasprun("vasprun.xml") somewhere I believe. In any case, your PR should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants