Skip to content

Error when initializing Vasprun when LDAUL/J or MAGMOM exception triggers #3622

Open
@fyalcin

Description

Python version

Python 3.10.13

Pymatgen version

2023.12.18

Operating system version

Mint 20

Current behavior

I wasn't sure where to post this as it triggered when VasprunXMLValidator from custodian checked a job and found issues with the LDAU parameters in the vasprun.xml. I feel like the issue belongs here as the simplest fix is done through pymatgen. The issue is when custodian tries to initialize a Vasprun object in the VasprunXMLValidator().check() by simply calling Vasprun("vasprun.xml"), and can not correctly parse some of the values in the XML and tries to parse the INCAR instead. This is done through _parse_from_incar which when given simply "vasprun.xml", sets dirname to os.path.dirname(filename), which is an empty string since the file is in current working directory. os.listdir(dirname) in the following line then raises a FileNotFoundError and the check() method of the validator incorrectly returns True.

The simplest fix would be to change dirname = os.path.dirname(filename) to dirname = os.path.dirname(filename) or '.'.

The other fix would be to change the vrun = Vasprun('vasprun.xml') in the try block in VasprunXMLValidator().check() of custodian to use the full path instead.

If you think this is the correct place to apply the fix, I can do a PR, otherwise I go to the custodian repo :)

Expected Behavior

I think the reason this evaded attention was because this unexpected parsing of LDAU and/or MAGMOM from vasprun.xml is kind of rare, and the reason tests pass is because they always use the full path of vasprun.xml, in which case this doesn't happen. Only when vasprun.xml is used directly as in the case of VasprunXMLValidator, we get an exception. Even though _parse_v_parameters in pymatgen.io.vasp.outputs explicitly states that the filename should be the fullpath of vasprun.xml, I personally see no reason why Vasprun should fail when initialized in the same path as the vasprun.xml.

Minimal example

No response

Relevant files to reproduce this bug

I have a vasprun.xml that can reproduce this error but it's rather large (~90MB). I can upload it if anyone wants to take a look, though.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions