Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Pymatgen-style VASP input sets #1649

Merged
merged 44 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a3803be
Support Pymatgen-style VASP input sets
Andrew-S-Rosen Feb 1, 2024
3b86805
fix
Andrew-S-Rosen Feb 1, 2024
9cee0d9
fix
Andrew-S-Rosen Feb 1, 2024
95c8ac4
fix
Andrew-S-Rosen Feb 1, 2024
9798544
fix
Andrew-S-Rosen Feb 1, 2024
ad410b4
rename
Andrew-S-Rosen Feb 1, 2024
a9f0b1e
fix
Andrew-S-Rosen Feb 1, 2024
b67a949
fix
Andrew-S-Rosen Feb 1, 2024
5b64b24
fix
Andrew-S-Rosen Feb 1, 2024
1d5e0f3
refactor: autofix issues in 1 file
deepsource-autofix[bot] Feb 1, 2024
b4c1578
style: format code with Black, isort and Prettier
deepsource-autofix[bot] Feb 1, 2024
19e91e7
fix
Andrew-S-Rosen Feb 1, 2024
d7d82d5
Merge branch 'vaspsets' of github.com:Quantum-Accelerators/quacc into…
Andrew-S-Rosen Feb 1, 2024
312f128
fix
Andrew-S-Rosen Feb 1, 2024
e76d88f
fix
Andrew-S-Rosen Feb 1, 2024
a21c407
fix
Andrew-S-Rosen Feb 1, 2024
16f06e6
Merge branch 'main' into vaspsets
Andrew-S-Rosen Feb 8, 2024
26c298b
refactor: autofix issues in 1 file
deepsource-autofix[bot] Feb 8, 2024
25a68f1
fix
Andrew-S-Rosen Feb 8, 2024
8274881
fix
Andrew-S-Rosen Feb 8, 2024
46eba57
Merge branch 'vaspsets' of github.com:Quantum-Accelerators/quacc into…
Andrew-S-Rosen Feb 8, 2024
24c08e5
fix
Andrew-S-Rosen Feb 8, 2024
8de5639
Merge branch 'main' into vaspsets
Andrew-S-Rosen Feb 8, 2024
fd80546
fix
Andrew-S-Rosen Feb 8, 2024
c6ffbbc
Merge branch 'main' into vaspsets
Andrew-S-Rosen Feb 8, 2024
7c201f7
fi
Andrew-S-Rosen Feb 8, 2024
347e5ec
Merge branch 'vaspsets' of github.com:Quantum-Accelerators/quacc into…
Andrew-S-Rosen Feb 8, 2024
0306d81
fix
Andrew-S-Rosen Feb 8, 2024
1c3d04d
Update params.py
Andrew-S-Rosen Feb 8, 2024
22bedd3
Update params.py
Andrew-S-Rosen Feb 8, 2024
ada589c
Update params.py
Andrew-S-Rosen Feb 8, 2024
e2ec56b
fix
Andrew-S-Rosen Feb 9, 2024
2062d52
Merge branch 'vaspsets' of github.com:Quantum-Accelerators/quacc into…
Andrew-S-Rosen Feb 9, 2024
f6d1bb2
style: format code with Black, isort and Prettier
deepsource-autofix[bot] Feb 9, 2024
faab92f
fix reference
Andrew-S-Rosen Feb 9, 2024
9691f90
fix
Andrew-S-Rosen Feb 9, 2024
63ca1fa
Merge branch 'vaspsets' of github.com:Quantum-Accelerators/quacc into…
Andrew-S-Rosen Feb 9, 2024
2d65b83
Merge branch 'main' into vaspsets
Andrew-S-Rosen Feb 9, 2024
a6f412b
Update requirements.txt
Andrew-S-Rosen Feb 16, 2024
e6f4944
Merge branch 'main' into vaspsets
Andrew-S-Rosen Feb 16, 2024
d9055e8
Update VASP sets
Andrew-S-Rosen Feb 17, 2024
0fe9416
style: format code with Black, isort and Prettier
deepsource-autofix[bot] Feb 17, 2024
323805b
fix
Andrew-S-Rosen Feb 17, 2024
ce913a1
Merge branch 'vaspsets' of github.com:Quantum-Accelerators/quacc into…
Andrew-S-Rosen Feb 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,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]
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/recipes/flows.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 14 additions & 13 deletions docs/user/recipes/recipes_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,19 @@ The list of available quacc recipes is shown below. The "Req'd Extras" column sp

<center>

| 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_relax_job][] | |
| VASP MP Relax | `#!Python @job` | [quacc.recipes.vasp.mp.mp_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][] | |
| 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 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][] | |

</center>
48 changes: 48 additions & 0 deletions src/quacc/calculators/vasp/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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
Expand All @@ -15,6 +16,7 @@
from typing import Any, Literal

from ase.atoms import Atoms
from pymatgen.io.vasp.sets import DictSet

from quacc.utils.kpts import PmgKpts

Expand Down Expand Up @@ -349,3 +351,49 @@ def set_pmg_kpts(
user_calc_params["gamma"] = gamma

return user_calc_params


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.

Parameters
----------
dict_set
The Pymatgen VASP input set.
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, 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}
for k, v in potcar_setups.items():
if k in v:
potcar_setups[k] = v.split(k)[-1]

pp = pmg_input_set.potcar_functional.split("_")[0]

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 |= {
"kpts": kpoints_dict["kpoints"][0],
"gamma": kpoints_dict["generation_style"] == "Gamma",
}

return full_input_params, AseAtomsAdaptor().get_atoms(
pmg_input_set.poscar.structure
)
30 changes: 0 additions & 30 deletions src/quacc/calculators/vasp/presets/MPScanSet.yaml

This file was deleted.

103 changes: 0 additions & 103 deletions src/quacc/calculators/vasp/presets/setups_pbe54_MP.yaml

This file was deleted.

20 changes: 18 additions & 2 deletions src/quacc/calculators/vasp/vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
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,
)
from quacc.schemas.prep import set_magmoms
from quacc.utils.dicts import sort_dict

if TYPE_CHECKING:
from typing import Literal

from ase.atoms import Atoms
from pymatgen.io.vasp.sets import DictSet


class Vasp(Vasp_):
Expand All @@ -50,6 +53,7 @@ def __init__(
| None
) = None,
auto_dipole: bool | None = None,
pmg_input_set: DictSet | None = None,
**kwargs,
) -> None:
"""
Expand Down Expand Up @@ -94,6 +98,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.
Expand Down Expand Up @@ -132,6 +139,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
Expand Down Expand Up @@ -208,6 +216,14 @@ 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
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:
calc_preset = load_vasp_yaml_calc(SETTINGS.VASP_PRESET_DIR / self.preset)[
Expand All @@ -218,7 +234,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
Expand Down Expand Up @@ -271,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))
Loading
Loading