Skip to content

Commit 6f4dc00

Browse files
Add OC20 recipe (#3271)
## Summary of Changes Add OC20 recipe. Pending confirmation of an upstream issue at facebookresearch/fairchem#2030.
1 parent d37cf64 commit 6f4dc00

4 files changed

Lines changed: 93 additions & 10 deletions

File tree

src/quacc/calculators/vasp/params.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,6 @@ def get_param_swaps(
155155
)
156156
calc.set(lreal=False)
157157

158-
if not calc.parameters.get("lorbit", False) and (
159-
calc.parameters.get("ispin", 1) == 2
160-
or np.any(input_atoms.get_initial_magnetic_moments() != 0)
161-
):
162-
LOGGER.info(
163-
"Recommending LORBIT = 11 because you have a spin-polarized calculation."
164-
)
165-
calc.set(lorbit=11)
166-
167158
if (
168159
calc.parameters.get("lhfcalc", False) is True
169160
and calc.parameters.get("isym", 3) < 3
@@ -190,6 +181,15 @@ def get_param_swaps(
190181
# Light INCAR swaps
191182
# ----------------------------
192183
if incar_copilot_mode.lower() != "off":
184+
if not calc.parameters.get("lorbit", False) and (
185+
calc.parameters.get("ispin", 1) == 2
186+
or np.any(input_atoms.get_initial_magnetic_moments() != 0)
187+
):
188+
LOGGER.info(
189+
"Recommending LORBIT = 11 because you have a spin-polarized calculation."
190+
)
191+
calc.set(lorbit=11)
192+
193193
if (
194194
calc.parameters.get("ismear", 1) == -5
195195
and (calc.kpts is not None and np.prod(calc.kpts) < 4)

src/quacc/recipes/vasp/fairchem.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,62 @@ def odac_static_job(
241241
"isym": 0,
242242
"pp_version": "54",
243243
}
244+
calc_defaults |= {"incar_copilot": "light"}
244245
return run_and_summarize(
245246
atoms,
246247
calc_defaults=calc_defaults,
247248
calc_swaps=calc_kwargs,
248249
additional_fields={"name": "ODAC Static"} | (additional_fields or {}),
249250
copy_files=copy_files,
250251
)
252+
253+
254+
@job
255+
@requires(
256+
has_fairchem_omat,
257+
"fairchem-data-oc is not installed. Run `pip install quacc[fairchem]`",
258+
)
259+
def oc20_static_job(
260+
atoms: Atoms,
261+
copy_files: SourceDirectory | Copy | None = None,
262+
additional_fields: dict[str, Any] | None = None,
263+
**calc_kwargs,
264+
) -> VaspSchema:
265+
"""
266+
Carry out a static calculation with OC20 settings.
267+
268+
Parameters
269+
----------
270+
atoms
271+
Atoms object
272+
copy_files
273+
Files to copy (and decompress) from source to the runtime directory.
274+
additional_fields
275+
Additional fields to add to the results dictionary.
276+
**calc_kwargs
277+
Custom kwargs for the Vasp calculator. Set a value to
278+
`None` to remove a pre-existing key entirely. For a list of available
279+
keys, refer to [quacc.calculators.vasp.vasp.Vasp][]. All of the ASE
280+
Vasp calculator keyword arguments are supported.
281+
282+
Returns
283+
-------
284+
VaspSchema
285+
Dictionary of results from [quacc.schemas.vasp.VaspSummarize.run][].
286+
See the type-hint for the data structure.
287+
"""
288+
from fairchem.data.oc.utils.vasp_flags import VASP_FLAGS
289+
290+
calc_defaults = VASP_FLAGS | {
291+
"xc": "RPBE",
292+
"pp_version": "54",
293+
"incar_copilot": "light",
294+
}
295+
296+
return run_and_summarize(
297+
atoms,
298+
calc_defaults=calc_defaults,
299+
calc_swaps=calc_kwargs,
300+
additional_fields={"name": "OC20 Static"} | (additional_fields or {}),
301+
copy_files=copy_files,
302+
)

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
and util.find_spec("fairchem.data") is not None
4343
and util.find_spec("fairchem.data.omat") is not None
4444
)
45-
45+
has_fairchem_oc = (
46+
has_fairchem
47+
and util.find_spec("fairchem.data") is not None
48+
and util.find_spec("fairchem.data.oc") is not None
49+
)
4650
FILE_DIR = Path(__file__).parent
4751
MOCKED_DIR = FILE_DIR / "mocked_vasp_runs"
4852

@@ -1362,3 +1366,29 @@ def test_fairchem_odac(patch_nonmetallic_taskdoc):
13621366
"pp": "PBE",
13631367
"pp_version": "54",
13641368
}
1369+
1370+
1371+
@pytest.mark.skipif(not has_fairchem_oc, reason="fairchem not installed")
1372+
def test_fairchem_oc20(patch_nonmetallic_taskdoc):
1373+
from quacc.recipes.vasp.fairchem import oc20_static_job
1374+
1375+
atoms = bulk("Si")
1376+
output = oc20_static_job(atoms)
1377+
output["parameters"].pop("ncore")
1378+
assert output["parameters"] == {
1379+
"ibrion": 2,
1380+
"nsw": 2000,
1381+
"isif": 0,
1382+
"ispin": 1,
1383+
"isym": 0,
1384+
"lreal": "auto",
1385+
"ediffg": -0.03,
1386+
"symprec": 1e-10,
1387+
"encut": 350.0,
1388+
"laechg": False,
1389+
"lwave": False,
1390+
"gga": "RP",
1391+
"pp": "PBE",
1392+
"xc": "rpbe",
1393+
"pp_version": "54",
1394+
}

tests/requirements-fairchem.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
fairchem-core==2.21.0
2+
fairchem-data-oc==1.0.2
23
fairchem-data-omat==0.2
34
atomate2==0.1.4

0 commit comments

Comments
 (0)