How is explicit KPOINT generated from pymatgen and how to get high symmetry points from KPOINT file?



I am starting to use pymatgen and Material Project. I can only get automatic KPOINT from MPRelaxSet of pymatgen. I wonder what method from pymatgen do you use to generate the explicit KPOINT file used for bandstructure calculation? Furthermore, the kpath of some bandstructure plots on Material Project do not agree with the kpath generated from HighSymmKpath of pymatgen. What method does MP use to get the high-symmetry points for bandstructure plotting?

Thank you for your help!


You can see the code used currently in the MP Production on the MPWorks repository. I believe the code in question is here, where you can see we use the MPNonSCFSet to generate the VASP inputs with a line density of 20. Note also that the line density parameter is increased to 30 if the band gap in a previous firework is found to be lower than 0.5 eV (shown here). This should be replicated using:

from import MPNonSCFSet
from pymatgen import MPRester
mpr = MPRester()
structure = mpr.get_structure_by_material_id(MATERIAL_ID_HERE)
kld = 20 # or 30 if the material has a gap lower than 0.5 eV
kpoints = MPNonSCFSet(structure, kpoints_line_density=kld).kpoints

The kpath should be generated by HighSymmKpath. Can you point us to an example where the kpaths don’t agree?

Note that we’re actually our workflow/calculation infrastructure to atomate over this summer. In general, our VASP parameters shouldn’t change, but the explicit code we’re using will.


Thank you for your reply! The example I am looking at is mp-758433 (material id). I used Highsymmpath.kpath to get the path, then print out label for the path:

labels = [r"$%s$" % lab for lab in path]

The labels returned ["$[’\\Gamma’, ‘X’, ‘M’, ‘\\Gamma’, ‘Z’, ‘R’, ‘A’, ‘Z’]$",
"$[‘X’, ‘R’]$",
"$[‘M’, ‘A’]$"]

This is different from the wave vector label on MP for the material shown here


I should add that I used structure.from_file (POSCAR) to get the structure and then used HighSymmKpath (structure) to get the kpath


It appears that the bandstructure calculation and the optimization calculation are using slightly different input structures (the bandstructure one is cubic). This is likely related to our build procedures, which sometimes attach derivative calculations (e. g. bandstructure) using structural similarity, and might attach these. I’ll check to see if we can fix this.


So the structure returned from get_structure_by_material_id is the one used for bandstructure calculation and the structure generated from POSCAR is the one for optimization?


Sorry I wasn’t clear. The structure returned from get_structure_by_material_id and the one listed on material page of the web site is the result of an optimization, i. e. the Optimize Structure task. The structure corresponding to the POSCAR for the bandstructure calculation is slightly different, which causes the discrepancy between the bandstructure kpath and the one generated using HighSymmKpath on the optimized structure. This is a mistake on our part that I believe is related to the database building procedure.


Thanks for the clarification. I noticed that you mentioned using MPNonSCFSet to set up VASP input files for bandstructure calculation. Is MPRelaxSet the right method to set VASP inputs if I want to start with relaxation, then static calculation and finally bandstructure calculation?