-
Notifications
You must be signed in to change notification settings - Fork 41
/
core.py
202 lines (179 loc) · 5.52 KB
/
core.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
"""Core recipes for Q-Chem."""
from __future__ import annotations
from importlib.util import find_spec
from typing import TYPE_CHECKING
from quacc import job
from quacc.recipes.qchem._base import run_and_summarize, run_and_summarize_opt
from quacc.utils.dicts import recursive_dict_merge
has_sella = bool(find_spec("sella"))
if has_sella:
from sella import Sella
if TYPE_CHECKING:
from ase.atoms import Atoms
from quacc.runners.ase import OptParams
from quacc.schemas._aliases.ase import OptSchema, RunSchema
from quacc.utils.files import Filenames, SourceDirectory
_BASE_SET = {
"rem": {
"gen_scfman": True,
"xc_grid": 3,
"thresh": 14,
"s2thresh": 16,
"scf_algorithm": "diis",
"resp_charges": True,
"symmetry": False,
"sym_ignore": True,
}
}
@job
def static_job(
atoms: Atoms,
charge: int = 0,
spin_multiplicity: int = 1,
method: str | None = "wb97mv",
basis: str | None = "def2-tzvpd",
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Carry out a single-point calculation.
Parameters
----------
atoms
Atoms object
charge
Total charge of the system.
spin_multiplicity
Multiplicity of the system.
method
DFT exchange-correlation functional or other electronic structure
method.
basis
Basis set.
copy_files
Files to copy (and decompress) from source to the runtime directory.
**calc_kwargs
Custom kwargs for the calculator. Set a value to `quacc.Remove` to remove
a pre-existing key entirely. See [quacc.calculators.qchem.qchem.QChem][] for more
details.
Returns
-------
RunSchema
Dictionary of results from [quacc.schemas.ase.summarize_run][].
See the type-hint for the data structure.
"""
calc_defaults = recursive_dict_merge(
_BASE_SET, {"rem": {"job_type": "force", "method": method, "basis": basis}}
)
return run_and_summarize(
atoms,
charge=charge,
spin_multiplicity=spin_multiplicity,
calc_defaults=calc_defaults,
calc_swaps=calc_kwargs,
additional_fields={"name": "Q-Chem Static"},
copy_files=copy_files,
)
@job
def relax_job(
atoms: Atoms,
charge: int = 0,
spin_multiplicity: int = 1,
method: str = "wb97mv",
basis: str = "def2-svpd",
opt_params: OptParams | None = None,
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
**calc_kwargs,
) -> OptSchema:
"""
Optimize aka "relax" a molecular structure with an ASE optimizer.
Parameters
----------
atoms
Atoms object
charge
Charge of the system.
spin_multiplicity
Multiplicity of the system.
method
DFT exchange-correlation functional or other electronic structure
method.
basis
Basis set.
opt_params
Dictionary of custom kwargs for the optimization process. For a list
of available keys, refer to [quacc.runners.ase.Runner.run_opt][].
copy_files
Files to copy (and decompress) from source to the runtime directory.
**calc_kwargs
Custom kwargs for the calculator. Set a value to `quacc.Remove` to remove
a pre-existing key entirely. See [quacc.calculators.qchem.qchem.QChem][] for more
details.
Returns
-------
OptSchema
Dictionary of results from [quacc.schemas.ase.summarize_opt_run][].
See the type-hint for the data structure.
"""
calc_defaults = recursive_dict_merge(
_BASE_SET, {"rem": {"job_type": "force", "method": method, "basis": basis}}
)
opt_defaults = {"optimizer": Sella} if has_sella else {}
return run_and_summarize_opt(
atoms,
charge=charge,
spin_multiplicity=spin_multiplicity,
calc_defaults=calc_defaults,
calc_swaps=calc_kwargs,
opt_defaults=opt_defaults,
opt_params=opt_params,
additional_fields={"name": "Q-Chem Optimization"},
copy_files=copy_files,
)
@job
def freq_job(
atoms: Atoms,
charge: int = 0,
spin_multiplicity: int = 1,
method: str = "wb97mv",
basis: str = "def2-svpd",
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Perform a frequency calculation on a molecular structure.
Parameters
----------
atoms
Atoms object
charge
Charge of the system.
spin_multiplicity
Multiplicity of the system.
method
DFT exchange-correlation functional or other electronic structure
method.
basis
Basis set.
copy_files
Files to copy (and decompress) from source to the runtime directory. **calc_kwargs
Custom kwargs for the calculator. Set a value to `quacc.Remove` to remove
a pre-existing key entirely. See [quacc.calculators.qchem.qchem.QChem][] for more
details.
Returns
-------
RunSchema
Dictionary of results from [quacc.schemas.ase.summarize_run][]
"""
calc_defaults = recursive_dict_merge(
_BASE_SET, {"rem": {"job_type": "freq", "method": method, "basis": basis}}
)
return run_and_summarize(
atoms,
charge=charge,
spin_multiplicity=spin_multiplicity,
calc_defaults=calc_defaults,
calc_swaps=calc_kwargs,
copy_files=copy_files,
additional_fields={"name": "Q-Chem Frequency"},
)