From d9055e8d7a656a30ed5f0e3fdd00973494f2cc58 Mon Sep 17 00:00:00 2001 From: Andrew-S-Rosen Date: Fri, 16 Feb 2024 19:22:54 -0800 Subject: [PATCH] Update VASP sets --- src/quacc/calculators/vasp/vasp.py | 3 +- src/quacc/recipes/vasp/mp.py | 30 ++-- .../vasp_recipes/mocked/test_vasp_recipes.py | 133 ++++++++++++++---- 3 files changed, 126 insertions(+), 40 deletions(-) diff --git a/src/quacc/calculators/vasp/vasp.py b/src/quacc/calculators/vasp/vasp.py index 3004846f2d..6861fe67e8 100644 --- a/src/quacc/calculators/vasp/vasp.py +++ b/src/quacc/calculators/vasp/vasp.py @@ -23,6 +23,7 @@ set_pmg_kpts, ) from quacc.schemas.prep import set_magmoms +from quacc.utils.dicts import sort_dict if TYPE_CHECKING: from typing import Literal @@ -286,4 +287,4 @@ def _cleanup_params(self) -> None: ) # Remove unused INCAR flags - self.user_calc_params = remove_unused_flags(self.user_calc_params) + self.user_calc_params = sort_dict(remove_unused_flags(self.user_calc_params)) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index f7e0a06b6a..2e873aba73 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -70,8 +70,8 @@ def mp_metagga_prerelax_job( "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap, auto_ismear=False), "ediffg": -0.05, "gga": "PS", - "laechg": False, - "lvtot": False, + "laechg": False, # Deviation from MP (but logical) + "lvtot": False, # Deviation from MP (but logical) "lwave": True, "metagga": None, } @@ -119,8 +119,8 @@ def mp_metagga_relax_job( calc_defaults = { "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap, auto_ismear=False), - "laechg": False, - "lvtot": False, + "laechg": False, # Deviation from MP (but logical) + "lvtot": False, # Deviation from MP (but logical) "lwave": True, } return base_fn( @@ -168,7 +168,7 @@ def mp_metagga_static_job( "algo": "fast", "ismear": -5, "lreal": False, - "lwave": True, + "lwave": True, # Deviation from MP (but logical) "nsw": 0, } return base_fn( @@ -219,15 +219,17 @@ def mp_metagga_relax_flow( MPMetaGGARelaxFlowSchema Dictionary of results. See the type-hint for the data structure. """ - ( - mp_metagga_prerelax_job_, - mp_metagga_relax_job_, - mp_metagga_static_job_, - ) = customize_funcs( - ["mp_metagga_prerelax_job", "mp_metagga_relax_job", "mp_metagga_static_job"], - [mp_metagga_prerelax_job, mp_metagga_relax_job, mp_metagga_static_job], - parameters=job_params, - decorators=job_decorators, + (mp_metagga_prerelax_job_, mp_metagga_relax_job_, mp_metagga_static_job_) = ( + customize_funcs( + [ + "mp_metagga_prerelax_job", + "mp_metagga_relax_job", + "mp_metagga_static_job", + ], + [mp_metagga_prerelax_job, mp_metagga_relax_job, mp_metagga_static_job], + parameters=job_params, + decorators=job_decorators, + ) ) # Run the prerelax diff --git a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py index bf1a7fd14c..65e433fadc 100644 --- a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py +++ b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py @@ -7,6 +7,7 @@ mp_metagga_prerelax_job, mp_metagga_relax_flow, mp_metagga_relax_job, + mp_metagga_static_job, ) from quacc.recipes.vasp.qmof import qmof_relax_job from quacc.recipes.vasp.slabs import bulk_to_slabs_flow @@ -361,14 +362,36 @@ def test_mp_metagga_prerelax_job(tmp_path, monkeypatch): atoms = bulk("Al") output = mp_metagga_prerelax_job(atoms) assert output["nsites"] == len(atoms) - assert output["parameters"]["gga"] == "PS" - assert output["parameters"]["ediffg"] == -0.05 - assert output["parameters"]["encut"] == 680 - assert output["parameters"]["kspacing"] == 0.22 - assert output["parameters"]["ismear"] == 0 - assert output["parameters"]["sigma"] == 0.05 - assert output["parameters"]["pp"] == "PBE" - assert "metagga" not in output["parameters"] + assert output["parameters"] == { + "algo": "All", + "ediff": 1e-5, + "ediffg": -0.05, + "efermi": "midgap", # added by copilot + "enaug": 1360, + "encut": 680, + "gga": "PS", + "ibrion": 2, + "isif": 3, + "ismear": 0, + "ispin": 2, + "kspacing": 0.22, + "laechg": False, # disabled by us + "lasph": True, + "lcharg": True, + "lelf": False, + "lmixtau": True, + "lorbit": 11, + "lreal": "Auto", + "lvtot": False, # disabled by us + "lwave": True, + "magmom": [0.6], + "nelm": 200, + "nsw": 99, + "prec": "Accurate", + "setups": {"Al": ""}, + "sigma": 0.05, + "pp": "PBE", + } output = mp_metagga_prerelax_job(atoms, bandgap=0) assert output["nsites"] == len(atoms) @@ -376,8 +399,8 @@ def test_mp_metagga_prerelax_job(tmp_path, monkeypatch): assert output["parameters"]["ediffg"] == -0.05 assert output["parameters"]["encut"] == 680 assert output["parameters"]["kspacing"] == 0.22 - assert output["parameters"]["ismear"] == 2 - assert output["parameters"]["sigma"] == 0.2 + assert output["parameters"]["ismear"] == 0 + assert output["parameters"]["sigma"] == 0.05 assert output["parameters"]["pp"] == "PBE" assert "metagga" not in output["parameters"] @@ -387,7 +410,7 @@ def test_mp_metagga_prerelax_job(tmp_path, monkeypatch): assert output["parameters"]["ediffg"] == -0.05 assert output["parameters"]["encut"] == 680 assert output["parameters"]["kspacing"] == 0.44 - assert output["parameters"]["ismear"] == -5 + assert output["parameters"]["ismear"] == 0 assert output["parameters"]["sigma"] == 0.05 assert output["parameters"]["pp"] == "PBE" assert "metagga" not in output["parameters"] @@ -400,13 +423,36 @@ def test_mp_metagga_relax_job(tmp_path, monkeypatch): output = mp_metagga_relax_job(atoms) assert output["nsites"] == len(atoms) - assert output["parameters"]["metagga"].lower() == "r2scan" - assert output["parameters"]["ediffg"] == -0.02 - assert output["parameters"]["encut"] == 680 - assert output["parameters"]["kspacing"] == 0.22 - assert output["parameters"]["ismear"] == 0 - assert output["parameters"]["sigma"] == 0.05 - assert output["parameters"]["pp"] == "PBE" + assert output["parameters"] == { + "algo": "All", + "ediff": 1e-5, + "ediffg": -0.02, + "efermi": "midgap", # added by copilot + "enaug": 1360, + "encut": 680, + "ibrion": 2, + "isif": 3, + "ismear": 0, + "ispin": 2, + "kspacing": 0.22, + "laechg": False, # disabled by us + "lasph": True, + "lcharg": True, + "lelf": False, + "lmixtau": True, + "lorbit": 11, + "lreal": "Auto", + "lvtot": False, # disabled by us + "lwave": True, + "magmom": [0.6], + "metagga": "R2scan", + "nelm": 200, + "nsw": 99, + "prec": "Accurate", + "sigma": 0.05, + "pp": "PBE", + "setups": {"Al": ""}, + } output = mp_metagga_relax_job(atoms, bandgap=0) assert output["nsites"] == len(atoms) @@ -414,8 +460,8 @@ def test_mp_metagga_relax_job(tmp_path, monkeypatch): assert output["parameters"]["ediffg"] == -0.02 assert output["parameters"]["encut"] == 680 assert output["parameters"]["kspacing"] == 0.22 - assert output["parameters"]["ismear"] == 2 - assert output["parameters"]["sigma"] == 0.2 + assert output["parameters"]["ismear"] == 0 + assert output["parameters"]["sigma"] == 0.05 assert output["parameters"]["pp"] == "PBE" output = mp_metagga_relax_job(atoms, bandgap=100) @@ -424,11 +470,47 @@ def test_mp_metagga_relax_job(tmp_path, monkeypatch): assert output["parameters"]["ediffg"] == -0.02 assert output["parameters"]["encut"] == 680 assert output["parameters"]["kspacing"] == 0.44 - assert output["parameters"]["ismear"] == -5 + assert output["parameters"]["ismear"] == 0 assert output["parameters"]["sigma"] == 0.05 assert output["parameters"]["pp"] == "PBE" +def test_mp_metagga_static_job(tmp_path, monkeypatch): + monkeypatch.chdir(tmp_path) + + atoms = bulk("Al") + + output = mp_metagga_static_job(atoms) + assert output["nsites"] == len(atoms) + assert output["parameters"] == { + "algo": "fast", + "ediff": 1e-05, + "efermi": "midgap", # added by copilot + "enaug": 1360, + "encut": 680, + "ismear": -5, + "ispin": 2, + "kspacing": 0.22, + "laechg": True, + "lasph": True, + "lcharg": True, + "lelf": False, + "lmixtau": True, + "lorbit": 11, + "lreal": False, + "lvtot": True, + "lwave": True, # enabled by us + "magmom": [0.6], + "metagga": "R2scan", + "nelm": 200, + "nsw": 0, + "prec": "Accurate", + "sigma": 0.05, + "pp": "PBE", + "setups": {"Al": ""}, + } + + def test_mp_metagga_relax_flow(tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) @@ -439,8 +521,8 @@ def test_mp_metagga_relax_flow(tmp_path, monkeypatch): assert output["relax"]["parameters"]["metagga"].lower() == "r2scan" assert output["relax"]["parameters"]["ediffg"] == -0.02 assert output["relax"]["parameters"]["encut"] == 680 - assert output["relax"]["parameters"]["ismear"] == 2 - assert output["relax"]["parameters"]["sigma"] == 0.2 + assert output["relax"]["parameters"]["ismear"] == 0 + assert output["relax"]["parameters"]["sigma"] == 0.05 assert output["relax"]["parameters"]["kspacing"] == 0.22 assert output["relax"]["parameters"]["pp"] == "PBE" assert output["prerelax"]["parameters"]["gga"] == "PS" @@ -453,7 +535,7 @@ def test_mp_metagga_relax_flow(tmp_path, monkeypatch): assert output["relax"]["parameters"]["metagga"].lower() == "r2scan" assert output["relax"]["parameters"]["ediffg"] == -0.02 assert output["relax"]["parameters"]["encut"] == 680 - assert output["relax"]["parameters"]["ismear"] == -5 + assert output["relax"]["parameters"]["ismear"] == 0 assert output["relax"]["parameters"]["kspacing"] == pytest.approx( 0.28329488761304206 ) @@ -466,12 +548,13 @@ def test_mp_metagga_relax_flow(tmp_path, monkeypatch): atoms.pbc = True output = mp_metagga_relax_flow(atoms) assert output["static"]["nsites"] == len(atoms) + assert output["static"]["parameters"]["ismear"] == -5 assert output["static"]["parameters"]["nsw"] == 0 assert output["static"]["parameters"]["algo"] == "fast" assert output["relax"]["parameters"]["metagga"].lower() == "r2scan" assert output["relax"]["parameters"]["ediffg"] == -0.02 assert output["relax"]["parameters"]["encut"] == 680 - assert output["relax"]["parameters"]["ismear"] == -5 + assert output["relax"]["parameters"]["ismear"] == 0 assert output["relax"]["parameters"]["kspacing"] == pytest.approx( 0.28329488761304206 )