Modify Kpoints in all FW of workflow

Hi !

I would like to modify the kpoints used in dielectric_constant workflow but for now, I can only modify the KPOINTS used in first optimization FW of the workflow with this script :

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

kpoints_list = [1, 3, 5]

for kpoint in kpoints_list:

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

    vis = MPRelaxSet(structure=structure1,
                     user_kpoints_settings = kpoints,
                    force_gamma=True)

    wf = get_wf(structure = structure1, 
                wf_filename = "dielectric_constant.yaml",
                vis=vis,
               common_params={"db_file": db_file},)
    
    wf_final = add_additional_fields_to_taskdocs(wf, {"project":"Convergence_kpoint"})
    wf_final = add_additional_fields_to_taskdocs(wf_final, {"KPOINTS":kpoint})
    wf_final = add_additional_fields_to_taskdocs(wf_final, {"struc":'structure1'})
    lpad.add_wf(wf_final)

Is there a way to modify all fireworks in the workflow or I need to perform 2 successive workflows to do it ? (optimization workflow + dielectric_no_opt workflow)

Thank your very much for your help !

Hi Florian.

Yeah, it is not very straightforward to modify the kpoints (as it is for incar params).
A way I used is to use the powerup add_modify_kpoints after the wf is created,
where you speficy the kpoints you want and the FW to apply this chage to.
Here is a code I used in the past to get a kpoints file containing a list of the explicit kpoints:

    kpath = HighSymmKpath(st_prim)
    frac_k_points, k_points_labels = kpath.get_kpoints(
        line_density=20, coords_are_cartesian=False
    )
    kpoints = Kpoints(
        comment="Non SCF run along symmetry lines",
        style=Kpoints.supported_modes.Reciprocal,
        num_kpts=len(frac_k_points),
        kpts=frac_k_points,
        labels=k_points_labels,
        kpts_weights=[1] * len(frac_k_points),
    )

    kpoints_dict = kpoints.as_dict()
    kpoints_dict['num_kpts'] = kpoints_dict.pop('nkpoints')
    kpoints_dict['kpts'] = kpoints_dict.pop('kpoints')
    kpoints_dict['kpts_shift'] = kpoints_dict.pop('usershift')
    kpoints_dict.pop('@class')
    kpoints_dict.pop('@module')
    
    wf = add_modify_kpoints(wf,
                            modify_kpoints_params={'kpoints_update': kpoints_dict},
                            fw_name_constraint='line')

Maybe you do not need all of this. The main points are generating a kpoints_dict
with the right keys and specify the name (of part of it) of the fw where you want
to apply this change.

Hope this helps.
FR