-
Notifications
You must be signed in to change notification settings - Fork 41
/
slabs.py
116 lines (86 loc) · 2.32 KB
/
slabs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"""Common slab workflows."""
from __future__ import annotations
from typing import TYPE_CHECKING
from quacc import subflow
from quacc.atoms.slabs import make_adsorbate_structures, make_slabs_from_bulk
if TYPE_CHECKING:
from typing import Any
from ase.atoms import Atoms
from quacc import Job
@subflow
def bulk_to_slabs_subflow(
atoms: Atoms,
relax_job: Job,
static_job: Job | None = None,
make_slabs_kwargs: dict[str, Any] | None = None,
) -> list[dict]:
"""
Workflow consisting of:
1. Slab generation
2. Slab relaxations
3. Slab statics (optional)
Parameters
----------
atoms
Atoms object
relax_job
The relaxation function.
static_job
The static function.
make_slabs_kwargs
Additional keyword arguments to pass to
[quacc.atoms.slabs.make_slabs_from_bulk][]
Returns
-------
list[dict]
List of schemas.
"""
make_slabs_kwargs = make_slabs_kwargs or {}
slabs = make_slabs_from_bulk(atoms, **make_slabs_kwargs)
results = []
for slab in slabs:
result = relax_job(slab)
if static_job is not None:
result = static_job(result["atoms"])
results.append(result)
return results
@subflow
def slab_to_ads_subflow(
atoms: Atoms,
adsorbate: Atoms,
relax_job: Job,
static_job: Job | None,
make_ads_kwargs: dict[str, Any] | None = None,
) -> list[dict]:
"""
Workflow consisting of:
1. Slab-adsorbate generation
2. Slab-adsorbate relaxations
3. Slab-adsorbate statics (optional)
Parameters
----------
atoms
Atoms object for the slab structure.
adsorbate
Atoms object for the adsorbate.
relax_job
The slab releaxation job.
static_job
The slab static job.
make_ads_kwargs
Additional keyword arguments to pass to
[quacc.atoms.slabs.make_adsorbate_structures][]
Returns
-------
list[dict]
List of schemas.
"""
make_ads_kwargs = make_ads_kwargs or {}
slabs = make_adsorbate_structures(atoms, adsorbate, **make_ads_kwargs)
results = []
for slab in slabs:
result = relax_job(slab)
if static_job is not None:
result = static_job(result["atoms"])
results.append(result)
return results