/
run.py
117 lines (105 loc) · 3.53 KB
/
run.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
import os
from promethium_sdk.client import PromethiumClient
from promethium_sdk.models import (
CreateReactionPathOptimizationWorkflowRequest,
)
from promethium_sdk.utils import (
base64encode,
)
foldername = "output"
base_url = os.getenv("PM_API_BASE_URL", "https://api.promethium.qcware.com")
gpu_type = os.getenv("PM_GPU_TYPE", "a100")
dir_path = os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
)
if not os.path.exists(foldername):
os.makedirs(foldername)
n = 4
workflow_ids = []
prom = PromethiumClient()
for i in range(1, n + 1):
with open(os.path.join(dir_path, f"{i}/reactant.xyz"), "r") as fp:
reactant = base64encode(fp.read())
with open(os.path.join(dir_path, f"{i}/product.xyz"), "r") as fp:
product = base64encode(fp.read())
job_params = {
"name": f"API Reaction Path Optimization: {i}",
"version": "v1",
"kind": "ReactionPathOptimization",
"parameters": {
"reactant": {
"base64data": reactant,
"filetype": "xyz",
"params": {
"geometry_optimize": True,
},
},
"product": {
"base64data": product,
"filetype": "xyz",
"params": {
"geometry_optimize": True,
},
},
"system": {
"params": {
"basisname": "def2-svp",
"jkfit_basisname": "def2-universal-jkfit",
"methodname": "b3lyp",
"xc_grid_scheme": "SG1",
"threshold_pq": 1.0e-12,
},
},
"hf": {
"params": {
"multiplicity": 1,
"charge": 0,
"g_convergence": 1.0e-6,
"print_level": 0,
},
},
"pes": {
"params": {"coordinate_system_name": "redundant"},
},
"optimization": {
"params": {
"maxiter": 200,
},
},
"interpolation": {
"params": {
"rk_thresh": 1.0e-3,
"integrator": "rk45",
"dt": 0.01,
"nbeads": 11,
},
},
"neb": {
"params": {"force_constant_upper": 0.10, "force_constant_lower": 0.01},
},
"fire": {
"params": {
"g_convergence": 5.0e-3,
"dt_start": 0.5,
"alpha_start": 0.25,
},
},
},
"resources": {"gpu_type": gpu_type},
}
payload = CreateReactionPathOptimizationWorkflowRequest(**job_params)
workflow = prom.workflows.submit(payload)
workflow_ids.append(workflow.id)
# Wait for all workflows to complete:
for workflow_id in workflow_ids:
prom.workflows.wait(workflow_id)
# Get results:
for i, workflow_id in enumerate(workflow_ids):
workflow = prom.workflows.get(workflow_id)
print(f"Workflow {workflow.name} completed with status: {workflow.status}")
print(f"Workflow completed in {workflow.duration_seconds:.2f}s")
workflow_results = prom.workflows.results(workflow.id)
with open(f"{foldername}/{i}_{workflow.name}_results.json", "w") as fp:
fp.write(workflow_results.model_dump_json(indent=2))
# Download:
prom.workflows.download(workflow.id)