From 56e6e1ecab87fe7065ba87b9c7998510c8f989ce Mon Sep 17 00:00:00 2001 From: Maxwell Dylla Date: Tue, 26 Mar 2019 12:34:44 -0700 Subject: [PATCH 1/3] allow for user kpoints in NSCF calculation --- pymatgen/io/vasp/sets.py | 6 ++++++ 1 file changed, 6 insertions(+) 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 From c2049c2eae7fd94fe00b87ff436181c92cf34b78 Mon Sep 17 00:00:00 2001 From: Maxwell Dylla Date: Tue, 26 Mar 2019 13:40:29 -0700 Subject: [PATCH 2/3] tests for kpoint override in NSCF calculations --- pymatgen/io/vasp/tests/test_sets.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pymatgen/io/vasp/tests/test_sets.py b/pymatgen/io/vasp/tests/test_sets.py index e544b2d1817..52db0b1463f 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") From 118397bb51b50796a7f52e99e4e6508f5f81ec16 Mon Sep 17 00:00:00 2001 From: Maxwell Dylla Date: Tue, 26 Mar 2019 14:32:17 -0700 Subject: [PATCH 3/3] fixed kpoint construction in tests --- pymatgen/io/vasp/tests/test_sets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymatgen/io/vasp/tests/test_sets.py b/pymatgen/io/vasp/tests/test_sets.py index 52db0b1463f..e6f23b3b327 100644 --- a/pymatgen/io/vasp/tests/test_sets.py +++ b/pymatgen/io/vasp/tests/test_sets.py @@ -431,7 +431,7 @@ def test_optics(self): 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 + kpts=((1, 1, 1),)) # the default kpoints style is reciprocal prev_run = self.TEST_FILES_DIR / "relaxation" vis = MPNonSCFSet.from_prev_calc(