From a3803be9da3a9423c5c1808f9496c0827a1710bd Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 22:42:47 -0800 Subject: [PATCH 01/33] Support Pymatgen-style VASP input sets --- src/quacc/calculators/vasp/params.py | 31 ++++++++++++++++++++++++++++ src/quacc/calculators/vasp/vasp.py | 16 +++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index 30f202b6bb..156b4fe84e 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -6,6 +6,7 @@ import numpy as np from ase.calculators.vasp import Vasp as Vasp_ +from pymatgen.io.ase import AseAtomsAdaptor from quacc.atoms.core import check_is_metal from quacc.utils.kpts import convert_pmg_kpts @@ -14,6 +15,7 @@ from typing import Any, Literal from ase.atoms import Atoms + from pymatgen.io.vasp.sets import DictSet from quacc.utils.kpts import PmgKpts @@ -346,3 +348,32 @@ def set_pmg_kpts( user_calc_params["gamma"] = gamma return user_calc_params + + +def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms | None = None) -> dict: + """ + Convert a Pymatgen VASP input set into an ASE-compatible set of + calculator parameters. + + Parameters + ---------- + pmg_input_set + The Pymatgen VASP input set. + atoms + The input atoms. + + Returns + ------- + dict + The ASE-compatible set of calculator parameters. + """ + structure = AseAtomsAdaptor.get_structure(atoms) + pmg_input_set = dict_set(structure=structure) + kpoints_dict = pmg_input_set.kpoints.as_dict() + potcar_symbols = pmg_input_set.potcar_symbols + potcar_setups = {symbol.split("_")[0]: symbol for symbol in potcar_symbols} + return pmg_input_set.incar | { + "kpts": kpoints_dict["kpoints"][0], + "gamma": kpoints_dict["generation_style"] == "Gamma", + "setups": potcar_setups, + } diff --git a/src/quacc/calculators/vasp/vasp.py b/src/quacc/calculators/vasp/vasp.py index 63530deaf6..dfd6aaacaa 100644 --- a/src/quacc/calculators/vasp/vasp.py +++ b/src/quacc/calculators/vasp/vasp.py @@ -17,6 +17,7 @@ from quacc.calculators.vasp.io import load_vasp_yaml_calc from quacc.calculators.vasp.params import ( get_param_swaps, + get_pmg_input_set_params, remove_unused_flags, set_auto_dipole, set_pmg_kpts, @@ -27,6 +28,7 @@ from typing import Literal from ase.atoms import Atoms + from pymatgen.io.vasp.sets import DictSet class Vasp(Vasp_): @@ -48,6 +50,7 @@ def __init__( | dict[Literal["length_densities"], list[float]] | None = None, auto_dipole: bool | None = None, + pmg_input_set: DictSet | None = None, **kwargs, ) -> None: """ @@ -92,6 +95,9 @@ def __init__( auto_dipole If True, will automatically set dipole moment correction parameters based on the center of mass (in the c dimension by default). + pmg_input_set + A Pymatgen input set to use for the VASP calculation, taken from a + `pymatgen.io.vasp.sets.DictSet` object. **kwargs Additional arguments to be passed to the VASP calculator, e.g. `xc='PBE'`, `encut=520`. Takes all valid ASE calculator arguments. @@ -130,6 +136,7 @@ def __init__( self.elemental_magmoms = elemental_magmoms self.pmg_kpts = pmg_kpts self.auto_dipole = auto_dipole + self.pmg_input_set = pmg_input_set self.kwargs = kwargs # Initialize for later @@ -206,6 +213,13 @@ def _cleanup_params(self) -> None: msg = "Atoms object has a constraint that is not compatible with Custodian." raise ValueError(msg) + # Get Pymatgen VASP input set parameters + pmg_calc_params = ( + get_pmg_input_set_params(self.pmg_input_set, atoms=self.input_atoms) + if self.pmg_input_set + else {} + ) + # Get user-defined preset parameters for the calculator if self.preset: calc_preset = load_vasp_yaml_calc(SETTINGS.VASP_PRESET_DIR / self.preset)[ @@ -216,7 +230,7 @@ def _cleanup_params(self) -> None: # Collect all the calculator parameters and prioritize the kwargs in the # case of duplicates. - self.user_calc_params = calc_preset | self.kwargs + self.user_calc_params = pmg_calc_params | calc_preset | self.kwargs # Allow the user to use setups='mysetups.yaml' to load in a custom # setups from a YAML file From 3b86805034788c58402f18d9c43441f08f65946a Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 22:50:40 -0800 Subject: [PATCH 02/33] fix --- src/quacc/calculators/vasp/params.py | 4 +- .../calculators/vasp/presets/MPScanSet.yaml | 30 ----- .../vasp/presets/setups_pbe54_MP.yaml | 103 ------------------ src/quacc/recipes/vasp/mp.py | 12 +- 4 files changed, 6 insertions(+), 143 deletions(-) delete mode 100644 src/quacc/calculators/vasp/presets/MPScanSet.yaml delete mode 100644 src/quacc/calculators/vasp/presets/setups_pbe54_MP.yaml diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index 156b4fe84e..bc95bfb7f2 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -357,9 +357,9 @@ def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms | None = None) -> d Parameters ---------- - pmg_input_set + dict_set The Pymatgen VASP input set. - atoms + atoms | None The input atoms. Returns diff --git a/src/quacc/calculators/vasp/presets/MPScanSet.yaml b/src/quacc/calculators/vasp/presets/MPScanSet.yaml deleted file mode 100644 index b2aaee4ba5..0000000000 --- a/src/quacc/calculators/vasp/presets/MPScanSet.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Default VASP settings for calculations in the Materials Project -# using the r2SCAN functional. -# Caution: The pseudopotentials should be used with the .54 PAW PBE set -# Source: https://github.com/materialsproject/atomate2/blob/main/src/atomate2/vasp/sets/BaseMPR2SCANRelaxSet.yaml -# Last modified: 08-07-2023 -inputs: - algo: all - ediff: 1.0e-5 - ediffg: -0.02 - enaug: 1360 - encut: 680 - ibrion: 2 - isif: 3 - ismear: 0 - kspacing: 0.22 - laechg: True - lasph: True - lcharg: True - lmixtau: True - lorbit: 11 - lreal: auto - lvtot: True - lwave: False - nelm: 200 - nsw: 99 - prec: accurate - sigma: 0.05 - xc: r2scan -parent_magmoms: magmoms_MP.yaml -parent_setups: setups_pbe54_MP.yaml diff --git a/src/quacc/calculators/vasp/presets/setups_pbe54_MP.yaml b/src/quacc/calculators/vasp/presets/setups_pbe54_MP.yaml deleted file mode 100644 index 7d1b0ecca2..0000000000 --- a/src/quacc/calculators/vasp/presets/setups_pbe54_MP.yaml +++ /dev/null @@ -1,103 +0,0 @@ -# Materials Project pseudopotentials (r2SCAN workflow) -# Note: These are specifically the .54 PAW PBE potentials -# Source: https://github.com/materialsproject/atomate2/blob/main/src/atomate2/vasp/sets/BaseMPR2SCANRelaxSet.yaml -# Last modified: 08-01-2023 -inputs: - setups: - Ac: Ac - Ag: Ag - Al: Al - Am: Am - Ar: Ar - As: As - At: At - Au: Au - B: B - Ba: Ba_sv - Be: Be_sv - Bi: Bi - Br: Br - C: C - Ca: Ca_sv - Cd: Cd - Ce: Ce - Cf: Cf - Cl: Cl - Cm: Cm - Co: Co - Cr: Cr_pv - Cs: Cs_sv - Cu: Cu_pv - Dy: Dy_3 - Er: Er_3 - Eu: Eu - F: F - Fe: Fe_pv - Fr: Fr_sv - Ga: Ga_d - Gd: Gd - Ge: Ge_d - H: H - He: He - Hf: Hf_pv - Hg: Hg - Ho: Ho_3 - I: I - In: In_d - Ir: Ir - K: K_sv - Kr: Kr - La: La - Li: Li_sv - Lu: Lu_3 - Mg: Mg_pv - Mn: Mn_pv - Mo: Mo_pv - N: N - Na: Na_pv - Nb: Nb_pv - Nd: Nd_3 - Ne: Ne - Ni: Ni_pv - Np: Np - O: O - Os: Os_pv - P: P - Pa: Pa - Pb: Pb_d - Pd: Pd - Pm: Pm_3 - Po: Po_d - Pr: Pr_3 - Pt: Pt - Pu: Pu - Ra: Ra_sv - Rb: Rb_sv - Re: Re_pv - Rh: Rh_pv - Rn: Rn - Ru: Ru_pv - S: S - Sb: Sb - Sc: Sc_sv - Se: Se - Si: Si - Sm: Sm_3 - Sn: Sn_d - Sr: Sr_sv - Ta: Ta_pv - Tb: Tb_3 - Tc: Tc_pv - Te: Te - Th: Th - Ti: Ti_pv - Tl: Tl_d - Tm: Tm_3 - U: U - V: V_pv - W: W_sv - Xe: Xe - Y: Y_sv - Yb: Yb_3 - Zn: Zn - Zr: Zr_sv diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index a62293a90f..9e63ed5276 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -15,10 +15,12 @@ """ from __future__ import annotations +from functools import partial from pathlib import Path from typing import TYPE_CHECKING import numpy as np +from pymatgen.io.vasp.sets import MPScanRelaxSet from quacc import flow, job from quacc.recipes.vasp._base import base_fn @@ -35,7 +37,6 @@ @job def mp_prerelax_job( atoms: Atoms, - preset: str | None = "MPScanSet", bandgap: float | None = None, copy_files: str | Path | list[str | Path] | None = None, **calc_kwargs, @@ -48,8 +49,6 @@ def mp_prerelax_job( ---------- atoms Atoms object - preset - Preset to use from `quacc.calculators.vasp.presets`. bandgap Estimate for the bandgap in eV. copy_files @@ -75,9 +74,9 @@ def mp_prerelax_job( return base_fn( atoms, - preset=preset, calc_defaults=calc_defaults, calc_swaps=calc_kwargs, + pmg_input_set=partial(MPScanRelaxSet, bandgap=bandgap), additional_fields={"name": "MP Pre-Relax"}, copy_files=copy_files, ) @@ -86,7 +85,6 @@ def mp_prerelax_job( @job def mp_relax_job( atoms: Atoms, - preset: str | None = "MPScanSet", bandgap: float | None = None, copy_files: str | Path | list[str | Path] | None = None, **calc_kwargs, @@ -99,8 +97,6 @@ def mp_relax_job( ---------- atoms Atoms object - preset - Preset to use from `quacc.calculators.vasp.presets`. bandgap Estimate for the bandgap in eV. copy_files @@ -120,9 +116,9 @@ def mp_relax_job( calc_defaults = {"lcharg": True, "lwave": True} | _get_bandgap_swaps(bandgap) return base_fn( atoms, - preset=preset, calc_defaults=calc_defaults, calc_swaps=calc_kwargs, + pmg_input_set=partial(MPScanRelaxSet, bandgap=bandgap), additional_fields={"name": "MP Relax"}, copy_files=copy_files, ) From 9cee0d97a6f730e47867eac539fec03c18acb8f0 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 22:52:57 -0800 Subject: [PATCH 03/33] fix --- src/quacc/recipes/vasp/mp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 9e63ed5276..72a31869c0 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -66,6 +66,7 @@ def mp_prerelax_job( """ calc_defaults = { + "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), "ediffg": -0.05, "xc": "pbesol", "lwave": True, @@ -113,12 +114,15 @@ def mp_relax_job( See the type-hint for the data structure. """ - calc_defaults = {"lcharg": True, "lwave": True} | _get_bandgap_swaps(bandgap) + calc_defaults = { + "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), + "lcharg": True, + "lwave": True, + } | _get_bandgap_swaps(bandgap) return base_fn( atoms, calc_defaults=calc_defaults, calc_swaps=calc_kwargs, - pmg_input_set=partial(MPScanRelaxSet, bandgap=bandgap), additional_fields={"name": "MP Relax"}, copy_files=copy_files, ) From 95c8ac48748d04fa6f87b7a1b199ebff32af2777 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 22:54:18 -0800 Subject: [PATCH 04/33] fix --- src/quacc/recipes/vasp/mp.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 72a31869c0..9326d05d02 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -77,7 +77,6 @@ def mp_prerelax_job( atoms, calc_defaults=calc_defaults, calc_swaps=calc_kwargs, - pmg_input_set=partial(MPScanRelaxSet, bandgap=bandgap), additional_fields={"name": "MP Pre-Relax"}, copy_files=copy_files, ) From 97985447a4eab2d2acc72a632f53f27eebab3784 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 22:58:25 -0800 Subject: [PATCH 05/33] fix --- src/quacc/recipes/vasp/mp.py | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 9326d05d02..7abbec7b77 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -71,8 +71,7 @@ def mp_prerelax_job( "xc": "pbesol", "lwave": True, "lcharg": True, - } | _get_bandgap_swaps(bandgap) - + } return base_fn( atoms, calc_defaults=calc_defaults, @@ -117,7 +116,7 @@ def mp_relax_job( "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), "lcharg": True, "lwave": True, - } | _get_bandgap_swaps(bandgap) + } return base_fn( atoms, calc_defaults=calc_defaults, @@ -182,27 +181,3 @@ def mp_relax_flow( relax_results["prerelax"] = prerelax_results return relax_results - - -def _get_bandgap_swaps(bandgap: float | None = None) -> dict[str, float]: - """ - Get bandgap-related swaps. - - Parameters - --------- - bandgap - The bandgap, in units of eV. - - Returns - ------- - dict - Dictionary of swaps. - """ - - if bandgap is None: - return {"kspacing": 0.22, "ismear": 0, "sigma": 0.05} - if bandgap <= 1e-4: - return {"kspacing": 0.22, "ismear": 2, "sigma": 0.2} - rmin = max(1.5, 25.22 - 2.87 * bandgap) - kspacing = 2 * np.pi * 1.0265 / (rmin - 1.0183) - return {"kspacing": min(kspacing, 0.44), "ismear": -5, "sigma": 0.05} From ad410b40a2fcb25e9c83159c871f9768a36df60e Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 23:01:04 -0800 Subject: [PATCH 06/33] rename --- docs/user/recipes/recipes_list.md | 4 ++-- src/quacc/recipes/vasp/mp.py | 22 +++++++++---------- .../vasp_recipes/mocked/test_vasp_recipes.py | 22 +++++++++++-------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/docs/user/recipes/recipes_list.md b/docs/user/recipes/recipes_list.md index c6846eb45f..76ccb17d3e 100644 --- a/docs/user/recipes/recipes_list.md +++ b/docs/user/recipes/recipes_list.md @@ -236,8 +236,8 @@ The list of available quacc recipes is shown below. The "Req'd Extras" column sp | VASP Slab Relax | `#!Python @job` | [quacc.recipes.vasp.slabs.relax_job][] | | | VASP Bulk to Slabs | `#!Python @flow` | [quacc.recipes.vasp.slabs.bulk_to_slabs_flow][] | | | VASP Slab to Adsorbates | `#!Python @flow` | [quacc.recipes.vasp.slabs.slab_to_ads_flow][] | | -| VASP MP Prerelax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_relax_job][] | | -| VASP MP Relax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_relax_job][] | | +| VASP MP Prerelax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | +| VASP MP Relax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | | VASP MP Relax Workflow | `#!Python @flow` | [quacc.recipes.vasp.mp.mp_relax_flow][] | | | VASP QMOF Relax | `#!Python @job` | [quacc.recipes.vasp.qmof.qmof_relax_job][] | | diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 7abbec7b77..a56a6c23d4 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -35,7 +35,7 @@ @job -def mp_prerelax_job( +def mp_metagga_prerelax_job( atoms: Atoms, bandgap: float | None = None, copy_files: str | Path | list[str | Path] | None = None, @@ -82,7 +82,7 @@ def mp_prerelax_job( @job -def mp_relax_job( +def mp_metagga_relax_job( atoms: Atoms, bandgap: float | None = None, copy_files: str | Path | list[str | Path] | None = None, @@ -136,12 +136,12 @@ def mp_relax_flow( Workflow consisting of: 1. MP-compatible pre-relax - - name: "mp_prerelax_job" - - job: [quacc.recipes.vasp.mp.mp_prerelax_job][] + - name: "mp_metagga_prerelax_job" + - job: [quacc.recipes.vasp.mp.mp_metagga_prerelax_job][] 2. MP-compatible relax - - name: "mp_relax_job" - - job: [quacc.recipes.vasp.mp.mp_relax_job][] + - name: "mp_metagga_relax_job" + - job: [quacc.recipes.vasp.mp.mp_metagga_relax_job][] Parameters ---------- @@ -159,18 +159,18 @@ def mp_relax_flow( MPRelaxFlowSchema Dictionary of results. See the type-hint for the data structure. """ - mp_prerelax_job_, mp_relax_job_ = customize_funcs( - ["mp_prerelax_job", "mp_relax_job"], - [mp_prerelax_job, mp_relax_job], + mp_metagga_prerelax_job_, mp_metagga_relax_job_ = customize_funcs( + ["mp_metagga_prerelax_job", "mp_metagga_relax_job"], + [mp_metagga_prerelax_job, mp_metagga_relax_job], parameters=job_params, decorators=job_decorators, ) # Run the prerelax - prerelax_results = mp_prerelax_job_(atoms) + prerelax_results = mp_metagga_prerelax_job_(atoms) # Run the relax - relax_results = mp_relax_job_( + relax_results = mp_metagga_relax_job_( prerelax_results["atoms"], bandgap=prerelax_results["output"]["bandgap"], copy_files=[ 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 035a83e7a5..5c38297e63 100644 --- a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py +++ b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py @@ -3,7 +3,11 @@ from quacc import SETTINGS from quacc.recipes.vasp.core import double_relax_job, relax_job, static_job -from quacc.recipes.vasp.mp import mp_prerelax_job, mp_relax_flow, mp_relax_job +from quacc.recipes.vasp.mp import ( + mp_metagga_prerelax_job, + mp_metagga_relax_job, + mp_relax_flow, +) from quacc.recipes.vasp.qmof import qmof_relax_job from quacc.recipes.vasp.slabs import bulk_to_slabs_flow from quacc.recipes.vasp.slabs import relax_job as slab_relax_job @@ -351,11 +355,11 @@ def test_qmof(tmp_path, monkeypatch): assert output["double_relax"][1]["parameters"]["isif"] == 2 -def test_mp_prerelax_job(tmp_path, monkeypatch): +def test_mp_metagga_prerelax_job(tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) atoms = bulk("Al") - output = mp_prerelax_job(atoms) + output = mp_metagga_prerelax_job(atoms) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "pbesol" assert output["parameters"]["ediffg"] == -0.05 @@ -364,7 +368,7 @@ def test_mp_prerelax_job(tmp_path, monkeypatch): assert output["parameters"]["ismear"] == 0 assert output["parameters"]["sigma"] == 0.05 - output = mp_prerelax_job(atoms, bandgap=0) + output = mp_metagga_prerelax_job(atoms, bandgap=0) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "pbesol" assert output["parameters"]["ediffg"] == -0.05 @@ -373,7 +377,7 @@ def test_mp_prerelax_job(tmp_path, monkeypatch): assert output["parameters"]["ismear"] == 2 assert output["parameters"]["sigma"] == 0.2 - output = mp_prerelax_job(atoms, bandgap=100) + output = mp_metagga_prerelax_job(atoms, bandgap=100) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "pbesol" assert output["parameters"]["ediffg"] == -0.05 @@ -383,12 +387,12 @@ def test_mp_prerelax_job(tmp_path, monkeypatch): assert output["parameters"]["sigma"] == 0.05 -def test_mp_relax_job(tmp_path, monkeypatch): +def test_mp_metagga_relax_job(tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) atoms = bulk("Al") - output = mp_relax_job(atoms) + output = mp_metagga_relax_job(atoms) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "r2scan" assert output["parameters"]["ediffg"] == -0.02 @@ -397,7 +401,7 @@ def test_mp_relax_job(tmp_path, monkeypatch): assert output["parameters"]["ismear"] == 0 assert output["parameters"]["sigma"] == 0.05 - output = mp_relax_job(atoms, bandgap=0) + output = mp_metagga_relax_job(atoms, bandgap=0) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "r2scan" assert output["parameters"]["ediffg"] == -0.02 @@ -406,7 +410,7 @@ def test_mp_relax_job(tmp_path, monkeypatch): assert output["parameters"]["ismear"] == 2 assert output["parameters"]["sigma"] == 0.2 - output = mp_relax_job(atoms, bandgap=100) + output = mp_metagga_relax_job(atoms, bandgap=100) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "r2scan" assert output["parameters"]["ediffg"] == -0.02 From a9f0b1e6a5d5729a5ec5531e525d39ad66723c1d Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 23:01:45 -0800 Subject: [PATCH 07/33] fix --- src/quacc/recipes/vasp/mp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index a56a6c23d4..c9ef138836 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -2,7 +2,6 @@ Materials Project-compatible recipes. This set of recipes is meant to be compatible with the Materials Project -Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801 !!! Info @@ -45,6 +44,8 @@ def mp_metagga_prerelax_job( Function to pre-relax a structure with Materials Project settings. By default, this uses a PBEsol pre-relax step. + Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801 + Parameters ---------- atoms @@ -92,6 +93,8 @@ def mp_metagga_relax_job( Function to relax a structure with Materials Project settings. By default, this uses an r2SCAN relax step. + Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801 + Parameters ---------- atoms @@ -143,6 +146,8 @@ def mp_relax_flow( - name: "mp_metagga_relax_job" - job: [quacc.recipes.vasp.mp.mp_metagga_relax_job][] + Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801 + Parameters ---------- atoms From b67a94947b19677ad7833ab251d5f8ce8c6b67d7 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 23:02:23 -0800 Subject: [PATCH 08/33] fix --- src/quacc/recipes/vasp/mp.py | 6 +++--- src/quacc/schemas/_aliases/vasp.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index c9ef138836..aedbf7fb70 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -30,7 +30,7 @@ from ase.atoms import Atoms - from quacc.schemas._aliases.vasp import MPRelaxFlowSchema, VaspSchema + from quacc.schemas._aliases.vasp import MPMetaGGARelaxFlowSchema, VaspSchema @job @@ -134,7 +134,7 @@ def mp_relax_flow( atoms: Atoms, job_params: dict[str, dict[str, Any]] | None = None, job_decorators: dict[str, Callable | None] | None = None, -) -> MPRelaxFlowSchema: +) -> MPMetaGGARelaxFlowSchema: """ Workflow consisting of: @@ -161,7 +161,7 @@ def mp_relax_flow( Returns ------- - MPRelaxFlowSchema + MPMetaGGARelaxFlowSchema Dictionary of results. See the type-hint for the data structure. """ mp_metagga_prerelax_job_, mp_metagga_relax_job_ = customize_funcs( diff --git a/src/quacc/schemas/_aliases/vasp.py b/src/quacc/schemas/_aliases/vasp.py index 094075cb20..0bba8c43e6 100644 --- a/src/quacc/schemas/_aliases/vasp.py +++ b/src/quacc/schemas/_aliases/vasp.py @@ -53,8 +53,8 @@ class DoubleRelaxSchema(VaspSchema): relax1: VaspSchema -class MPRelaxFlowSchema(VaspSchema): - """Type hint associated with the MP relaxation flows.""" +class MPMetaGGARelaxFlowSchema(VaspSchema): + """Type hint associated with the MP meta-GGA relaxation flows.""" prerelax: VaspSchema From 5b64b243237ba9f558b66f4bf83cdb9e2badfbb7 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 23:07:30 -0800 Subject: [PATCH 09/33] fix --- src/quacc/calculators/vasp/params.py | 3 ++- tests/core/calculators/vasp/test_vasp.py | 28 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index bc95bfb7f2..afd42b133d 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -369,10 +369,11 @@ def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms | None = None) -> d """ structure = AseAtomsAdaptor.get_structure(atoms) pmg_input_set = dict_set(structure=structure) + incar_dict = {k.lower(): v for k, v in pmg_input_set.incar.items()} kpoints_dict = pmg_input_set.kpoints.as_dict() potcar_symbols = pmg_input_set.potcar_symbols potcar_setups = {symbol.split("_")[0]: symbol for symbol in potcar_symbols} - return pmg_input_set.incar | { + return incar_dict | { "kpts": kpoints_dict["kpoints"][0], "gamma": kpoints_dict["generation_style"] == "Gamma", "setups": potcar_setups, diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py index 2d24bac29a..a65e60ffd2 100644 --- a/tests/core/calculators/vasp/test_vasp.py +++ b/tests/core/calculators/vasp/test_vasp.py @@ -9,6 +9,7 @@ from ase.calculators.vasp import Vasp as Vasp_ from ase.constraints import FixAtoms, FixBondLength from ase.io import read +from pymatgen.io.vasp.sets import MPRelaxSet from quacc import SETTINGS from quacc.calculators.vasp import Vasp, presets @@ -821,3 +822,30 @@ def test_preset_override(): calc = Vasp(atoms, preset="BulkSet", efermi=None) assert calc.parameters.get("efermi") is None + + +def test_pmg_input_set(): + atoms = bulk("Cu") + calc = Vasp(atoms, pmg_input_set=MPRelaxSet, incar_copilot="off") + assert calc.parameters == { + "algo": "Fast", + "ediff": 5e-05, + "encut": 520, + "ibrion": 2, + "isif": 3, + "ismear": -5, + "ispin": 2, + "lasph": True, + "lorbit": 11, + "lreal": "Auto", + "lwave": False, + "nelm": 100, + "nsw": 99, + "prec": "Accurate", + "sigma": 0.05, + "magmom": [0.6], + "lmaxmix": 4, + "kpts": [11, 11, 11], + "gamma": True, + "setups": {"Cu": "Cu_pv"}, + } From 1d5e0f31bb2951feec0167145c57589e24434ff1 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 07:09:33 +0000 Subject: [PATCH 10/33] refactor: autofix issues in 1 file Resolved issues in src/quacc/recipes/vasp/mp.py with DeepSource Autofix --- src/quacc/recipes/vasp/mp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index aedbf7fb70..2dc22f88e0 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -17,8 +17,6 @@ from functools import partial from pathlib import Path from typing import TYPE_CHECKING - -import numpy as np from pymatgen.io.vasp.sets import MPScanRelaxSet from quacc import flow, job From b4c15786631449bddc3edaddaad0c9e857639fa1 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 07:09:48 +0000 Subject: [PATCH 11/33] style: format code with Black, isort and Prettier This commit fixes the style issues introduced in 1d5e0f3 according to the output from Black, isort and Prettier. Details: https://github.com/Quantum-Accelerators/quacc/pull/1649 --- src/quacc/recipes/vasp/mp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 2dc22f88e0..eb2f0e25aa 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -17,6 +17,7 @@ from functools import partial from pathlib import Path from typing import TYPE_CHECKING + from pymatgen.io.vasp.sets import MPScanRelaxSet from quacc import flow, job From 19e91e759367cfaac24f3a31b07d58894ed270d3 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 23:28:13 -0800 Subject: [PATCH 12/33] fix --- CHANGELOG.md | 2 +- docs/dev/recipes/flows.md | 2 +- docs/user/recipes/recipes_list.md | 2 +- src/quacc/recipes/vasp/mp.py | 2 +- .../recipes/vasp_recipes/mocked/test_vasp_recipes.py | 10 +++++----- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35f12f6a50..1e6c6d08a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -439,7 +439,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - VASP: Fixed a scenario where SIGMA was set to 0.05 if the user provided SIGMA > 0.05. This was supposed to happen when ISMEAR = 0 but was previously done when ISMEAR = -5, which is not influenced by SIGMA. -- Fixed `mp_relax_flow` to use a `#!Python @flow` decorator instead of `#!Python @job` +- Fixed `mp_metagga_relax_flow` to use a `#!Python @flow` decorator instead of `#!Python @job` - Fixed the Q-Chem Quasi-IRC job to run as one `#!Python @job` instead of two. ## [0.2.3] diff --git a/docs/dev/recipes/flows.md b/docs/dev/recipes/flows.md index e90675d0f3..b3e6d164de 100644 --- a/docs/dev/recipes/flows.md +++ b/docs/dev/recipes/flows.md @@ -12,7 +12,7 @@ A flow is a Python function decorated by `#!Python @flow` that contains a collec ### Production Example -A simple, representative flow can be found in [quacc.recipes.vasp.mp.mp_relax_flow][]. +A simple, representative flow can be found in [quacc.recipes.vasp.mp.mp_metagga_relax_flow][]. !!! Note diff --git a/docs/user/recipes/recipes_list.md b/docs/user/recipes/recipes_list.md index 76ccb17d3e..2255a14eae 100644 --- a/docs/user/recipes/recipes_list.md +++ b/docs/user/recipes/recipes_list.md @@ -238,7 +238,7 @@ The list of available quacc recipes is shown below. The "Req'd Extras" column sp | VASP Slab to Adsorbates | `#!Python @flow` | [quacc.recipes.vasp.slabs.slab_to_ads_flow][] | | | VASP MP Prerelax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | | VASP MP Relax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | -| VASP MP Relax Workflow | `#!Python @flow` | [quacc.recipes.vasp.mp.mp_relax_flow][] | | +| VASP MP Relax Workflow | `#!Python @flow` | [quacc.recipes.vasp.mp.mp_metagga_relax_flow][] | | | VASP QMOF Relax | `#!Python @job` | [quacc.recipes.vasp.qmof.qmof_relax_job][] | | diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index aedbf7fb70..5358030786 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -130,7 +130,7 @@ def mp_metagga_relax_job( @flow -def mp_relax_flow( +def mp_metagga_relax_flow( atoms: Atoms, job_params: dict[str, dict[str, Any]] | None = None, job_decorators: dict[str, Callable | None] | None = None, 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 5c38297e63..9a3f5b5b9f 100644 --- a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py +++ b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py @@ -5,8 +5,8 @@ from quacc.recipes.vasp.core import double_relax_job, relax_job, static_job from quacc.recipes.vasp.mp import ( mp_metagga_prerelax_job, + mp_metagga_relax_flow, mp_metagga_relax_job, - mp_relax_flow, ) from quacc.recipes.vasp.qmof import qmof_relax_job from quacc.recipes.vasp.slabs import bulk_to_slabs_flow @@ -420,12 +420,12 @@ def test_mp_metagga_relax_job(tmp_path, monkeypatch): assert output["parameters"]["sigma"] == 0.05 -def test_mp_relax_flow(tmp_path, monkeypatch): +def test_mp_metagga_relax_flow(tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) atoms = bulk("Al") - output = mp_relax_flow(atoms) + output = mp_metagga_relax_flow(atoms) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "r2scan" assert output["parameters"]["ediffg"] == -0.02 @@ -437,7 +437,7 @@ def test_mp_relax_flow(tmp_path, monkeypatch): assert output["prerelax"]["parameters"]["ismear"] == 0 atoms = bulk("C") - output = mp_relax_flow(atoms) + output = mp_metagga_relax_flow(atoms) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "r2scan" assert output["parameters"]["ediffg"] == -0.02 @@ -449,7 +449,7 @@ def test_mp_relax_flow(tmp_path, monkeypatch): atoms = molecule("O2") atoms.center(vacuum=10) atoms.pbc = True - output = mp_relax_flow(atoms) + output = mp_metagga_relax_flow(atoms) assert output["nsites"] == len(atoms) assert output["parameters"]["xc"] == "r2scan" assert output["parameters"]["ediffg"] == -0.02 From 312f12811398b40b304b13858091ed2b36082ebb Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 23:28:43 -0800 Subject: [PATCH 13/33] fix --- docs/user/recipes/recipes_list.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/user/recipes/recipes_list.md b/docs/user/recipes/recipes_list.md index 2255a14eae..bf6441e677 100644 --- a/docs/user/recipes/recipes_list.md +++ b/docs/user/recipes/recipes_list.md @@ -227,18 +227,18 @@ The list of available quacc recipes is shown below. The "Req'd Extras" column sp
-| Name | Decorator | Documentation | Req'd Extras | -| ----------------------- | ---------------- | ----------------------------------------------- | ------------ | -| VASP Static | `#!Python @job` | [quacc.recipes.vasp.core.static_job][] | | -| VASP Relax | `#!Python @job` | [quacc.recipes.vasp.core.relax_job][] | | -| VASP Double Relax | `#!Python @job` | [quacc.recipes.vasp.core.double_relax_job][] | | -| VASP Slab Static | `#!Python @job` | [quacc.recipes.vasp.slabs.static_job][] | | -| VASP Slab Relax | `#!Python @job` | [quacc.recipes.vasp.slabs.relax_job][] | | -| VASP Bulk to Slabs | `#!Python @flow` | [quacc.recipes.vasp.slabs.bulk_to_slabs_flow][] | | -| VASP Slab to Adsorbates | `#!Python @flow` | [quacc.recipes.vasp.slabs.slab_to_ads_flow][] | | -| VASP MP Prerelax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | -| VASP MP Relax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | -| VASP MP Relax Workflow | `#!Python @flow` | [quacc.recipes.vasp.mp.mp_metagga_relax_flow][] | | -| VASP QMOF Relax | `#!Python @job` | [quacc.recipes.vasp.qmof.qmof_relax_job][] | | +| Name | Decorator | Documentation | Req'd Extras | +| ------------------------------- | ---------------- | ----------------------------------------------- | ------------ | +| VASP Static | `#!Python @job` | [quacc.recipes.vasp.core.static_job][] | | +| VASP Relax | `#!Python @job` | [quacc.recipes.vasp.core.relax_job][] | | +| VASP Double Relax | `#!Python @job` | [quacc.recipes.vasp.core.double_relax_job][] | | +| VASP Slab Static | `#!Python @job` | [quacc.recipes.vasp.slabs.static_job][] | | +| VASP Slab Relax | `#!Python @job` | [quacc.recipes.vasp.slabs.relax_job][] | | +| VASP Bulk to Slabs | `#!Python @flow` | [quacc.recipes.vasp.slabs.bulk_to_slabs_flow][] | | +| VASP Slab to Adsorbates | `#!Python @flow` | [quacc.recipes.vasp.slabs.slab_to_ads_flow][] | | +| VASP MP Meta-GGA Prerelax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | +| VASP MP Meta-GGA Relax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | +| VASP MP Meta-GGA Relax Workflow | `#!Python @flow` | [quacc.recipes.vasp.mp.mp_metagga_relax_flow][] | | +| VASP QMOF Relax | `#!Python @job` | [quacc.recipes.vasp.qmof.qmof_relax_job][] | |
From e76d88f6e3d73b703eabdb3fcbd31907559bf5f7 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 31 Jan 2024 23:28:58 -0800 Subject: [PATCH 14/33] fix --- src/quacc/recipes/vasp/mp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 9a6a3aca36..f31ed1ff26 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -76,7 +76,7 @@ def mp_metagga_prerelax_job( atoms, calc_defaults=calc_defaults, calc_swaps=calc_kwargs, - additional_fields={"name": "MP Pre-Relax"}, + additional_fields={"name": "MP Meta-GGA Pre-Relax"}, copy_files=copy_files, ) @@ -123,7 +123,7 @@ def mp_metagga_relax_job( atoms, calc_defaults=calc_defaults, calc_swaps=calc_kwargs, - additional_fields={"name": "MP Relax"}, + additional_fields={"name": "MP Meta-GGA Relax"}, copy_files=copy_files, ) From a21c4076364fbc2c3f908ee30d1682a4fc55a6f3 Mon Sep 17 00:00:00 2001 From: Andrew-S-Rosen Date: Thu, 1 Feb 2024 08:57:02 -0800 Subject: [PATCH 15/33] fix --- tests/core/calculators/vasp/test_vasp.py | 36 +++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py index a65e60ffd2..264d3b41be 100644 --- a/tests/core/calculators/vasp/test_vasp.py +++ b/tests/core/calculators/vasp/test_vasp.py @@ -9,7 +9,7 @@ from ase.calculators.vasp import Vasp as Vasp_ from ase.constraints import FixAtoms, FixBondLength from ase.io import read -from pymatgen.io.vasp.sets import MPRelaxSet +from pymatgen.io.vasp.sets import MPRelaxSet, MPScanRelaxSet from quacc import SETTINGS from quacc.calculators.vasp import Vasp, presets @@ -849,3 +849,37 @@ def test_pmg_input_set(): "gamma": True, "setups": {"Cu": "Cu_pv"}, } + + +def test_pmg_input_set2(): + atoms = bulk("Fe") * (2, 1, 1) + atoms[0].symbol = "O" + calc = Vasp(atoms, pmg_input_set=MPRelaxSet, incar_copilot="off") + assert calc.parameters == { + "algo": "Fast", + "ediff": 0.0001, + "encut": 520, + "ibrion": 2, + "isif": 3, + "ismear": -5, + "ispin": 2, + "lasph": True, + "ldau": True, + "ldauj": [0, 0], + "ldaul": [2, 0], + "ldautype": 2, + "ldauu": [5.3, 0], + "ldauprint": 1, + "lorbit": 11, + "lreal": "Auto", + "lwave": False, + "nelm": 100, + "nsw": 99, + "prec": "Accurate", + "sigma": 0.05, + "magmom": [2.3, 2.3], + "lmaxmix": 4, + "kpts": [5, 11, 11], + "gamma": True, + "setups": {"Fe": "Fe_pv", "O": "O"}, + } From 26c298bee505e3dcca950c21078313af6bdd2f43 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 18:23:17 +0000 Subject: [PATCH 16/33] refactor: autofix issues in 1 file Resolved issues in tests/core/calculators/vasp/test_vasp.py with DeepSource Autofix --- tests/core/calculators/vasp/test_vasp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py index 264d3b41be..53af38677c 100644 --- a/tests/core/calculators/vasp/test_vasp.py +++ b/tests/core/calculators/vasp/test_vasp.py @@ -9,7 +9,7 @@ from ase.calculators.vasp import Vasp as Vasp_ from ase.constraints import FixAtoms, FixBondLength from ase.io import read -from pymatgen.io.vasp.sets import MPRelaxSet, MPScanRelaxSet +from pymatgen.io.vasp.sets import MPRelaxSet from quacc import SETTINGS from quacc.calculators.vasp import Vasp, presets From 25a68f110d29d3114149dd6b1b68df4957ab5d29 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 10:38:39 -0800 Subject: [PATCH 17/33] fix --- tests/core/calculators/vasp/test_vasp.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py index 264d3b41be..77dc378863 100644 --- a/tests/core/calculators/vasp/test_vasp.py +++ b/tests/core/calculators/vasp/test_vasp.py @@ -70,7 +70,7 @@ def test_presets(): assert calc.exp_params["ediff"] == 1e-5 assert calc.float_params["encut"] == 450 - calc = Vasp(atoms, xc="scan", preset="MPScanSet") + calc = Vasp(atoms, xc="scan", pmg_input_set=MPScanRelaxSet) assert calc.xc.lower() == "scan" assert calc.string_params["algo"] == "all" assert calc.exp_params["ediff"] == 1e-5 @@ -187,7 +187,7 @@ def test_magmoms(atoms_mag, atoms_nomag, atoms_nospin): atoms = bulk("Cu") * (2, 2, 1) atoms[-1].symbol = "Fe" - calc = Vasp(atoms, preset="MPScanSet") + calc = Vasp(atoms, pmg_input_set=MPScanRelaxSet) atoms.calc = calc assert atoms.get_initial_magnetic_moments().tolist() == [1.0] * (len(atoms) - 1) + [ 5.0 @@ -196,7 +196,7 @@ def test_magmoms(atoms_mag, atoms_nomag, atoms_nospin): atoms = bulk("Cu") * (2, 2, 1) atoms[-1].symbol = "Fe" atoms.set_initial_magnetic_moments([3.14] * (len(atoms) - 1) + [1.0]) - calc = Vasp(atoms, preset="BulkSet") + calc = Vasp(atoms, pmg_input_set=MPScanRelaxSet) atoms.calc = calc assert atoms.get_initial_magnetic_moments().tolist() == [3.14] * ( len(atoms) - 1 @@ -708,7 +708,7 @@ def test_setups(): assert calc.parameters["setups"]["Cu"] == "" atoms = bulk("Cu") - calc = Vasp(atoms, preset="MPScanSet") + calc = Vasp(atoms, pmg_input_set=MPScanRelaxSet) assert calc.parameters["setups"]["Cu"] == "_pv" atoms = bulk("Cu") @@ -720,7 +720,7 @@ def test_setups(): assert calc.parameters["setups"]["Cu"] == "" atoms = bulk("Cu") - calc = Vasp(atoms, setups="minimal", preset="MPScanSet") + calc = Vasp(atoms, setups="minimal", pmg_input_set=MPScanRelaxSet) assert isinstance(calc.parameters["setups"], str) assert calc.parameters["setups"] == "minimal" From 8274881153f31ec3d9d404011178a063b5588814 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 10:39:47 -0800 Subject: [PATCH 18/33] fix --- tests/core/calculators/vasp/test_vasp.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py index 77dc378863..7bea16bbe5 100644 --- a/tests/core/calculators/vasp/test_vasp.py +++ b/tests/core/calculators/vasp/test_vasp.py @@ -719,6 +719,11 @@ def test_setups(): calc = Vasp(atoms, setups="setups_pbe54.yaml", preset="BulkSet") assert calc.parameters["setups"]["Cu"] == "" + atoms = bulk("Cu") + calc = Vasp(atoms, setups="minimal", preset="BulkSet") + assert isinstance(calc.parameters["setups"], str) + assert calc.parameters["setups"] == "minimal" + atoms = bulk("Cu") calc = Vasp(atoms, setups="minimal", pmg_input_set=MPScanRelaxSet) assert isinstance(calc.parameters["setups"], str) From 24c08e52b4ac743545feb0f3e9ef36e8077979c9 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 10:41:30 -0800 Subject: [PATCH 19/33] fix --- tests/core/calculators/vasp/test_vasp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py index b28d046dd0..7bea16bbe5 100644 --- a/tests/core/calculators/vasp/test_vasp.py +++ b/tests/core/calculators/vasp/test_vasp.py @@ -9,7 +9,7 @@ from ase.calculators.vasp import Vasp as Vasp_ from ase.constraints import FixAtoms, FixBondLength from ase.io import read -from pymatgen.io.vasp.sets import MPRelaxSet +from pymatgen.io.vasp.sets import MPRelaxSet, MPScanRelaxSet from quacc import SETTINGS from quacc.calculators.vasp import Vasp, presets From fd8054668af212ff47b1e96c436a62284c24228c Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 10:51:59 -0800 Subject: [PATCH 20/33] fix --- src/quacc/calculators/vasp/params.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index afd42b133d..efca6e42b6 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -1,4 +1,5 @@ """Parameter-related utilities for the Vasp calculator.""" + from __future__ import annotations import logging @@ -234,9 +235,11 @@ def get_param_swaps( return ( calc.parameters if incar_copilot == "aggressive" - else calc.parameters | user_calc_params - if incar_copilot == "on" - else user_calc_params + else ( + calc.parameters | user_calc_params + if incar_copilot == "on" + else user_calc_params + ) ) @@ -370,11 +373,15 @@ def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms | None = None) -> d structure = AseAtomsAdaptor.get_structure(atoms) pmg_input_set = dict_set(structure=structure) incar_dict = {k.lower(): v for k, v in pmg_input_set.incar.items()} - kpoints_dict = pmg_input_set.kpoints.as_dict() potcar_symbols = pmg_input_set.potcar_symbols potcar_setups = {symbol.split("_")[0]: symbol for symbol in potcar_symbols} - return incar_dict | { - "kpts": kpoints_dict["kpoints"][0], - "gamma": kpoints_dict["generation_style"] == "Gamma", - "setups": potcar_setups, - } + full_input_params = incar_dict | {"setups": potcar_setups} + pmg_kpts = pmg_input_set.kpoints + if pmg_kpts is not None: + kpoints_dict = pmg_input_set.kpoints.as_dict() + full_input_params = incar_dict | { + "kpts": kpoints_dict["kpoints"][0], + "gamma": kpoints_dict["generation_style"] == "Gamma", + } + + return full_input_params From 7c201f7d0a7355a216b1ac6cde1074adb23759fa Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 15:35:59 -0800 Subject: [PATCH 21/33] fi --- src/quacc/calculators/vasp/params.py | 31 ++++++++++++---- src/quacc/calculators/vasp/vasp.py | 19 +++++----- src/quacc/recipes/vasp/mp.py | 13 ++++--- tests/core/calculators/vasp/test_vasp.py | 18 +++++----- .../vasp_recipes/mocked/test_vasp_recipes.py | 35 +++++++++++++------ 5 files changed, 80 insertions(+), 36 deletions(-) diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index efca6e42b6..84af1f48be 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -353,7 +353,7 @@ def set_pmg_kpts( return user_calc_params -def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms | None = None) -> dict: +def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms) -> tuple[dict, Atoms]: """ Convert a Pymatgen VASP input set into an ASE-compatible set of calculator parameters. @@ -362,26 +362,45 @@ def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms | None = None) -> d ---------- dict_set The Pymatgen VASP input set. - atoms | None + atoms The input atoms. Returns ------- dict The ASE-compatible set of calculator parameters. + Atoms + The input atoms to match the pymatgen input set. """ structure = AseAtomsAdaptor.get_structure(atoms) - pmg_input_set = dict_set(structure=structure) + pmg_input_set = dict_set(structure=structure, sort_structure=False) incar_dict = {k.lower(): v for k, v in pmg_input_set.incar.items()} + potcar_symbols = pmg_input_set.potcar_symbols potcar_setups = {symbol.split("_")[0]: symbol for symbol in potcar_symbols} - full_input_params = incar_dict | {"setups": potcar_setups} + potcar_functional = pmg_input_set.potcar_functional.split("_")[0] + if "PBE" in potcar_functional: + pp = "PBE" + elif "PW91" in potcar_functional: + pp = "PW91" + elif "LDA" in potcar_functional or "Perdew-Zunger81" in potcar_functional: + pp = "LDA" + else: + raise ValueError(f"Unknown POTCAR functional: {potcar_functional}") + for k, v in potcar_setups.items(): + if k in v: + potcar_setups[k] = v.split(k)[-1] + + full_input_params = incar_dict | {"setups": potcar_setups, "pp": pp} + pmg_kpts = pmg_input_set.kpoints if pmg_kpts is not None: kpoints_dict = pmg_input_set.kpoints.as_dict() - full_input_params = incar_dict | { + full_input_params |= { "kpts": kpoints_dict["kpoints"][0], "gamma": kpoints_dict["generation_style"] == "Gamma", } - return full_input_params + return full_input_params, AseAtomsAdaptor().get_atoms( + pmg_input_set.poscar.structure + ) diff --git a/src/quacc/calculators/vasp/vasp.py b/src/quacc/calculators/vasp/vasp.py index dfd6aaacaa..47ecab333d 100644 --- a/src/quacc/calculators/vasp/vasp.py +++ b/src/quacc/calculators/vasp/vasp.py @@ -46,9 +46,11 @@ def __init__( preset_mag_default: float | None = None, mag_cutoff: None | float = None, elemental_magmoms: dict[str, float] | None = None, - pmg_kpts: dict[Literal["line_density", "kppvol", "kppa"], float] - | dict[Literal["length_densities"], list[float]] - | None = None, + pmg_kpts: ( + dict[Literal["line_density", "kppvol", "kppa"], float] + | dict[Literal["length_densities"], list[float]] + | None + ) = None, auto_dipole: bool | None = None, pmg_input_set: DictSet | None = None, **kwargs, @@ -214,11 +216,12 @@ def _cleanup_params(self) -> None: raise ValueError(msg) # Get Pymatgen VASP input set parameters - pmg_calc_params = ( - get_pmg_input_set_params(self.pmg_input_set, atoms=self.input_atoms) - if self.pmg_input_set - else {} - ) + if self.pmg_input_set: + pmg_calc_params, self.input_atoms = get_pmg_input_set_params( + self.pmg_input_set, self.input_atoms + ) + else: + pmg_calc_params = {} # Get user-defined preset parameters for the calculator if self.preset: diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index f31ed1ff26..887d8d6198 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -35,7 +35,7 @@ @job def mp_metagga_prerelax_job( atoms: Atoms, - bandgap: float | None = None, + bandgap: float = 0.0, copy_files: str | Path | list[str | Path] | None = None, **calc_kwargs, ) -> VaspSchema: @@ -68,9 +68,12 @@ def mp_metagga_prerelax_job( calc_defaults = { "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), "ediffg": -0.05, - "xc": "pbesol", - "lwave": True, + "gga": "PS", + "laechg": False, "lcharg": True, + "lvtot": False, + "lwave": True, + "metagga": None, } return base_fn( atoms, @@ -84,7 +87,7 @@ def mp_metagga_prerelax_job( @job def mp_metagga_relax_job( atoms: Atoms, - bandgap: float | None = None, + bandgap: float = 0.0, copy_files: str | Path | list[str | Path] | None = None, **calc_kwargs, ) -> VaspSchema: @@ -116,7 +119,9 @@ def mp_metagga_relax_job( calc_defaults = { "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), + "laechg": False, "lcharg": True, + "lvtot": False, "lwave": True, } return base_fn( diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py index 7bea16bbe5..f074368285 100644 --- a/tests/core/calculators/vasp/test_vasp.py +++ b/tests/core/calculators/vasp/test_vasp.py @@ -72,7 +72,7 @@ def test_presets(): calc = Vasp(atoms, xc="scan", pmg_input_set=MPScanRelaxSet) assert calc.xc.lower() == "scan" - assert calc.string_params["algo"] == "all" + assert calc.string_params["algo"].lower() == "all" assert calc.exp_params["ediff"] == 1e-5 @@ -165,6 +165,7 @@ def test_magmoms(atoms_mag, atoms_nomag, atoms_nospin): atoms[-1].symbol = "Fe" calc = Vasp(atoms, preset="BulkSet") atoms.calc = calc + assert atoms.get_chemical_symbols() == ["Cu", "Cu", "Cu", "Fe"] assert atoms.get_initial_magnetic_moments().tolist() == [2.0] * (len(atoms) - 1) + [ 5.0 ] @@ -189,9 +190,8 @@ def test_magmoms(atoms_mag, atoms_nomag, atoms_nospin): atoms[-1].symbol = "Fe" calc = Vasp(atoms, pmg_input_set=MPScanRelaxSet) atoms.calc = calc - assert atoms.get_initial_magnetic_moments().tolist() == [1.0] * (len(atoms) - 1) + [ - 5.0 - ] + assert atoms.get_chemical_symbols() == ["Cu", "Cu", "Cu", "Fe"] + assert calc.parameters["magmom"] == [0.6, 0.6, 0.6, 5.0] atoms = bulk("Cu") * (2, 2, 1) atoms[-1].symbol = "Fe" @@ -846,13 +846,14 @@ def test_pmg_input_set(): "lwave": False, "nelm": 100, "nsw": 99, + "pp": "PBE", "prec": "Accurate", "sigma": 0.05, "magmom": [0.6], "lmaxmix": 4, "kpts": [11, 11, 11], "gamma": True, - "setups": {"Cu": "Cu_pv"}, + "setups": {"Cu": "_pv"}, } @@ -871,20 +872,21 @@ def test_pmg_input_set2(): "lasph": True, "ldau": True, "ldauj": [0, 0], - "ldaul": [2, 0], + "ldaul": [0, 2.0], "ldautype": 2, - "ldauu": [5.3, 0], + "ldauu": [0, 5.3], "ldauprint": 1, "lorbit": 11, "lreal": "Auto", "lwave": False, "nelm": 100, "nsw": 99, + "pp": "PBE", "prec": "Accurate", "sigma": 0.05, "magmom": [2.3, 2.3], "lmaxmix": 4, "kpts": [5, 11, 11], "gamma": True, - "setups": {"Fe": "Fe_pv", "O": "O"}, + "setups": {"Fe": "_pv", "O": ""}, } 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 9a3f5b5b9f..fb2e9346eb 100644 --- a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py +++ b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py @@ -361,30 +361,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"]["xc"] == "pbesol" + 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"] output = mp_metagga_prerelax_job(atoms, bandgap=0) assert output["nsites"] == len(atoms) - assert output["parameters"]["xc"] == "pbesol" + 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"]["pp"] == "PBE" + assert "metagga" not in output["parameters"] output = mp_metagga_prerelax_job(atoms, bandgap=100) assert output["nsites"] == len(atoms) - assert output["parameters"]["xc"] == "pbesol" + assert output["parameters"]["gga"] == "{S}" 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"]["sigma"] == 0.05 + assert output["parameters"]["pp"] == "PBE" + assert "metagga" not in output["parameters"] def test_mp_metagga_relax_job(tmp_path, monkeypatch): @@ -394,30 +400,33 @@ def test_mp_metagga_relax_job(tmp_path, monkeypatch): output = mp_metagga_relax_job(atoms) assert output["nsites"] == len(atoms) - assert output["parameters"]["xc"] == "r2scan" + 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" output = mp_metagga_relax_job(atoms, bandgap=0) assert output["nsites"] == len(atoms) - assert output["parameters"]["xc"] == "r2scan" + 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"]["pp"] == "PBE" output = mp_metagga_relax_job(atoms, bandgap=100) assert output["nsites"] == len(atoms) - assert output["parameters"]["xc"] == "r2scan" + assert output["parameters"]["metagga"].lower() == "r2scan" 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"]["sigma"] == 0.05 + assert output["parameters"]["pp"] == "PBE" def test_mp_metagga_relax_flow(tmp_path, monkeypatch): @@ -427,33 +436,39 @@ def test_mp_metagga_relax_flow(tmp_path, monkeypatch): output = mp_metagga_relax_flow(atoms) assert output["nsites"] == len(atoms) - assert output["parameters"]["xc"] == "r2scan" + assert output["parameters"]["metagga"].lower() == "r2scan" assert output["parameters"]["ediffg"] == -0.02 assert output["parameters"]["encut"] == 680 assert output["parameters"]["ismear"] == 2 assert output["parameters"]["sigma"] == 0.2 assert output["parameters"]["kspacing"] == 0.22 - assert output["prerelax"]["parameters"]["xc"] == "pbesol" + assert output["parameters"]["pp"] == "PBE" + assert output["prerelax"]["parameters"]["gga"] == "PS" assert output["prerelax"]["parameters"]["ismear"] == 0 + assert output["prerelax"]["parameters"]["pp"] == "PBE" atoms = bulk("C") output = mp_metagga_relax_flow(atoms) assert output["nsites"] == len(atoms) - assert output["parameters"]["xc"] == "r2scan" + assert output["parameters"]["metagga"].lower() == "r2scan" assert output["parameters"]["ediffg"] == -0.02 assert output["parameters"]["encut"] == 680 assert output["parameters"]["ismear"] == -5 assert output["parameters"]["kspacing"] == pytest.approx(0.28329488761304206) + assert output["parameters"]["pp"] == "PBE" assert output["prerelax"]["parameters"]["ismear"] == 0 + assert output["prerelax"]["parameters"]["pp"] == "PBE" atoms = molecule("O2") atoms.center(vacuum=10) atoms.pbc = True output = mp_metagga_relax_flow(atoms) assert output["nsites"] == len(atoms) - assert output["parameters"]["xc"] == "r2scan" + assert output["parameters"]["metagga"].lower() == "r2scan" assert output["parameters"]["ediffg"] == -0.02 assert output["parameters"]["encut"] == 680 assert output["parameters"]["ismear"] == -5 assert output["parameters"]["kspacing"] == pytest.approx(0.28329488761304206) + assert output["parameters"]["pp"] == "PBE" assert output["prerelax"]["parameters"]["ismear"] == 0 + assert output["prerelax"]["parameters"]["pp"] == "PBE" From 0306d81e3413e6b5f55a0030fd086dcce097eb50 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 15:37:15 -0800 Subject: [PATCH 22/33] fix --- tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fb2e9346eb..fb10be6e70 100644 --- a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py +++ b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py @@ -383,7 +383,7 @@ def test_mp_metagga_prerelax_job(tmp_path, monkeypatch): output = mp_metagga_prerelax_job(atoms, bandgap=100) assert output["nsites"] == len(atoms) - assert output["parameters"]["gga"] == "{S}" + assert output["parameters"]["gga"] == "PS" assert output["parameters"]["ediffg"] == -0.05 assert output["parameters"]["encut"] == 680 assert output["parameters"]["kspacing"] == 0.44 From 1c3d04d08353ff4ab5081103f140af1a2b8f148e Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Thu, 8 Feb 2024 15:40:04 -0800 Subject: [PATCH 23/33] Update params.py --- src/quacc/calculators/vasp/params.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index 84af1f48be..5ed0a4b034 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -235,11 +235,9 @@ def get_param_swaps( return ( calc.parameters if incar_copilot == "aggressive" - else ( - calc.parameters | user_calc_params - if incar_copilot == "on" - else user_calc_params - ) + else calc.parameters | user_calc_params + if incar_copilot == "on" + else user_calc_params ) From 22bedd36effef39167d3b9cd26add72280a3a70f Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Thu, 8 Feb 2024 15:41:07 -0800 Subject: [PATCH 24/33] Update params.py --- src/quacc/calculators/vasp/params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index 5ed0a4b034..b0a084be3c 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -376,7 +376,7 @@ def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms) -> tuple[dict, Ato potcar_symbols = pmg_input_set.potcar_symbols potcar_setups = {symbol.split("_")[0]: symbol for symbol in potcar_symbols} - potcar_functional = pmg_input_set.potcar_functional.split("_")[0] + potcar_functional = pmg_input_set.potcar_functional if "PBE" in potcar_functional: pp = "PBE" elif "PW91" in potcar_functional: From ada589cba42bea6c5238a94a490cd46090426888 Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Thu, 8 Feb 2024 15:42:39 -0800 Subject: [PATCH 25/33] Update params.py --- src/quacc/calculators/vasp/params.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index b0a084be3c..d313bda6fe 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -376,6 +376,10 @@ def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms) -> tuple[dict, Ato potcar_symbols = pmg_input_set.potcar_symbols potcar_setups = {symbol.split("_")[0]: symbol for symbol in potcar_symbols} + for k, v in potcar_setups.items(): + if k in v: + potcar_setups[k] = v.split(k)[-1] + potcar_functional = pmg_input_set.potcar_functional if "PBE" in potcar_functional: pp = "PBE" @@ -385,9 +389,6 @@ def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms) -> tuple[dict, Ato pp = "LDA" else: raise ValueError(f"Unknown POTCAR functional: {potcar_functional}") - for k, v in potcar_setups.items(): - if k in v: - potcar_setups[k] = v.split(k)[-1] full_input_params = incar_dict | {"setups": potcar_setups, "pp": pp} From e2ec56b1559ad1cdae7e6ed51457c6845c4c1463 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 16:10:19 -0800 Subject: [PATCH 26/33] fix --- docs/user/recipes/recipes_list.md | 1 + src/quacc/recipes/vasp/mp.py | 88 +++++++++++++++++-- src/quacc/schemas/_aliases/vasp.py | 2 + .../vasp_recipes/mocked/test_vasp_recipes.py | 50 ++++++----- 4 files changed, 111 insertions(+), 30 deletions(-) diff --git a/docs/user/recipes/recipes_list.md b/docs/user/recipes/recipes_list.md index 773882963f..39f251094c 100644 --- a/docs/user/recipes/recipes_list.md +++ b/docs/user/recipes/recipes_list.md @@ -240,6 +240,7 @@ The list of available quacc recipes is shown below. The "Req'd Extras" column sp | VASP Slab to Adsorbates | `#!Python @flow` | [quacc.recipes.vasp.slabs.slab_to_ads_flow][] | | | VASP MP Meta-GGA Prerelax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | | VASP MP Meta-GGA Relax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_relax_job][] | | +| VASP MP Meta-GGA Static | `#!Python @job` | [quacc.recipes.vasp.mp.mp_metagga_static_job][] | | | VASP MP Meta-GGA Relax Workflow | `#!Python @flow` | [quacc.recipes.vasp.mp.mp_metagga_relax_flow][] | | | VASP QMOF Relax | `#!Python @job` | [quacc.recipes.vasp.qmof.qmof_relax_job][] | | diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 887d8d6198..9eee984316 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -70,7 +70,6 @@ def mp_metagga_prerelax_job( "ediffg": -0.05, "gga": "PS", "laechg": False, - "lcharg": True, "lvtot": False, "lwave": True, "metagga": None, @@ -120,7 +119,6 @@ def mp_metagga_relax_job( calc_defaults = { "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), "laechg": False, - "lcharg": True, "lvtot": False, "lwave": True, } @@ -133,6 +131,56 @@ def mp_metagga_relax_job( ) +@job +def mp_metagga_static_job( + atoms: Atoms, + bandgap: float = 0.0, + copy_files: str | Path | list[str | Path] | None = None, + **calc_kwargs, +) -> VaspSchema: + """ + Function to run a static calculation on a structure with Materials Project settings. By default, this uses + an r2SCAN static step. + + Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801 + + Parameters + ---------- + atoms + Atoms object + bandgap + Estimate for the bandgap in eV. + copy_files + File(s) to copy to the runtime directory. If a directory is provided, it will be recursively unpacked. + **calc_kwargs + Dictionary of custom kwargs for the Vasp calculator. Set a value to + `None` to remove a pre-existing key entirely. For a list of available + keys, refer to `ase.calculators.vasp.vasp.Vasp`. + + Returns + ------- + VaspSchema + Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]. + See the type-hint for the data structure. + """ + + calc_defaults = { + "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), + "algo": "fast", + "ismear": -5, + "lreal": False, + "lwave": True, + "nsw": 0, + } + return base_fn( + atoms, + calc_defaults=calc_defaults, + calc_swaps=calc_kwargs, + additional_fields={"name": "MP Meta-GGA Static"}, + copy_files=copy_files, + ) + + @flow def mp_metagga_relax_flow( atoms: Atoms, @@ -150,6 +198,10 @@ def mp_metagga_relax_flow( - name: "mp_metagga_relax_job" - job: [quacc.recipes.vasp.mp.mp_metagga_relax_job][] + 3. MP-compatible static + - name: "mp_metagga_static_job" + - job: [quacc.recipes.vasp.mp.mp_metagga_static_job][] + Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801 Parameters @@ -168,11 +220,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_ = customize_funcs( - ["mp_metagga_prerelax_job", "mp_metagga_relax_job"], - [mp_metagga_prerelax_job, mp_metagga_relax_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 @@ -189,4 +247,18 @@ def mp_metagga_relax_flow( ) relax_results["prerelax"] = prerelax_results - return relax_results + # Run the static + static_results = mp_metagga_static_job_( + relax_results["atoms"], + bandgap=relax_results["output"]["bandgap"], + copy_files=[ + Path(relax_results["dir_name"]) / "CHGCAR", + Path(relax_results["dir_name"]) / "WAVECAR", + ], + ) + + return { + "prerelax": prerelax_results, + "relax": relax_results, + "static": static_results, + } diff --git a/src/quacc/schemas/_aliases/vasp.py b/src/quacc/schemas/_aliases/vasp.py index 0bba8c43e6..1e0f044711 100644 --- a/src/quacc/schemas/_aliases/vasp.py +++ b/src/quacc/schemas/_aliases/vasp.py @@ -57,6 +57,8 @@ class MPMetaGGARelaxFlowSchema(VaspSchema): """Type hint associated with the MP meta-GGA relaxation flows.""" prerelax: VaspSchema + relax: VaspSchema + static: VaspSchema class QMOFRelaxSchema(VaspSchema): 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 fb10be6e70..bf1a7fd14c 100644 --- a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py +++ b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py @@ -435,27 +435,29 @@ def test_mp_metagga_relax_flow(tmp_path, monkeypatch): atoms = bulk("Al") output = mp_metagga_relax_flow(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"]["ismear"] == 2 - assert output["parameters"]["sigma"] == 0.2 - assert output["parameters"]["kspacing"] == 0.22 - assert output["parameters"]["pp"] == "PBE" + assert output["static"]["nsites"] == len(atoms) + 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"]["kspacing"] == 0.22 + assert output["relax"]["parameters"]["pp"] == "PBE" assert output["prerelax"]["parameters"]["gga"] == "PS" assert output["prerelax"]["parameters"]["ismear"] == 0 assert output["prerelax"]["parameters"]["pp"] == "PBE" atoms = bulk("C") output = mp_metagga_relax_flow(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"]["ismear"] == -5 - assert output["parameters"]["kspacing"] == pytest.approx(0.28329488761304206) - assert output["parameters"]["pp"] == "PBE" + assert output["static"]["nsites"] == len(atoms) + 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"]["kspacing"] == pytest.approx( + 0.28329488761304206 + ) + assert output["relax"]["parameters"]["pp"] == "PBE" assert output["prerelax"]["parameters"]["ismear"] == 0 assert output["prerelax"]["parameters"]["pp"] == "PBE" @@ -463,12 +465,16 @@ def test_mp_metagga_relax_flow(tmp_path, monkeypatch): atoms.center(vacuum=10) atoms.pbc = True output = mp_metagga_relax_flow(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"]["ismear"] == -5 - assert output["parameters"]["kspacing"] == pytest.approx(0.28329488761304206) - assert output["parameters"]["pp"] == "PBE" + assert output["static"]["nsites"] == len(atoms) + 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"]["kspacing"] == pytest.approx( + 0.28329488761304206 + ) + assert output["relax"]["parameters"]["pp"] == "PBE" assert output["prerelax"]["parameters"]["ismear"] == 0 assert output["prerelax"]["parameters"]["pp"] == "PBE" From f6d1bb2f7639fea3f8adcfc1b5cbd0c92f141609 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:13:42 +0000 Subject: [PATCH 27/33] style: format code with Black, isort and Prettier This commit fixes the style issues introduced in 2062d52 according to the output from Black, isort and Prettier. Details: https://github.com/Quantum-Accelerators/quacc/pull/1649 --- src/quacc/recipes/vasp/mp.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 9eee984316..6e5f2a2a1c 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -220,17 +220,15 @@ 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 From faab92f1a263a0d28049b16f0bf3fd554c0e2e4f Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 16:33:40 -0800 Subject: [PATCH 28/33] fix reference --- src/quacc/recipes/vasp/mp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 9eee984316..2bbe4fe116 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -142,8 +142,6 @@ def mp_metagga_static_job( Function to run a static calculation on a structure with Materials Project settings. By default, this uses an r2SCAN static step. - Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801 - Parameters ---------- atoms From 9691f90fa45af2484ed3d27812c3ebc9c2480d24 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Thu, 8 Feb 2024 16:38:19 -0800 Subject: [PATCH 29/33] fix --- src/quacc/recipes/vasp/mp.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 2bbe4fe116..df71ce5d3b 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -12,6 +12,7 @@ and up-to-date. This module is a best effort to be used at your own discretion. """ + from __future__ import annotations from functools import partial @@ -66,7 +67,7 @@ def mp_metagga_prerelax_job( """ calc_defaults = { - "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), + "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap, auto_ismear=False), "ediffg": -0.05, "gga": "PS", "laechg": False, @@ -117,7 +118,7 @@ def mp_metagga_relax_job( """ calc_defaults = { - "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), + "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap, auto_ismear=False), "laechg": False, "lvtot": False, "lwave": True, @@ -163,7 +164,7 @@ def mp_metagga_static_job( """ calc_defaults = { - "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap), + "pmg_input_set": partial(MPScanRelaxSet, bandgap=bandgap, auto_ismear=False), "algo": "fast", "ismear": -5, "lreal": False, From a6f412bb3ccb82c48d189b9a61ef36044d911fc1 Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Fri, 16 Feb 2024 06:19:30 -0800 Subject: [PATCH 30/33] Update requirements.txt --- tests/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index 0dc81287db..167e9828df 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -8,5 +8,5 @@ numpy==1.26.3 psutil==5.9.8 pydantic==2.6.1 pydantic-settings==2.1.0 -pymatgen==2024.2.8 +git+https://github.com/materialsproject/pymatgen.git typer[all]==0.9.0 From d9055e8d7a656a30ed5f0e3fdd00973494f2cc58 Mon Sep 17 00:00:00 2001 From: Andrew-S-Rosen Date: Fri, 16 Feb 2024 19:22:54 -0800 Subject: [PATCH 31/33] 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 ) From 0fe941625a43af2542befcf0d01a774302f5c74b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 17 Feb 2024 03:23:20 +0000 Subject: [PATCH 32/33] style: format code with Black, isort and Prettier This commit fixes the style issues introduced in d9055e8 according to the output from Black, isort and Prettier. Details: https://github.com/Quantum-Accelerators/quacc/pull/1649 --- src/quacc/recipes/vasp/mp.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 2e873aba73..0178ef419a 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -219,17 +219,15 @@ 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 From 323805bbf3c6ce941d7ef85e2b1e18c6ab5df81d Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Fri, 16 Feb 2024 19:51:38 -0800 Subject: [PATCH 33/33] fix --- src/quacc/calculators/vasp/params.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py index 8c90d1b701..362a120dd3 100644 --- a/src/quacc/calculators/vasp/params.py +++ b/src/quacc/calculators/vasp/params.py @@ -382,15 +382,7 @@ def get_pmg_input_set_params(dict_set: DictSet, atoms: Atoms) -> tuple[dict, Ato if k in v: potcar_setups[k] = v.split(k)[-1] - potcar_functional = pmg_input_set.potcar_functional - if "PBE" in potcar_functional: - pp = "PBE" - elif "PW91" in potcar_functional: - pp = "PW91" - elif "LDA" in potcar_functional or "Perdew-Zunger81" in potcar_functional: - pp = "LDA" - else: - raise ValueError(f"Unknown POTCAR functional: {potcar_functional}") + pp = pmg_input_set.potcar_functional.split("_")[0] full_input_params = incar_dict | {"setups": potcar_setups, "pp": pp}