-
Notifications
You must be signed in to change notification settings - Fork 41
/
core.py
124 lines (108 loc) · 3.63 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
"""Core recipes for DFTB+"""
from __future__ import annotations
from typing import TYPE_CHECKING
from quacc import job
from quacc.recipes.dftb._base import run_and_summarize
if TYPE_CHECKING:
from typing import Literal
from ase.atoms import Atoms
from quacc.schemas._aliases.ase import RunSchema
from quacc.utils.files import Filenames, SourceDirectory
@job
def static_job(
atoms: Atoms,
method: Literal["GFN1-xTB", "GFN2-xTB", "DFTB"] = "GFN2-xTB",
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
kpts: tuple | list[tuple] | dict | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Carry out a single-point calculation.
Parameters
----------
atoms
Atoms object
method
Method to use.
kpts
k-point grid to use.
copy_files
Files to copy (and decompress) from source to the runtime directory.
**calc_kwargs
Custom kwargs for the calculator that would override the
calculator defaults. Set a value to `quacc.Remove` to remove a pre-existing key
entirely. For a list of available keys, refer to the
[ase.calculators.dftb.Dftb][] calculator.
Returns
-------
RunSchema
Dictionary of results, specified in [quacc.schemas.ase.summarize_run][].
See the return type-hint for the data structure.
"""
calc_defaults = {
"Hamiltonian_": "xTB" if "xtb" in method.lower() else "DFTB",
"Hamiltonian_MaxSccIterations": 200,
"kpts": kpts or ((1, 1, 1) if atoms.pbc.any() else None),
}
if "xtb" in method.lower():
calc_defaults["Hamiltonian_Method"] = method
return run_and_summarize(
atoms,
calc_defaults=calc_defaults,
calc_swaps=calc_kwargs,
additional_fields={"name": "DFTB+ Static"},
copy_files=copy_files,
)
@job
def relax_job(
atoms: Atoms,
method: Literal["GFN1-xTB", "GFN2-xTB", "DFTB"] = "GFN2-xTB",
kpts: tuple | list[tuple] | dict | None = None,
relax_cell: bool = False,
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Carry out a structure relaxation.
Parameters
----------
atoms
Atoms object
method
Method to use.
kpts
k-point grid to use.
relax_cell
Whether to relax the unit cell shape/volume in addition to the
positions.
copy_files
Files to copy (and decompress) from source to the runtime directory.
**calc_kwargs
Custom kwargs for the calculator that would override the
calculator defaults. Set a value to `quacc.Remove` to remove a pre-existing key
entirely. For a list of available keys, refer to the
[ase.calculators.dftb.Dftb][] calculator.
Returns
-------
RunSchema
Dictionary of results, specified in [quacc.schemas.ase.summarize_run][].
See the return type-hint for the data structure.
"""
calc_defaults = {
"Driver_": "GeometryOptimization",
"Driver_AppendGeometries": "Yes",
"Driver_LatticeOpt": "Yes" if relax_cell else "No",
"Driver_MaxSteps": 2000,
"Hamiltonian_": "xTB" if "xtb" in method.lower() else "DFTB",
"Hamiltonian_MaxSccIterations": 200,
"kpts": kpts or ((1, 1, 1) if atoms.pbc.any() else None),
}
if "xtb" in method.lower():
calc_defaults["Hamiltonian_Method"] = method
return run_and_summarize(
atoms,
calc_defaults=calc_defaults,
calc_swaps=calc_kwargs,
additional_fields={"name": "DFTB+ Relax"},
copy_files=copy_files,
)