materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.46k stars 845 forks source link

[Feature Request]: Vasprun.xml needs to be updated to be compatible vasp > 6.3 #3455

Open Jeff-oakley opened 9 months ago

Jeff-oakley commented 9 months ago

Problem

The new vasp allows to provide KPOINTS_OPT so that a non-self-consistent run will be done automatically after self-consisten run on KPOINTS file. This is the new feature starting from vasp.6.3. As a result, the vasprun.xml will generate two "band structures" rather than just one, can anyone update this feature? More description can be found in vasp documentation:

https://www.vasp.at/wiki/index.php/KPOINTS_OPT https://www.vasp.at/wiki/index.php/Band-structure_calculation_using_hybrid_functionals

Proposed Solution

Just add the decision whether there is KPOINTS_OPT?

Alternatives

No response

shyuep commented 9 months ago

For us to work on this, I need an example vasprun.xml with 6.3 and the two band structures. Just a simple one for say Si will do.

Jeff-oakley commented 9 months ago

Thanks. Here is the zip file for a calculation with Si. Multiple output files have different formats, e.g. vasprun.xml (has both band structures from KPOINTS and KPOINTS_OPT), OUTCAR (additional outputs). si_two_bandstructures.zip

dhoulek commented 9 months ago

Let me follow up on this. The current Vasprun parser does not parse the stresses from the MD (ML_LMLFF) steps. The data is available in the vasprun.xml. This can be easily achieved by adding

elif tag == "varray" and elem.attrib.get("name") == "stress":
    md_data[-1]["stress"] = _parse_varray(elem)

between lines 404 and 405 in the present version of the Vasprun._parse() function.

At least in my present runs this seems to work, because the info about the stress is otherwise provided only for the DFT steps (via Vasprun.ionic_steps). Here is an example: vasprun.tar.gz

bfield1 commented 5 months ago

This should now be resolved since pull request #3509 has been merged.

Jeff-oakley commented 5 months ago

Yes. I have tried with the example and it works greatly!

Jeff-oakley commented 5 months ago

I realize the implementation still have the following issue:

When save the Vasprun object with dumpfn, it calls the as_dict() method with new parameter vasp_version. However, when load the mson file using loadfn, it shows that vasp_verison key can not be recognized.

vp = Vasprun('vasprun.xml')
dumpfn(vp,'vp.mson')
data = loadfn('vp.mson')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bouyang/miniconda3/envs/new_vprun/lib/python3.12/site-packages/monty/serialization.py", line 74, in loadfn
    return json.load(fp, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bouyang/miniconda3/envs/new_vprun/lib/python3.12/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/home/bouyang/miniconda3/envs/new_vprun/lib/python3.12/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/bouyang/miniconda3/envs/new_vprun/lib/python3.12/site-packages/monty/json.py", line 626, in decode
    return self.process_decoded(d)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bouyang/miniconda3/envs/new_vprun/lib/python3.12/site-packages/monty/json.py", line 553, in process_decoded
    return cls_.from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/bouyang/miniconda3/envs/new_vprun/lib/python3.12/site-packages/monty/json.py", line 235, in from_dict
    return cls(**decoded)
           ^^^^^^^^^^^^^^
TypeError: Vasprun.__init__() got an unexpected keyword argument 'vasp_version'

Similar to the vasp_version tag, "has_vasp_completed", "unit_cell_formula", "has_vasp_completed", "pretty_formula" and many other tags have the initialization issue