Skip to content

Commit 4c16003

Browse files
Adjust default kwargs for matpes_static_job (#3103)
We have a `matpes_static_job` that can be used to reproduce MatPES settings. It pulls the settings directly from Pymatgen to ensure compatibility. This PR introduces a few changes. Independently, @Naisargi-Goyal and I have identified that there are some minor changes to the MatPES settings that are generally worth considering that do not notably break compatibility to any appreciable degree. For instance, the ENAUG flag is deprecated by VASP and is entirely unused. Similarly, we tend to have better SCF convergence with ALGO = All/ISEARCH = 1 than the default ALGO = Normal. And finally, VASP recommends using GGA_COMPAT = False for all calculations even though MatPES uses GGA_COMPAT = True. The last one is the only one that should have any impact on the results, but VASP reports the difference in energies are sub-meV level in terms of the total energy difference and should be virtually negligible. These changes are enabled with `use_improvements=True` in the `matpes_static_job`. Additionally, there is a `write_extra_files` keyword argument to write out the ELFCAR and more points in the DOSCAR. This is just to have more data written to disk. Both `use_improvements` and `write_extra_files` were set to `True` by default to reproduce our own settings. But I think it would be better in hindsight for these to be set to `False` by default so as to reproduce the MatPES settings exactly by default, which is likely what the user expects. That is what I am proposing here. I have also made a separate `mof_off_static_job` for @Naisargi-Goyal's work that calls `matpes_static_job` with `kspacing=0.4`, `use_improvements=True`, and `write_extra_files=True` for convenience.
1 parent f041b12 commit 4c16003

File tree

4 files changed

+226
-14
lines changed

4 files changed

+226
-14
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ jobs:
459459
echo "COVERAGE_CORE=sysmon" >> $GITHUB_ENV
460460
461461
- name: Run tests with pytest
462-
run: pytest -k 'matpes or mp_' --durations=10 --cov=quacc --cov-report=xml
462+
run: pytest -k 'matpes or mp_ or mof_off' --durations=10 --cov=quacc --cov-report=xml
463463

464464
- name: Upload code coverage report to Artifact
465465
uses: actions/upload-artifact@v6

src/quacc/recipes/vasp/matpes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def matpes_static_job(
3535
*,
3636
level: Literal["PBE", "r2SCAN", "HSE06"],
3737
kspacing: float | None = 0.22,
38-
use_improvements: bool = True,
39-
write_extra_files: bool = True,
38+
use_improvements: bool = False,
39+
write_extra_files: bool = False,
4040
prev_dir: SourceDirectory | None = None,
4141
**calc_kwargs,
4242
) -> VaspSchema:

src/quacc/recipes/vasp/mof_off.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""
2+
MOF-off-compatible VASP static calculation recipe.
3+
"""
4+
5+
from __future__ import annotations
6+
7+
from importlib.util import find_spec
8+
from typing import TYPE_CHECKING
9+
10+
from monty.dev import requires
11+
12+
from quacc import job
13+
from quacc.recipes.vasp.matpes import matpes_static_job
14+
from quacc.utils.dicts import recursive_dict_merge
15+
16+
has_atomate2 = bool(find_spec("atomate2"))
17+
18+
if TYPE_CHECKING:
19+
from typing import Literal
20+
21+
from ase.atoms import Atoms
22+
23+
from quacc.types import SourceDirectory, VaspSchema
24+
25+
26+
@job
27+
@requires(has_atomate2, "atomate2 is not installed. Run `pip install quacc[mp]`")
28+
def mof_off_static_job(
29+
atoms: Atoms,
30+
*,
31+
level: Literal["PBE", "r2SCAN"],
32+
prev_dir: SourceDirectory | None = None,
33+
**calc_kwargs,
34+
) -> VaspSchema:
35+
"""
36+
Function to run a MOF-Off-compatible static calculation.
37+
38+
Parameters
39+
----------
40+
atoms
41+
Atoms object
42+
level
43+
The level of theory: "PBE", "r2SCAN"
44+
prev_dir
45+
A previous directory for a prior step in the workflow.
46+
**calc_kwargs
47+
Custom kwargs for the Vasp calculator. Set a value to
48+
`None` to remove a pre-existing key entirely. For a list of available
49+
keys, refer to [quacc.calculators.vasp.vasp.Vasp][]. All of the ASE
50+
Vasp calculator keyword arguments are supported.
51+
52+
Returns
53+
-------
54+
VaspSchema
55+
Dictionary of results from [quacc.schemas.vasp.VaspSummarize.run][].
56+
See the type-hint for the data structure.
57+
"""
58+
default_parameters = {
59+
"kspacing": 0.4,
60+
"use_improvements": True,
61+
"write_extra_files": True,
62+
}
63+
calc_flags = recursive_dict_merge(default_parameters, calc_kwargs)
64+
65+
return matpes_static_job(atoms, level=level, prev_dir=prev_dir, **calc_flags)

tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py

Lines changed: 158 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
static_job,
1919
)
2020
from quacc.recipes.vasp.matpes import matpes_static_job
21+
from quacc.recipes.vasp.mof_off import mof_off_static_job
2122
from quacc.recipes.vasp.mp24 import (
2223
mp_metagga_relax_flow,
2324
mp_metagga_relax_job,
@@ -892,7 +893,13 @@ def test_freq_job():
892893

893894
@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed")
894895
def test_matpes(patch_metallic_taskdoc):
895-
output = matpes_static_job(bulk("Al"), level="pbe", ncore=None)
896+
output = matpes_static_job(
897+
bulk("Al"),
898+
level="pbe",
899+
ncore=None,
900+
use_improvements=True,
901+
write_extra_files=True,
902+
)
896903
assert output["parameters"] == {
897904
"algo": "all",
898905
"ediff": 1e-05,
@@ -927,7 +934,13 @@ def test_matpes(patch_metallic_taskdoc):
927934

928935
atoms_barium = bulk("Al")
929936
atoms_barium[0].symbol = "Ba"
930-
output = matpes_static_job(atoms_barium, level="pbe", ncore=None)
937+
output = matpes_static_job(
938+
atoms_barium,
939+
level="pbe",
940+
ncore=None,
941+
use_improvements=True,
942+
write_extra_files=True,
943+
)
931944
assert output["parameters"] == {
932945
"algo": "all",
933946
"ediff": 1e-05,
@@ -960,14 +973,7 @@ def test_matpes(patch_metallic_taskdoc):
960973
"xc": "pbe",
961974
}
962975

963-
output = matpes_static_job(
964-
bulk("Al"),
965-
level="pbe",
966-
kspacing=0.4,
967-
use_improvements=False,
968-
write_extra_files=False,
969-
ncore=None,
970-
)
976+
output = matpes_static_job(bulk("Al"), level="pbe", kspacing=0.4, ncore=None)
971977
assert output["parameters"] == {
972978
"algo": "normal",
973979
"ediff": 1e-05,
@@ -997,6 +1003,41 @@ def test_matpes(patch_metallic_taskdoc):
9971003
}
9981004

9991005
output = matpes_static_job(bulk("Al"), level="r2scan", ncore=None)
1006+
assert output["parameters"] == {
1007+
"algo": "normal",
1008+
"ediff": 1e-05,
1009+
"enaug": 1360,
1010+
"encut": 680.0,
1011+
"ismear": 0,
1012+
"ispin": 2,
1013+
"kspacing": 0.22,
1014+
"laechg": True,
1015+
"lasph": True,
1016+
"lcharg": True,
1017+
"lmaxmix": 6,
1018+
"lmixtau": True,
1019+
"lorbit": 11,
1020+
"lreal": False,
1021+
"lwave": False,
1022+
"magmom": [0.6],
1023+
"metagga": "R2SCAN",
1024+
"nelm": 200,
1025+
"nsw": 0,
1026+
"pp": "PBE",
1027+
"pp_version": "64",
1028+
"prec": "accurate",
1029+
"setups": {"Al": ""},
1030+
"sigma": 0.05,
1031+
"xc": "r2scan",
1032+
}
1033+
1034+
output = matpes_static_job(
1035+
bulk("Al"),
1036+
level="r2scan",
1037+
ncore=None,
1038+
use_improvements=True,
1039+
write_extra_files=True,
1040+
)
10001041
assert output["parameters"] == {
10011042
"algo": "all",
10021043
"ediff": 1e-05,
@@ -1031,7 +1072,13 @@ def test_matpes(patch_metallic_taskdoc):
10311072

10321073
atoms_no_mag = bulk("Al")
10331074
atoms_no_mag.set_initial_magnetic_moments([0.0] * len(atoms_no_mag))
1034-
output = matpes_static_job(atoms_no_mag, level="hse06", ncore=None)
1075+
output = matpes_static_job(
1076+
atoms_no_mag,
1077+
level="hse06",
1078+
ncore=None,
1079+
use_improvements=True,
1080+
write_extra_files=True,
1081+
)
10351082
assert output["parameters"] == {
10361083
"algo": "normal",
10371084
"ediff": 1e-05,
@@ -1065,10 +1112,110 @@ def test_matpes(patch_metallic_taskdoc):
10651112
"xc": "hse06",
10661113
}
10671114

1115+
output = matpes_static_job(atoms_no_mag, level="hse06", ncore=None)
1116+
assert output["parameters"] == {
1117+
"algo": "normal",
1118+
"ediff": 1e-05,
1119+
"enaug": 1360,
1120+
"encut": 680.0,
1121+
"gga": "PE",
1122+
"hfscreen": 0.2,
1123+
"ismear": 0,
1124+
"ispin": 2,
1125+
"kspacing": 0.22,
1126+
"laechg": True,
1127+
"lasph": True,
1128+
"lcharg": True,
1129+
"lhfcalc": True,
1130+
"lmaxmix": 6,
1131+
"lmixtau": True,
1132+
"lorbit": 11,
1133+
"lreal": False,
1134+
"lwave": False,
1135+
"magmom": [0.0],
1136+
"nelm": 200,
1137+
"nsw": 0,
1138+
"pp": "PBE",
1139+
"pp_version": "64",
1140+
"prec": "accurate",
1141+
"setups": {"Al": ""},
1142+
"sigma": 0.05,
1143+
"xc": "hse06",
1144+
}
1145+
10681146
with pytest.raises(ValueError, match="Unsupported value for m06"):
10691147
matpes_static_job(bulk("Al"), level="m06")
10701148

10711149

1150+
@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed")
1151+
def test_mof_off(patch_metallic_taskdoc):
1152+
output = mof_off_static_job(bulk("Al"), level="pbe", ncore=None)
1153+
assert output["parameters"] == {
1154+
"algo": "all",
1155+
"ediff": 1e-05,
1156+
"efermi": "midgap",
1157+
"encut": 680.0,
1158+
"gga": "PE",
1159+
"gga_compat": False,
1160+
"isearch": 1,
1161+
"ismear": 0,
1162+
"ispin": 2,
1163+
"kspacing": 0.4,
1164+
"laechg": True,
1165+
"lasph": True,
1166+
"lcharg": True,
1167+
"lelf": True,
1168+
"lmaxmix": 6,
1169+
"lmixtau": True,
1170+
"lorbit": 11,
1171+
"lreal": False,
1172+
"lwave": True,
1173+
"magmom": [0.6],
1174+
"nedos": 3001,
1175+
"nelm": 200,
1176+
"nsw": 0,
1177+
"pp": "PBE",
1178+
"pp_version": "64",
1179+
"prec": "accurate",
1180+
"setups": {"Al": ""},
1181+
"sigma": 0.05,
1182+
"xc": "pbe",
1183+
}
1184+
1185+
output = mof_off_static_job(bulk("Al"), level="r2scan", ncore=None)
1186+
assert output["parameters"] == {
1187+
"algo": "all",
1188+
"ediff": 1e-05,
1189+
"efermi": "midgap",
1190+
"encut": 680.0,
1191+
"gga_compat": False,
1192+
"isearch": 1,
1193+
"ismear": 0,
1194+
"ispin": 2,
1195+
"kspacing": 0.4,
1196+
"laechg": True,
1197+
"lasph": True,
1198+
"lcharg": True,
1199+
"lelf": True,
1200+
"lmaxmix": 6,
1201+
"lmixtau": True,
1202+
"lorbit": 11,
1203+
"lreal": False,
1204+
"lwave": False,
1205+
"magmom": [0.6],
1206+
"metagga": "R2SCAN",
1207+
"nedos": 3001,
1208+
"nelm": 200,
1209+
"nsw": 0,
1210+
"pp": "PBE",
1211+
"pp_version": "64",
1212+
"prec": "accurate",
1213+
"setups": {"Al": ""},
1214+
"sigma": 0.05,
1215+
"xc": "r2scan",
1216+
}
1217+
1218+
10721219
@pytest.mark.skipif(not has_fairchem_omat, reason="fairchem not installed")
10731220
def test_fairchem_omat(patch_metallic_taskdoc):
10741221
from quacc.recipes.vasp.fairchem import omat_static_job

0 commit comments

Comments
 (0)