POTCAR questions

I posted the following on the Github pymatgen site, but it has been over two weeks without a single reply so I thought would post the question again here.

In short, I encounter errors when I attempt a new installation of the POTCAR files from Vasp and the POTCAR related errors make it much more difficult to use pymatgen in an effective way. Unless I am missing something, it might be a good idea to rewrite the instructions on the pymatgen webpage to make the correct process clearer.

On a new machine (a Macintosh in this case, although I encountered the same type of problems on CentOS 7), following the instructions from the pymatgen homepage (using omg config -p <pymatgen_potcar> results in a setup that does leads to errors in POTCAR file generation.

To Reproduce
I have encountered some problems with the use of pymatgen and the generation of POTCAR VASP files. I thought I would
review the installation procedure in an attempt to determine what is going wrong.

There are several different versions of PAW pseudopotentials on the VASP web site. In principle, it would seem that pymatgen
should work with any of them, but there are problems. At the very least, the documentation on PAW installation using
pmg needs to be updated to avoid the errors I have been encountering.

PAW PS on the VASP site

  1. PAW POTCAR files: LDA version 54 (recommend)
  2. PAW POTCAR files: PBE version 54 (recommend)
  3. PAW POTCAR files: LDA & PBE, 5.2 & 5.4 (original unvie release version)
  4. PAW POTCAR files: LDA version 52
  5. PAW POTCAR files: PBE version 52
    other files are labeled as outdated

The online text states that the distributions 1 and 2 yield identical results to distribution 3, but also
states that the TITEL has been changed and a hash key has been added of the newest distributions 1 and 2.

The above distributions correspond to the following tar images from the www.vasp.at website:

  1. 79M Mar 27 21:45 potpaw_PBE.54.tar
  2. 71M Mar 27 21:45 potpaw_LDA.54.tar
  3. 280M Mar 27 21:45 potpaw_LDA_PBE_52_54_orig.tar
  4. 62M Mar 27 22:14 potpaw_LDA.52.tar
  5. 70M Mar 27 22:14 potpaw_PBE.52.tar

By way of demonstration, I initially unpacked distribution (3) (PAW POTCAR files: LDA & PBE, 5.2 & 5.4 (original unvie release version))
into a new directory to yield. I was under the impression that this was the older version used by pymatgen (although the
installation instructions on the pymatgen website are fuzzy)

potpaw.52 potpaw.54 potpaw_PBE.52 potpaw_PBE.54

I then ran the pmg config command to generate the pymatgen flavored output

pmg config -p extracted pymatgen_pot

and set the environment variables to reflect the new directory

pmg config --add PMG_VASP_PSP_DIR ‘/Users/paulfons/Google Drive/Vasp/pymatgen_pot’

Loading a ipython and attempting to generate VASP input fails as can be seen below:

Python 3.7.6 (default, Feb 28 2020, 08:55:06)
Type ‘copyright’, ‘credits’ or ‘license’ for more information
IPython 7.13.0 – An enhanced Interactive Python. Type ‘?’ for help.

In [2]: import pymatgen as mg

In [3]: structure = mg.Structure.from_file(‘POSCAR’)

In [4]: structure.composition
Out[4]: Comp: Cr24 Ge24 Te72

In [5]: from pymatgen.io.vasp.sets import MPStaticSet

In [7]: static = MPStaticSet(structure)

In [8]: static.write_input(output_dir=‘crgete’)

OSError Traceback (most recent call last)
in
----> 1 static.write_input(output_dir=‘crgete’)

~/.pyenv/versions/3.7.6/envs/pymatgen/lib/python3.7/site-packages/pymatgen/io/vasp/sets.py in write_input(self, output_dir, make_dir_if_not_present, include_cif, potcar_spec, zip_output)
720 include_cif=include_cif,
721 potcar_spec=potcar_spec,
–> 722 zip_output=zip_output
723 )
724 for k, v in self.files_to_transfer.items():

~/.pyenv/versions/3.7.6/envs/pymatgen/lib/python3.7/site-packages/pymatgen/io/vasp/sets.py in write_input(self, output_dir, make_dir_if_not_present, include_cif, potcar_spec, zip_output)
210 f.write(v. str ())
211 else:
–> 212 vinput = self.get_vasp_input()
213 vinput.write_input(output_dir, make_dir_if_not_present=make_dir_if_not_present)
214

~/.pyenv/versions/3.7.6/envs/pymatgen/lib/python3.7/site-packages/pymatgen/io/vasp/sets.py in get_vasp_input(self)
172 kpoints=self.kpoints,
173 poscar=self.poscar,
–> 174 potcar=self.potcar,
175 )
176

~/.pyenv/versions/3.7.6/envs/pymatgen/lib/python3.7/site-packages/pymatgen/io/vasp/sets.py in potcar(self)
127 Potcar object.
128 “”"
–> 129 potcar = Potcar(self.potcar_symbols, functional=self.potcar_functional)
130
131 # warn if the selected POTCARs do not correspond to the chosen

~/.pyenv/versions/3.7.6/envs/pymatgen/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py in init (self, symbols, functional, sym_potcar_map)
2211 self.functional = functional
2212 if symbols is not None:
-> 2213 self.set_symbols(symbols, functional, sym_potcar_map)
2214
2215 def as_dict(self):

~/.pyenv/versions/3.7.6/envs/pymatgen/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py in set_symbols(self, symbols, functional, sym_potcar_map)
2318 else:
2319 for el in symbols:
-> 2320 p = PotcarSingle.from_symbol_and_functional(el, functional)
2321 self.append§
2322

~/.pyenv/versions/3.7.6/envs/pymatgen/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py in from_symbol_and_functional(symbol, functional)
1951 raise IOError(
1952 "You do not have the right POTCAR with functional "
-> 1953 + “{} and label {} in your VASP_PSP_DIR”.format(functional, symbol)
1954 )
1955

OSError: You do not have the right POTCAR with functional PBE and label Cr_pv in your VASP_PSP_DIR

Any suggestions as to what I can try out to fix this?

Expected behavior
It is expected that a functional POTCAR will be generated for a Vast POTCAR setup configured using the instructions provided on the pymatgen homepage.

  • OS: [e.g. Mac,Windows,Linux]
    MacOS 10.15.4

Hi @paulfons, I’m sorry to hear you’re having trouble getting pymatgen to recognize your POTCARs. I believe the problem is that you unzipped the ‘original unvie versions’ (Item 3 in your list). For the 5.2 POTCARs, these would carry the key ‘unvie_potpaw_52’ in pymatgen, but your calculation is looking for the key ‘PBE’ (the default specified in MPRelaxSet.yaml). This key corresponds to one of the files that Vasp lists as ‘outdated’.

You can find a complete dict that maps the pymatgen potcar functional keys to the descriptions on the Vasp website here. We tried to make this descriptive enough that it should be clear which set of POTCARs corresponds to which functional within pymatgen.

Thanks for bringing some of the documentation issues to our attention; we’ll try to update that to be more clear. Please test again after downloading the other set of POTCARs and let us know if you have other problems.

Since we do have all the POTCAR hashes, should we update the pmg code to assemble the POTCAR folders based on matching to these?

POTCAR distributions on the vasp.at web site correspond to the following tar images from the www.vasp.at website:

  1. 79M Mar 27 21:45 potpaw_PBE.54.tar
  2. 71M Mar 27 21:45 potpaw_LDA.54.tar
  3. 280M Mar 27 21:45 potpaw_LDA_PBE_52_54_orig.tar
  4. 62M Mar 27 22:14 potpaw_LDA.52.tar
  5. 70M Mar 27 22:14 potpaw_PBE.52.tar

I downloaded the 52 and 54 potential files (numbers 1,2,4, and 5) which the vasp web site listed as “recommended” and placed these in a folder called “ootentials”.

ls -lt potentials/
total 0
[email protected] 309 paulfons staff 9888 Apr 16 11:08 potpaw_PBE.52
[email protected] 280 paulfons staff 8960 Apr 16 11:07 potpaw_LDA.52
[email protected] 299 paulfons staff 9568 Apr 15 14:42 potpaw_LDA.54
[email protected] 331 paulfons staff 10592 Apr 15 14:42 potpaw_PBE.54

I then ran the command “pmg configure -p potentials pymatgen_pot” and pmg put the POTCARS into pymatgen gzipped format:

ls -l pymatgen_pot/
total 0
drwxr-xr-x 306 paulfons staff 9792 Apr 16 11:11 POT_GGA_PAW_PBE_52
drwxr-xr-x 329 paulfons staff 10528 Apr 16 11:11 POT_GGA_PAW_PBE_54
drwxr-xr-x 277 paulfons staff 8864 Apr 16 11:12 POT_LDA_PAW_52
drwxr-xr-x 297 paulfons staff 9504 Apr 16 11:12 POT_LDA_PAW_54

I then set the .pmgrc file to

PMG_DEFAULT_FUNCTIONAL: PBE_54
PMG_VASP_PSP_DIR: /Users/paulfons/Documents/Work/Software/Vasp/potentials

When I try to generate a POTCAR file using the MPStatic set class, I encounter the error:

static = MPStaticSet(structure,user_potcar_functional=“PBE_54”)
.
.
.
/usr/local/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py in from_symbol_and_functional(symbol, functional)
1951 raise IOError(
1952 "You do not have the right POTCAR with functional "
-> 1953 + “{} and label {} in your VASP_PSP_DIR”.format(functional, symbol)
1954 )
1955

OSError: You do not have the right POTCAR with functional PBE_54 and label Cr_pv in your VASP_PSP_DIR

I am confused by this error and how to fix it. I used the “recommended” POTCAR files from the vasp.at site and I can see
from PotcarSingle class that the key “PBE_54”: “POT_GGA_PAW_PBE_54” corresponds to the file POT_GGA_PAW_PBE_54 which
does exist in the PMG_VASP_PSP_DIR and in fact there is a “Cr_pv” pseudopotential present

ls -l POT_GGA_PAW_PBE_54/POTCAR.Cr*
-rw------- 1 paulfons staff 85318 Apr 16 11:11 POT_GGA_PAW_PBE_54/POTCAR.Cr.gz
-rw------- 1 paulfons staff 85386 Apr 16 11:11 POT_GGA_PAW_PBE_54/POTCAR.Cr_pv.gz
-rw------- 1 paulfons staff 91829 Apr 16 11:11 POT_GGA_PAW_PBE_54/POTCAR.Cr_sv.gz
-rw------- 1 paulfons staff 122803 Apr 16 11:11 POT_GGA_PAW_PBE_54/POTCAR.Cr_sv_GW.gz

Why is this failing? What have I done wrong with the setup. I note that in the vasp.io.inputs.potcar documentation, it states

functional (str) – Functional used. To know what functional options
there are, use Potcar.FUNCTIONAL_CHOICES. Note that VASP has different
versions of the same functional. By default, the old PBE functional is
used. If you want the newer ones, use PBE_52 or PBE_54. Note that if you
intend to compare your results with the Materials Project, you should
use the default setting. You can also override the default by setting
PMG_DEFAULT_FUNCTIONAL in your .pmgrc.yaml.

It would appear that Potcar attempts to use the “old PBE functional” (what is “old” means in this context – is not defined on
the VASP site or anywhere in the pymatgen site as far as I know). Above I tried to specified the “PBE_54” tag which should have
referenced the POT_GGA_PAW_PBE_54 POTCARs if I am not wrong. The files exist. The Cr_pv PAW exists. Why am I getting
this error message?

Sorry for the frequent postings. I believe that my PMG_VASP_PSP_DIR was not set correctly
and that lead to the failure I documented earlier.
.
Now when I try

Python 3.7.7 (default, Mar 10 2020, 15:43:33)
Type ‘copyright’, ‘credits’ or ‘license’ for more information
IPython 7.13.0 – An enhanced Interactive Python. Type ‘?’ for help.

In [1]: from pymatgen.io.vasp.inputs import Potcar,PotcarSingle

In [2]: potcar = PotcarSingle.from_symbol_and_functional(symbol=“Cr_pv”,functional=“PBE_54”)
/usr/local/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py:1767: UserWarning: Ignoring unknown variable type SHA256
warnings.warn("Ignoring unknown variable type s" key)
/usr/local/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py:1767: UserWarning: Ignoring unknown variable type COPYR
warnings.warn("Ignoring unknown variable type s" key)

If I now set up a static calculation using the MPStaticSet class, it works, but I receive
a hard to interpret warning about an “unknown variable type SHA256”. I am not sure what this
means. I am also curious to know which of the POTCAR distributions is the “old” POTCAR distribution used in the Materials Project. Thanks for your help and sorry for my earlier report.

Python 3.7.7 (default, Mar 10 2020, 15:43:33)
Type ‘copyright’, ‘credits’ or ‘license’ for more information
IPython 7.13.0 – An enhanced Interactive Python. Type ‘?’ for help.

In [1]: from pymatgen.io.vasp.inputs import Potcar,PotcarSingle

In [2]: potcar = PotcarSingle.from_symbol_and_functional(symbol=“Cr_pv”,functional=“PBE_54”)
/usr/local/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py:1767: UserWarning: Ignoring unknown variable type SHA256
warnings.warn("Ignoring unknown variable type s" key)
/usr/local/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py:1767: UserWarning: Ignoring unknown variable type COPYR
warnings.warn("Ignoring unknown variable type s" key)

In [3]: import pymatgen as mg

In [4]: structure = mg.Structure.from_file(‘POSCAR.vasp’)

In [5]: from pymatgen.io.vasp.sets import MPStaticSet

In [6]: static = MPStaticSet(structure,user_potcar_functional=“PBE_54”)
/usr/local/lib/python3.7/site-packages/pymatgen/io/vasp/sets.py:437: BadInputSetWarning: Overriding the POTCAR functional is generally not recommended as it significantly affect the results of calculations and compatibility with other calculations done with the same input set. Note that some POTCAR symbols specified in the configuration file may not be available in the selected functional.
BadInputSetWarning,

In [7]: static.write_input(output_dir=‘test’)
/usr/local/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py:1767: UserWarning: Ignoring unknown variable type SHA256
warnings.warn("Ignoring unknown variable type s" key)
/usr/local/lib/python3.7/site-packages/pymatgen/io/vasp/inputs.py:1767: UserWarning: Ignoring unknown variable type COPYR
warnings.warn("Ignoring unknown variable type s" key)

Hi @paulfons thanks for bringing this bug to our attention. It seems to originate from the code that PotcarSingle uses to parse raw potcar data, shown below. I have a suspicion that this is a consequence of VASP adding hash strings to their POTCAR metadata. Our PotcarSingle code isn’t expecting to find ‘SHA256’ in the metadata, so it raises a KeyError.

Would you mind opening an issue on github about this? I think it will be straightforward to fix.

def __init__(self, data, symbol=None):
        """
        Args:
            data:
                Complete and single potcar file as a string.
            symbol:
                POTCAR symbol corresponding to the filename suffix
                e.g. "Tm_3" for POTCAR.TM_3". If not given, pymatgen
                will attempt to extract the symbol from the file itself.
                However, this is not always reliable!
        """
        self.data = data  # raw POTCAR as a string

        # Vasp parses header in vasprun.xml and this differs from the titel
        self.header = data.split("\n")[0].strip()

        search_lines = re.search(
            r"(?s)(parameters from PSCTR are:" r".*?END of PSCTR-controll parameters)",
            data,
        ).group(1)

        self.keywords = {}
        for key, val in re.findall(
            r"(\S+)\s*=\s*(.*?)(?=;|$)", search_lines, flags=re.MULTILINE
        ):
            try:
                self.keywords[key] = self.parse_functions[key](val)
            except KeyError:
                warnings.warn("Ignoring unknown variable type %s" % key)

        PSCTR = OrderedDict()