Skip to content

Commit

Permalink
Update VASP sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen committed Feb 17, 2024
1 parent e6f4944 commit d9055e8
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 40 deletions.
3 changes: 2 additions & 1 deletion src/quacc/calculators/vasp/vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
30 changes: 16 additions & 14 deletions src/quacc/recipes/vasp/mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
133 changes: 108 additions & 25 deletions tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -361,23 +362,45 @@ 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)
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"] == 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"]

Expand All @@ -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"]
Expand All @@ -400,22 +423,45 @@ 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)
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"] == 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)
Expand All @@ -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)

Expand All @@ -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"
Expand All @@ -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
)
Expand All @@ -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
)
Expand Down

0 comments on commit d9055e8

Please sign in to comment.