Customize KPOINTs without using user_kpoints_settings (dict)

Hi,
If I want to modify a workflow for example the Bandstructure wf and modify INCAR I know we can use this code:

import numpy as np
from pymatgen import Structure
from fireworks import LaunchPad
from atomate.vasp.workflows.presets.core import wf_bandstructure
from atomate.vasp.powerups import add_modify_incar

struct = Structure.from_file(‘POSCAR’)

original_wf = wf_bandstructure(struct)
modified_wf = add_modify_incar(original_wf, modify_incar_params={‘incar_update’:{‘ISPIN’: 1 }}, fw_name_constraint=‘band’)

lpad = LaunchPad.auto_load() # loads this based on the FireWorks configuration
lpad.add_wf(modified_wf)

Now if I want in this wf modify kpoints to exact kpoints like:

Automatic mesh
0
Gamma
5 5 4
0.000 0.000 0.000

and didn’t use user_kpoints_settings (dict): example: {“grid_density”: 7000} how can I add these modified kpoints to that workflow and use custom incar and kpoints in a same time?

Thanks in advance

Hi,

I think you should be able to specify a specific mesh in an add_modify_kpoints powerup , e.g.:

from pymatgen import Structure
from pymatgen.io.vasp.inputs import Kpoints
from fireworks import LaunchPad
from atomate.vasp.workflows.presets.core import wf_bandstructure
from atomate.vasp.powerups import add_modify_incar, add_modify_kpoints

struct = Structure.from_file('POSCAR')

original_wf = wf_bandstructure(struct)
modified_wf = add_modify_incar(original_wf,
                               modify_incar_params={'incar_update':
                                                        {'ISPIN': 1 }},
                               fw_name_constraint='band')

k_dict = {'nkpoints': 0,
          'generation_style': 'Gamma',
          'kpoints': [[5, 5, 4]],
          'usershift': [0, 0, 0],
          'comment': 'Automatic mesh'}
kpoints = Kpoints.from_dict(k_dict)

wf_final = add_modify_kpoints(modified_wf,
                              modify_kpoints_params={'kpoints_update':
                                                            kpoints})

lpad = LaunchPad.auto_load() 
lpad.add_wf(final_wf)

I would personally configure a vasp input set, because it offers a little bit more control I think. But this is just personal preference:

from pymatgen import Structure
from pymatgen.io.vasp.inputs import Kpoints
from pymatgen.io.vasp.sets import MPRelaxSet
from fireworks import LaunchPad
from atomate.vasp.workflows.base.core import get_wf

struct = Structure.from_file('POSCAR')
uis = {"ISPIN": 1}
k_dict = {'nkpoints': 0,
          'generation_style': 'Gamma',
          'kpoints': [[5, 5, 4]],
          'usershift': [0, 0, 0],
          'comment': 'Automatic mesh'}
kpoints = Kpoints.from_dict(k_dict)

vis = MPRelaxSet(structure=struct,
                 user_incar_settings = uis,
                 user_kpoints_settings = kpoints)

wf = get_wf(structure = struct, 
            wf_filename = "bandstructure.yaml",
            vis=vis)

Dear Michael

Thank you for your response. I prefer the first way. Just If you let me I want to add something to that.
because in modify_kpoints_params, we need a dictionary it’s not necessary to use this line

kpoints = Kpoints.from_dict(k_dict)

and it’s enough to call k_dic in wf_final.

Best regards,
Nima

Hi Nima,

you are completely right. It is enought to pass the dictionary. However, I think it is also important to know that you can directly pass an pymatgen Kpoints object as well.
Glad that I could help,
Michael