diff --git a/pymatgen/io/vasp/sets.py b/pymatgen/io/vasp/sets.py index 3a0a0997b59..f4fb1a0b944 100644 --- a/pymatgen/io/vasp/sets.py +++ b/pymatgen/io/vasp/sets.py @@ -931,6 +931,12 @@ def kpoints(self): style=Kpoints.supported_modes.Reciprocal, num_kpts=len(ir_kpts), kpts=kpts, kpts_weights=weights) + + # override pymatgen kpoints if provided + user_kpoints = self.kwargs.get("user_kpoints_settings", None) + if isinstance(user_kpoints, Kpoints): + kpoints = user_kpoints + return kpoints @classmethod diff --git a/pymatgen/io/vasp/tests/test_sets.py b/pymatgen/io/vasp/tests/test_sets.py index e544b2d1817..e6f23b3b327 100644 --- a/pymatgen/io/vasp/tests/test_sets.py +++ b/pymatgen/io/vasp/tests/test_sets.py @@ -428,6 +428,18 @@ def test_optics(self): self.assertTrue(vis.incar["LOPTICS"]) self.assertEqual(vis.kpoints.style, Kpoints.supported_modes.Reciprocal) + def test_user_kpoint_override(self): + user_kpoints_override = Kpoints( + style=Kpoints.supported_modes.Gamma, + kpts=((1, 1, 1),)) # the default kpoints style is reciprocal + + prev_run = self.TEST_FILES_DIR / "relaxation" + vis = MPNonSCFSet.from_prev_calc( + prev_calc_dir=prev_run, copy_chgcar=False, optics=True, + mode="Uniform", nedos=2001, + user_kpoints_settings=user_kpoints_override) + self.assertEqual(vis.kpoints.style, Kpoints.supported_modes.Gamma) + def tearDown(self): shutil.rmtree(self.tmp) warnings.simplefilter("default")