-
Notifications
You must be signed in to change notification settings - Fork 0
/
nn_sella_quacc.py
140 lines (121 loc) · 3.3 KB
/
nn_sella_quacc.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
"""
Author: Anup Kumar
"""
import toml
import glob
import jobflow as jf
from ase import Atoms
from ase.io import read
from fireworks import LaunchPad
from jobflow.managers.fireworks import flow_to_workflow
from quacc.recipes.newtonnet.ts import ts_job
from quacc.recipes.newtonnet.ts import irc_job
from atomate.common.powerups import add_tags
def add_to_launchpad(
index: str,
atoms: Atoms,
config: dict,
lpad: LaunchPad,
ts_type: int = 0,
run_job_locally: bool = True,
) -> None:
"""
Add transition state and IRC jobs to the FireWorks LaunchPad.
Args:
index (str): The index string.
atoms (Atoms): The ASE Atoms object.
config (dict): The configuration dictionary.
lpad (LaunchPad): The FireWorks LaunchPad.
ts_type (int, optional): The type of transition state. Defaults to 0.
run_job_locally (bool, optional): Whether to run the job locally or add to LaunchPad. Defaults to True.
"""
tag = config['general']['tag'].format(ts_type)
if ts_type == 0:
job1 = ts_job(
atoms,
use_custom_hessian=True,
)
job1.update_metadata(
{
"tag": f'TS{ts_type}-{index}'
}
)
else:
job1 = ts_job(atoms, use_custom_hessian=False)
job1.update_metadata(
{
"tag": f'TS{ts_type}-{index}'
}
)
opt_swaps = {
"run_kwargs": {
"direction": "forward",
},
}
calc_swaps = {
"use_custom_hessian": False
}
job2 = irc_job(
job1.output["atoms"],
opt_swaps=opt_swaps,
calc_swaps=calc_swaps,
)
job2.update_metadata(
{
"tag": f'irc-forward{ts_type}-{index}',
}
)
opt_swaps = {
"run_kwargs": {
"direction": "reverse",
},
}
job3 = irc_job(
job1.output["atoms"],
opt_swaps=opt_swaps,
calc_swaps=calc_swaps,
)
job3.update_metadata(
{
"tag": f'irc-reverse{ts_type}-{index}',
}
)
flow = jf.Flow([job1, job2, job3])
if run_job_locally:
responses = jf.run_locally(flow)
result = responses[job2.uuid][1].output
print(result)
else:
wf = flow_to_workflow(flow)
wf = add_tags(wf, {"class": tag})
if config['general']['run']:
lpad.add_wf(wf)
def main():
"""
Main function to add transition state and IRC jobs to the LaunchPad.
"""
config = toml.load('inputs/config43.toml')
index_files = [index_file for index_file in glob.glob(config['indices']['xyz_files_dir'] + '/*')]
LAUNCHPAD_FILE = config['general']['launchpad_file']
lpad = LaunchPad.from_file(LAUNCHPAD_FILE)
for index_file in index_files:
atoms = read(index_file)
index = index_file.split('/')[-1].split('.')[0]
add_to_launchpad(
index,
atoms,
config,
lpad,
ts_type=0,
run_job_locally=False,
)
add_to_launchpad(
index,
atoms,
config,
lpad,
ts_type=1,
run_job_locally=False,
)
if __name__ == '__main__':
main()