pymatgen
pymatgen copied to clipboard
Crash in Bader analysis due to missing file
Describe the bug A clear and concise description of what the bug is.
Bader seems to run normally, but fails stating a file does not exist. The details are below.
To Reproduce Steps to reproduce the behavior:
The files necessary to reproduce the bug are too large to post here (800 MB CHGCAR), but the CHGCAR was created for a 114 atom system. The detailed error message is below. I followed the progress of the bader program while the calculation was continuing and could see a temporary directory was created (see below) and indeed the file referenced in the error is missing, but no errors were given up to the point of the crash. The temporary directory was deleted upon the error.
-rw-r--r-- 1 9484 Aug 25 11:28 ACF.dat
-rw-r--r-- 1 2326 Aug 25 11:28 AVF.dat
-rw-r--r-- 1 15767 Aug 25 11:28 BCF.dat
-rw-r--r-- 1 407590595 Aug 25 11:28 BvAt0001.dat
-rw-r--r-- 1 407590595 Aug 25 11:29 BvAt0002.dat
-rw-r--r-- 1 407590595 Aug 25 11:29 BvAt0003.dat
-rw-r--r-- 1 407590595 Aug 25 11:29 BvAt0004.dat
-rw-r--r-- 1 407590595 Aug 25 11:29 BvAt0005.dat
-rw-r--r-- 1 407590595 Aug 25 11:30 BvAt0006.dat
-rw-r--r-- 1 407590595 Aug 25 11:30 BvAt0007.dat
-rw-r--r-- 1 407590595 Aug 25 11:30 BvAt0008.dat
-rw-r--r-- 1 407590595 Aug 25 11:30 BvAt0009.dat
-rw-r--r-- 1 407590595 Aug 25 11:31 BvAt0010.dat
-rw-r--r-- 1 407590595 Aug 25 11:31 BvAt0011.dat
-rw-r--r-- 1 407590595 Aug 25 11:31 BvAt0012.dat
-rw-r--r-- 1 407590595 Aug 25 11:31 BvAt0013.dat
-rw-r--r-- 1 407590595 Aug 25 11:32 BvAt0014.dat
-rw-r--r-- 1 407590595 Aug 25 11:32 BvAt0015.dat
-rw-r--r-- 1 407590595 Aug 25 11:32 BvAt0016.dat
-rw-r--r-- 1 407590595 Aug 25 11:32 BvAt0017.dat
-rw-r--r-- 1 407590595 Aug 25 11:33 BvAt0018.dat
-rw-r--r-- 1 407590595 Aug 25 11:33 BvAt0019.dat
-rw-r--r-- 1 407590595 Aug 25 11:33 BvAt0020.dat
-rw-r--r-- 1 407590595 Aug 25 11:34 BvAt0021.dat
-rw-r--r-- 1 407590595 Aug 25 11:34 BvAt0022.dat
-rw-r--r-- 1 407590595 Aug 25 11:34 BvAt0023.dat
-rw-r--r-- 1 407590595 Aug 25 11:34 BvAt0024.dat
-rw-r--r-- 1 407590595 Aug 25 11:35 BvAt0025.dat
-rw-r--r-- 1 407590595 Aug 25 11:35 BvAt0026.dat
-rw-r--r-- 1 407590595 Aug 25 11:35 BvAt0027.dat
-rw-r--r-- 1 407590595 Aug 25 11:35 BvAt0028.dat
-rw-r--r-- 1 407590595 Aug 25 11:36 BvAt0029.dat
-rw-r--r-- 1 407590595 Aug 25 11:36 BvAt0030.dat
-rw-r--r-- 1 407590595 Aug 25 11:36 BvAt0031.dat
-rw-r--r-- 1 407590595 Aug 25 11:36 BvAt0032.dat
-rw-r--r-- 1 407590595 Aug 25 11:37 BvAt0033.dat
-rw-r--r-- 1 407590595 Aug 25 11:37 BvAt0034.dat
-rw-r--r-- 1 407590595 Aug 25 11:37 BvAt0035.dat
-rw-r--r-- 1 407590595 Aug 25 11:37 BvAt0036.dat
-rw-r--r-- 1 407590595 Aug 25 11:38 BvAt0037.dat
-rw-r--r-- 1 407590595 Aug 25 11:38 BvAt0038.dat
-rw-r--r-- 1 407590595 Aug 25 11:38 BvAt0039.dat
-rw-r--r-- 1 407590595 Aug 25 11:38 BvAt0040.dat
-rw-r--r-- 1 407590595 Aug 25 11:39 BvAt0041.dat
-rw-r--r-- 1 407590595 Aug 25 11:39 BvAt0042.dat
-rw-r--r-- 1 407590595 Aug 25 11:39 BvAt0043.dat
-rw-r--r-- 1 407590595 Aug 25 11:40 BvAt0044.dat
-rw-r--r-- 1 407590595 Aug 25 11:40 BvAt0045.dat
-rw-r--r-- 1 407590595 Aug 25 11:40 BvAt0092.dat
-rw-r--r-- 1 407590595 Aug 25 11:40 BvAt0093.dat
-rw-r--r-- 1 407590595 Aug 25 11:41 BvAt0094.dat
-rw-r--r-- 1 407590595 Aug 25 11:41 BvAt0095.dat
-rw-r--r-- 1 407590595 Aug 25 11:41 BvAt0096.dat
-rw-r--r-- 1 407590595 Aug 25 11:41 BvAt0097.dat
-rw-r--r-- 1 407590595 Aug 25 11:42 BvAt0098.dat
-rw-r--r-- 1 69705047 Aug 25 11:42 BvAt0099.dat
-rw-r--r-- 1 815356319 Aug 25 11:27 CHGCAR
In [1]: from pymatgen.command_line.bader_caller import BaderAnalysis
In [2]: bader = BaderAnalysis()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 bader = BaderAnalysis()
File /data/miniconda/envs/pymatgen/lib/python3.10/site-packages/monty/dev.py:97, in requires.__call__.<locals>.decorated(*args, **kwargs)
95 if not self.condition:
96 raise RuntimeError(self.message)
---> 97 return _callable(*args, **kwargs)
File /data/miniconda/envs/pymatgen/lib/python3.10/site-packages/pymatgen/command_line/bader_caller.py:128, in BaderAnalysis.__init__(self, chgcar_filename, potcar_filename, chgref_filename, parse_atomic_densities, cube_filename)
121 raise RuntimeError(
122 "BaderAnalysis requires the executable bader to be in the path."
123 " Please download the library at http://theory.cm.utexas"
124 ".edu/vasp/bader/ and compile the executable."
125 )
127 if not (cube_filename or chgcar_filename):
--> 128 raise ValueError("You must provide either a cube file or a CHGCAR")
129 if cube_filename and chgcar_filename:
130 raise ValueError("You cannot parse a cube and a CHGCAR at the same time.")
ValueError: You must provide either a cube file or a CHGCAR
In [3]: bader = BaderAnalysis(chgcar_filename="CHGCAR",potcar_filename="POTCAR",parse_atomic_densities=True))
Input In [3]
bader = BaderAnalysis(chgcar_filename="CHGCAR",potcar_filename="POTCAR",parse_atomic_densities=True))
^
SyntaxError: unmatched ')'
In [4]: bader = BaderAnalysis(chgcar_filename="CHGCAR",potcar_filename="POTCAR",parse_atomic_densities=True)
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 bader = BaderAnalysis(chgcar_filename="CHGCAR",potcar_filename="POTCAR",parse_atomic_densities=True)
File /data/miniconda/envs/pymatgen/lib/python3.10/site-packages/monty/dev.py:97, in requires.__call__.<locals>.decorated(*args, **kwargs)
95 if not self.condition:
96 raise RuntimeError(self.message)
---> 97 return _callable(*args, **kwargs)
File /data/miniconda/envs/pymatgen/lib/python3.10/site-packages/pymatgen/command_line/bader_caller.py:214, in BaderAnalysis.__init__(self, chgcar_filename, potcar_filename, chgref_filename, parse_atomic_densities, cube_filename)
210 self.data = data
212 if self.parse_atomic_densities:
213 # convert the charge density for each atom spit out by Bader into Chgcar objects for easy parsing
--> 214 atom_chgcars = [
215 Chgcar.from_file(f"BvAt{str(i).zfill(4)}.dat") for i in range(1, len(self.chgcar.structure) + 1)
216 ]
218 atomic_densities = []
219 # For each atom in the structure
File /data/miniconda/envs/pymatgen/lib/python3.10/site-packages/pymatgen/command_line/bader_caller.py:215, in <listcomp>(.0)
210 self.data = data
212 if self.parse_atomic_densities:
213 # convert the charge density for each atom spit out by Bader into Chgcar objects for easy parsing
214 atom_chgcars = [
--> 215 Chgcar.from_file(f"BvAt{str(i).zfill(4)}.dat") for i in range(1, len(self.chgcar.structure) + 1)
216 ]
218 atomic_densities = []
219 # For each atom in the structure
File /data/miniconda/envs/pymatgen/lib/python3.10/site-packages/pymatgen/io/vasp/outputs.py:4002, in Chgcar.from_file(filename)
3994 @staticmethod
3995 def from_file(filename):
3996 """
3997 Reads a CHGCAR file.
3998
3999 :param filename: Filename
4000 :return: Chgcar
4001 """
-> 4002 (poscar, data, data_aug) = VolumetricData.parse_file(filename)
4003 return Chgcar(poscar, data, data_aug=data_aug)
File /data/miniconda/envs/pymatgen/lib/python3.10/site-packages/pymatgen/io/vasp/outputs.py:3625, in VolumetricData.parse_file(filename)
3623 data_count = 0
3624 poscar = None
-> 3625 with zopen(filename, "rt") as f:
3626 for line in f:
3627 original_line = line
File /data/miniconda/envs/pymatgen/lib/python3.10/site-packages/monty/io.py:45, in zopen(filename, *args, **kwargs)
43 if ext in (".XZ", ".LZMA"):
44 return lzma.open(filename, *args, **kwargs)
---> 45 return open(filename, *args, **kwargs)
FileNotFoundError: [Errno 2] No such file or directory: 'BvAt0046.dat'
Provide any example files that are needed to reproduce the error, especially if the bug pertains to parsing of a file.
Expected behavior
The bader charges should have been returned.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Linux CentOS 7
- Version [e.g. 2019.9.16]
Additional context Add any other context about the problem here.