Skip to content

Mulit element POTCAR loading broken.Β #2895

@MichaelWolloch

Description

@MichaelWolloch

Describe the bug
Since commit e4bde8e it seems that loading is broken if any but the first POTCAR in the file has a sha256 hash.

I really appreciate the effort by @shyuep to clean up the code and get rid of the regex stuff and unicode handling. However, a small mistake appears to have slipped in in line 2277 of pymatgen/io/vasp/inputs.py. There should be a unicode end of line character still:

potcar_strings = fdata.split("End of Dataset\n")

instead of

potcar_strings = fdata.split("End of Dataset")

If that is included, also the test that got modified in the commit can be changed back it seems.

However, since this all seems a bit fragile, I suggest to actually also downgrade the ValueError that is raised in line 1829 in pymatgen/io/vasp/inputs.py to a warning.

To Reproduce
load the attached POTCAR (containing O and Fe_pv_with_hash from pymatgen/test_files/POT_GGA_PAW_PBE_54 with the Fe Potcar following the O) into a Potcar object:
POTCAR_test.gz

from pymatgen.io.vasp.inputs import Potcar
pot = Potcar.from_file('POTCAR_test.gz')

results in:

ValueError: POTCAR with symbol Fe_pv and functional
PBE has a SHA256 hash defined,
but the computed hash differs.
YOUR POTCAR FILE HAS BEEN CORRUPTED AND SHOULD NOT BE USED!

Expected behavior
There should be no error for the SHA256, since the POTCAR is good.

Environment (please supply relevant versions and platform info):

  • OS: Linux
  • Version 2023.3.10

Additional context
I am happy to make a pull request if this is wanted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions