materialsproject / atomate2

atomate2 is a library of computational materials science workflows
https://materialsproject.github.io/atomate2/
Other
167 stars 94 forks source link

BUG: not able to read potcars correctly #709

Closed rushikd27 closed 8 months ago

rushikd27 commented 9 months ago

I was trying to parse a VASP calculation using the VaspDrone functionality of atomate2 and I encountered an error where the code is not able to read my POTCAR correctly. It is a binary CsCl structure and I have the correct POTCAR in the directory. Following is the code I used to parse it.

from atomate2.vasp.drones import VaspDrone
from monty.json import jsanitize
import json
from monty.json import MontyEncoder

# Parse results with atomate2
drone = VaspDrone()
doc = drone.assimilate()
doc = jsanitize(doc.model_dump(),recursive_msonable=True)

# Save results as json file
with open('doc.json','w',encoding='utf-8') as f_o:
    json.dump(doc,f_o,cls=MontyEncoder)

The POTCAR types as mentioned in the OUTCAR files are: POTCAR: PAW Cs_sv_GW 23Mar2010 POTCAR: PAW Cl_GW 19Mar2012

Following is the error it throws out:

Error in /depot/amannodi/data/Perovs_phases_functionals/Jan_2024_new_calcs/Reference_calculations/AX_halides/CsCl/PBE
Traceback (most recent call last):
  File "/home/desai224/.conda/envs/2022.10-py39/atomate2/lib/python3.11/site-packages/atomate2/vasp/drones.py", line 46, in assimilate
    doc = TaskDoc.from_directory(path, **self.task_document_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/desai224/.conda/envs/2022.10-py39/atomate2/lib/python3.11/site-packages/emmet/core/tasks.py", line 510, in from_directory
    input=InputDoc.from_vasp_calc_doc(calcs_reversed[-1]),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/desai224/.conda/envs/2022.10-py39/atomate2/lib/python3.11/site-packages/emmet/core/tasks.py", line 204, in from_vasp_calc_doc
    pot_type, func = calc_doc.input.potcar_type[0].split("_")
    ^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Traceback (most recent call last):
  File "/depot/amannodi/data/Perovs_phases_functionals/Jan_2024_new_calcs/Reference_calculations/AX_halides/CsCl/PBE/drone.py", line 9, in <module>
    doc = drone.assimilate()
          ^^^^^^^^^^^^^^^^^^
  File "/home/desai224/.conda/envs/2022.10-py39/atomate2/lib/python3.11/site-packages/atomate2/vasp/drones.py", line 46, in assimilate
    doc = TaskDoc.from_directory(path, **self.task_document_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/desai224/.conda/envs/2022.10-py39/atomate2/lib/python3.11/site-packages/emmet/core/tasks.py", line 510, in from_directory
    input=InputDoc.from_vasp_calc_doc(calcs_reversed[-1]),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/desai224/.conda/envs/2022.10-py39/atomate2/lib/python3.11/site-packages/emmet/core/tasks.py", line 204, in from_vasp_calc_doc
    pot_type, func = calc_doc.input.potcar_type[0].split("_")
    ^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Can you look into this?

utf commented 8 months ago

Thanks for raising this. It looks like an error with the task document in emmet. Can you share a the folder that is causing the issue?

rushikd27 commented 8 months ago

I am attaching the zip folder for one of the files where this happens. The folder also has the script I used to get the TaskDocument. The file is named drone.py. It has the code as follows:

from atomate2.vasp.drones import VaspDrone
from monty.json import jsanitize
import json
from monty.json import MontyEncoder

drone = VaspDrone()
doc = drone.assimilate()
doc = jsanitize(doc.model_dump(),recursive_msonable=True)

with open('doc.json','w',encoding='utf-8') as f_o:
    json.dump(doc,f_o,cls=MontyEncoder)

PBE.zip

utf commented 8 months ago

Hi @rushikd27, thanks for sending the files. It seems like your POTCAR files are corrupted in some way. The TITEL field is not correct for the K_sv_GW POTCAR:

> grep TITEL POTCAR
   TITEL  = PAW K_sv_GW 31Mar2010
   TITEL  = PAW_PBE I 08Apr2002

The expected output (and what I get using the standard PBE.54 POTCARs downloaded from the VASP website) is:

   TITEL  = PAW_PBE K_sv_GW 31Mar2010
   TITEL  = PAW_PBE I 08Apr2002

Notice the PAW has changed to PAW_PBE. If you update your vasprun.xml on line 495 to change "PBE" to "PAW_PBE" that will allow the task document to be parsed correctly.

Ultimately, we're only able to support parsing the standard VASP POTCARs. However, please feel free to raise the issue on the Emmet repository if you have further concerns.

rushikd27 commented 8 months ago

Thanks for the help, Ill check the POTCARs. i also got them from VASP website

utf commented 8 months ago

If you downloaded them from the website, could you confirm which version of the pseudo potentials you downloaded? It is possible that the format has changed in recent versions, and so the emmet code would need to be updated.