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.52k stars 868 forks source link

generate explicit k-points generation for VASP #586

Closed chivalry123 closed 7 years ago

chivalry123 commented 7 years ago

I need to generate explicit k-points (considered symmetry of structure) for the vasp calculations (I also need it for correct Bootstrap fermi-surface calculation). I know that I could generate k-points among high symmetry lines in this way. However, I would need explicit k-points mesh for self consistent calculation (not lines though).


import pymatgen as mg
from pymatgen.symmetry.bandstructure import HighSymmKpath
# from pymatgen.io.vaspio.vasp_input import Kpoints
from pymatgen.io.vasp.inputs import Kpoints
from pymatgen import Structure

struct = Structure.from_file("POSCAR")

# First brillouin zone
ibz = HighSymmKpath(struct)
print("ibz type     : {0}".format(ibz.name))

# suggested path
print("paths in first brillouin zone :")
for path in ibz.kpath["path"]:
    print(path)

kpoints = list()
labels = list()
for path in ibz.kpath["path"]:
    for kpts in path:
        kpoints.append(ibz.kpath["kpoints"][kpts])
        labels.append(kpts)

# print kpoints file
Kpoints(comment = "band diagram for monoclinic cell, unique axes a",
        num_kpts = 100,
        style = Kpoints.supported_modes.Line_mode,
        coord_type = "Reciprocal",
        kpts = kpoints,
        labels = labels,
        ).write_file("KPOINTS")

However, I have difficulties locating the parts of the code that outputs automatic explicit k-points (for self consistent calculation, not line mode). Would you like to hint me about it? Thank you very much.

fraricci commented 7 years ago

This is what the method MPNonSCF does:

        kpoints = Kpoints.automatic_density_by_vol(self.structure,
                                                   self.reciprocal_density)
        mesh = kpoints.kpts[0]
        ir_kpts = SpacegroupAnalyzer(
            self.structure,
            symprec=self.sym_prec).get_ir_reciprocal_mesh(mesh)
        kpts = []
        weights = []
        for k in ir_kpts:
            kpts.append(k[0])
            weights.append(int(k[1]))
        kpoints = Kpoints(comment="Non SCF run on uniform grid",
                          style=Kpoints.supported_modes.Reciprocal,
                          num_kpts=len(ir_kpts),
                          kpts=kpts, kpts_weights=weights)
chivalry123 commented 7 years ago

Thank you very much. Explicit kpoints are generated successfully. This thread is actually targeting #584 for plotting fermi surface. I have posted the latest problem in plotting fermi surface there. Would you like to take a look there? Thank you very much.