-
Notifications
You must be signed in to change notification settings - Fork 875
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
Some OUTCARs cannot be parsed #4251
Comments
Thanks for opening this. I will look into this ASAP, link to #4195 Update: I cannot reproduce this on MacOS 15.2, Python 3.12.8 from pymatgen.io.vasp.outputs import Outcar
outcar = Outcar('OUTCAR.txt')
print(outcar.data["nbands"]) # 24 (seems to work fine) |
Oops. Sorry, attached a wrong OUTCAR file. Try this one |
Thanks this seems to recreate that issue now. However this VASP job seem to fail owing to a bad KPOINTS file, so perhaps this should not be handled by
If you comment out the NBANDS parsing part, yet another error would be thrown:
So perhaps it's better to provide a correctly started VASP job? |
Hmm. You are right. My confusion is probably originating from that fact that pymatgen can actually read OUTCAR from failed jobs most of the time. It is just that in this particular case the job failed especially early. It would be nice to throw a more readable exception (and document this fact) in the scenarios like in my example, when pymatgen cannot extract any kind of useful data from the OUTCAR. |
I agree having a descriptive exception message is always better. But currently it's unclear to me what is a reliable criterion from OUTCAR that indicating a VASP job has been properly setup and started. Looks like NBANDS might be one of the first parameters after KPOINTS are setup, do you have any comment on this? Looking at line 414 of your first OUTCAR (where the job started correctly)
|
IMHO, trying to deduce the undocumented OUTCAR format exactly is prone to errors.
According to the docstring, some parts of the OUTCAR are parsed conditionally. Similar to the optional parts of the OUTCAR, the "always present" parts (not always, as we see in my OUTCAR.txt) might be parsed conditionally - if they can be parsed, they do get added to the class. If not - not added. Paractically, I imagine that the class constructor can be separated into subroutines each parsing individual part of the file. If any of the subroutines throws an error or detects in any other way that some information is not present, either a error is thrown or a warning is displayed. |
If we do want some kind of simple criterion that VASP started a calculation (not stopped in the middle of a setup), one heuristics might be searching for |
pymatgen can usually parse OUTCARs from failed calculations only if they've reached at least one electronic step. Is there info in the OUTCAR that you need to extract in this case? Most of it is user input since it didn't reach k-point generation Also, you may want to look into |
For example, whether WAVECAR/CHGCAR has been read successfully (or at all). For context, I am using a class derived from the original Outcar with some extensions. The main focus is displaying key information about running VASP calculation. That said, I am not saying that pymatgen should implement the more granular parsing as I described. Throwing a catchable exception would suffice for my needs.
I've looked at it. It is not suitable for my needs as it produces results that are not comparable when analyzing several related structures. It will also not recover from this particular problem with parsing KPOINTS file (which is simply a VASP bug). But that's probably an off topic to this particular bug report. |
That's already possible no?
Restricting the exception catching to There's some precedent for parsing partial VASP output in the Maybe using the |
Yes, of course. But it is much better when pymatgen signals a very specific exception type that tells what exactly is wrong. And nothing in the docstring says that some Outcars cannot be read.
That would be ideal, although I am not 100% if it is worth the effort.
Oh. I wish it were true. But it is not:
|
I am closing this Issue since I don't think it is fruitful to try to implement. The main reason is that the OUTCAR is a poorly defined text file, unlike say XML. The OUTCAR can be incomplete for any number of reasons. E.g., say if the compute cluster just randomly terminates a run. At best, we can have a big try-catch and raise a "BadOutcar" error, but that is not going to be useful since there is no way to diagnose the reason for the error. In the extreme example, say a run results in a completely empty OUTCAR file - what then? A broad BadOutcar error is not much different from doing a try-catch with a BaseException. |
Python version
Python 3.12.4
Pymatgen version
2025.1.9
Operating system version
Linux
Current behavior
Expected Behavior
Outcar being parsed.
Minimal example
Relevant files to reproduce this bug
OUTCAR.txt
The text was updated successfully, but these errors were encountered: