Run type method error

I’m getting the error below when executing the run_type method from the Vasprun class.

Traceback (most recent call last):
File “/home/darnoc/Documents/VASP Projects/CeO2_HSE06_bulk/CeO2_HSE06_bulk.py”, line 17, in
** print(v.run_type)**
** File “/home/darnoc/anaconda3/lib/python3.7/site-packages/pymatgen/io/vasp/outputs.py”, line 668, in run_type**
** rt = “vdW-” + vdw_gga[gga]**
KeyError: True

I modified the run_type @property method definition as below to account for various hybrid functionals.

    GGA_TYPES = {"PE", "PS", "RE", "RA", "B3"}

    METAGGA_TYPES = {"TPSS", "RTPSS", "M06L", "MBJL", "SCAN", "MS0", "MS1", "MS2"}

    if self.parameters.get("LHFCALC", True) and self.parameters.get("AEXX", 1.00):
        rt = "HF"
    elif self.parameters.get("LHFCALC", True) and self.parameters.get("HFSCREEN", 0.30):
        rt = "HSE03"
    elif self.parameters.get("LHFCALC", True) and self.parameters.get("HFSCREEN", 0.20):
        rt = "HSE06"
    elif self.parameters.get("LHFCALC", True) and self.parameters.get("AEXX", 0.20):
        rt = "B3LYP"
    elif self.parameters.get("METAGGA", "").strip().upper() in METAGGA_TYPES:
        rt = incar["METAGGA"].strip().upper()
    elif self.parameters.get("LUSE_VDW", True):
        vdw_gga = {"RE": "DF", "OR": "optPBE", "BO": "optB88",
                   "MK": "optB86b", "ML": "DF2", "SCAN": "rVV10"}
        gga = self.parameters.get("GGA", "").strip().upper() in GGA_TYPES
        rt = "vdW-" + vdw_gga[gga]
    elif self.potcar_symbols[0].split()[0] == 'PAW':
        rt = "LDA"
    else:
        rt = "GGA"
        if self.is_hubbard:
            rt += "+U"
    return rt

The INCAR file from my vasprun meets the HSE06 if statement criteria but I’m still getting the KeyError stated above.
Why would the method search for True within the vdw_gga[gga] dictionary?
I look forward to your feedback,
Thank you.

It would be helpful if you can post the files for us to debug this.

I think the issue is here, you’re assigning gga the boolean corresponding to whether self.parameters.get(“GGA”) is in the iterable GGA_TYPES.

This might work if you do the following:

I have resolved the issue.

Below are the changes I made which yield the correct results, I committed the changes via my forked version on github, but they were not reflected.
I assume only designated developers/users with requisite level of access can make such changes.
It’s a bit inconvenient since the script reverts to its unmodified version when I update pymatgen.
Is there a proper way to circumvent this and have changes (made locally by user) at least sustained on one’s local version of pymatgen when a new version is installed?

GGA_TYPES = {“PE”: “PBE”, “PS”: “PBESol”, “RP”: “RevPBE”}

    METAGGA_TYPES = {"TPSS", "RTPSS", "M06L", "MBJL", "SCAN", "MS0", "MS1", "MS2"}

    if self.parameters.get("AEXX", 1.00) == 1.00:
        rt = "HF"
    elif self.parameters.get("HFSCREEN", 0.30) == 0.30:
        rt = "HSE03"
    elif self.parameters.get("HFSCREEN", 0.20) == 0.20:
        rt = "HSE06"
    elif self.parameters.get("AEXX", 0.20) == 0.20:
        rt = "B3LYP"
    elif self.parameters.get("GGA", "").strip().upper() in GGA_TYPES:
        gga = self.parameters.get("GGA", "").strip().upper()
        rt = GGA_TYPES[gga]
    elif self.parameters.get("METAGGA", "").strip().upper() in METAGGA_TYPES:
        rt = incar["METAGGA"].strip().upper()
    elif self.parameters.get("LUSE_VDW", True):
        vdw_gga = {"RE": "DF", "OR": "optPBE", "BO": "optB88",
                   "MK": "optB86b", "ML": "DF2", "SCAN": "rVV10"}
        gga = self.parameters.get("GGA", "").strip().upper() in GGA_TYPES
        rt = "vdW-" + vdw_gga[gga]
    elif self.potcar_symbols[0].split()[0] == 'PAW':
        rt = "LDA"
    else:
        rt = "GGA"
        if self.is_hubbard:
            rt += "+U"
    return rt

Since you have already committed the changes to your forked branch, you can just submit a pull request (click on the submit pull request button and follow the instructions). We will review it and integrate if it works. Pls make sure you implement unittests to account for the changes.

pymatgen is completely open - we welcome contributions from everyone. Of course, changes will be reviewed by the maintainers before merging into the main branch of pymatgen for release.

1 Like

Can you provide specific details regarding the unittests protocol?