catbench 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- catbench-0.1.0/LICENSE +21 -0
- catbench-0.1.0/PKG-INFO +25 -0
- catbench-0.1.0/README.md +2 -0
- catbench-0.1.0/catbench/__init__.py +1 -0
- catbench-0.1.0/catbench/core.py +420 -0
- catbench-0.1.0/catbench.egg-info/PKG-INFO +25 -0
- catbench-0.1.0/catbench.egg-info/SOURCES.txt +10 -0
- catbench-0.1.0/catbench.egg-info/dependency_links.txt +1 -0
- catbench-0.1.0/catbench.egg-info/requires.txt +5 -0
- catbench-0.1.0/catbench.egg-info/top_level.txt +1 -0
- catbench-0.1.0/setup.cfg +4 -0
- catbench-0.1.0/setup.py +33 -0
catbench-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jinuk Moon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
catbench-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: catbench
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MLP benchmarking workflow for catalysis
|
|
5
|
+
Home-page: https://github.com/JinukMoon/catbench
|
|
6
|
+
Author: Jinuk Moon
|
|
7
|
+
Author-email: jumooon@snu.ac.kr
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: MLP benchmarking for catalysis
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Requires-Python: >=3.6
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: korean_lunar_calendar>=0.2.1
|
|
20
|
+
Requires-Dist: requests>=2.0.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: ase>=3.22.1; extra == "dev"
|
|
23
|
+
|
|
24
|
+
# catbench
|
|
25
|
+
MLP benchmarking workflow for catalysis
|
catbench-0.1.0/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import execute_benchmark, json2pkl
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
from ase.optimize import LBFGS
|
|
2
|
+
import os
|
|
3
|
+
import pickle
|
|
4
|
+
import torch
|
|
5
|
+
import json
|
|
6
|
+
import time
|
|
7
|
+
from copy import deepcopy
|
|
8
|
+
from ase.constraints import FixAtoms
|
|
9
|
+
import numpy as np
|
|
10
|
+
from ase.io import read, write
|
|
11
|
+
import requests
|
|
12
|
+
import json
|
|
13
|
+
import io
|
|
14
|
+
import copy
|
|
15
|
+
import os
|
|
16
|
+
from ase.io import read
|
|
17
|
+
import pickle
|
|
18
|
+
|
|
19
|
+
GRAPHQL = 'http://api.catalysis-hub.org/graphql'
|
|
20
|
+
|
|
21
|
+
def convert_trajectory(filename):
|
|
22
|
+
images = read(filename, index=':')
|
|
23
|
+
os.remove(filename)
|
|
24
|
+
write(filename, images, format='extxyz')
|
|
25
|
+
|
|
26
|
+
def energy_cal_gas(calculator, atoms_origin, F_CRIT_RELAX):
|
|
27
|
+
atoms = deepcopy(atoms_origin)
|
|
28
|
+
atoms.calc = calculator
|
|
29
|
+
cell_size = [10, 10, 10]
|
|
30
|
+
atoms.set_cell(cell_size)
|
|
31
|
+
atoms.center()
|
|
32
|
+
atomic_numbers = atoms.get_atomic_numbers()
|
|
33
|
+
max_atomic_number = np.max(atomic_numbers)
|
|
34
|
+
max_atomic_number_indices = [i for i, num in enumerate(
|
|
35
|
+
atomic_numbers) if num == max_atomic_number]
|
|
36
|
+
fixed_atom_index = np.random.choice(max_atomic_number_indices)
|
|
37
|
+
c = FixAtoms(indices=[fixed_atom_index])
|
|
38
|
+
atoms.set_constraint(c)
|
|
39
|
+
tags = np.ones(len(atoms))
|
|
40
|
+
atoms.set_tags(tags)
|
|
41
|
+
opt = LBFGS(atoms)
|
|
42
|
+
opt.run(fmax=F_CRIT_RELAX)
|
|
43
|
+
|
|
44
|
+
return atoms, atoms.get_potential_energy()
|
|
45
|
+
|
|
46
|
+
def energy_cal(calculator, atoms_origin, F_CRIT_RELAX, N_CRIT_RELAX, damping, z_target, logfile='', filename=''):
|
|
47
|
+
atoms = deepcopy(atoms_origin)
|
|
48
|
+
atoms.calc = calculator
|
|
49
|
+
tags = np.ones(len(atoms))
|
|
50
|
+
atoms.set_tags(tags)
|
|
51
|
+
if z_target != 0:
|
|
52
|
+
atoms.set_constraint(fixatom(atoms, z_target))
|
|
53
|
+
|
|
54
|
+
if logfile == 'no':
|
|
55
|
+
opt = LBFGS(atoms, logfile=None, damping=damping)
|
|
56
|
+
opt.run(fmax=F_CRIT_RELAX, steps=N_CRIT_RELAX)
|
|
57
|
+
elapsed_time = 0
|
|
58
|
+
else:
|
|
59
|
+
time_init = time.time()
|
|
60
|
+
logfile = open(logfile, 'w', buffering=1)
|
|
61
|
+
logfile.write('######################\n')
|
|
62
|
+
logfile.write('## NNP relax starts ##\n')
|
|
63
|
+
logfile.write('######################\n')
|
|
64
|
+
logfile.write('\nStep 1. Relaxing\n')
|
|
65
|
+
opt = LBFGS(atoms, logfile=logfile,
|
|
66
|
+
trajectory=filename, damping=damping)
|
|
67
|
+
opt.run(fmax=F_CRIT_RELAX, steps=N_CRIT_RELAX)
|
|
68
|
+
convert_trajectory(filename)
|
|
69
|
+
logfile.write('Done!\n')
|
|
70
|
+
elapsed_time = time.time() - time_init
|
|
71
|
+
logfile.write(f'\nElapsed time: {elapsed_time} s\n\n')
|
|
72
|
+
logfile.write('###############################\n')
|
|
73
|
+
logfile.write('## Relax terminated normally ##\n')
|
|
74
|
+
logfile.write('###############################\n')
|
|
75
|
+
logfile.close()
|
|
76
|
+
|
|
77
|
+
return atoms.get_potential_energy(), opt.nsteps, atoms, elapsed_time
|
|
78
|
+
|
|
79
|
+
def fixatom(atoms, z_target):
|
|
80
|
+
indices_to_fix = [
|
|
81
|
+
atom.index for atom in atoms if atom.position[2] < z_target]
|
|
82
|
+
const = FixAtoms(indices=indices_to_fix)
|
|
83
|
+
return const
|
|
84
|
+
|
|
85
|
+
def calc_displacement(atoms1, atoms2):
|
|
86
|
+
positions1 = atoms1.get_positions()
|
|
87
|
+
positions2 = atoms2.get_positions()
|
|
88
|
+
displacements = positions2 - positions1
|
|
89
|
+
displacement_magnitudes = np.linalg.norm(displacements, axis=1)
|
|
90
|
+
max_displacement = np.max(displacement_magnitudes)
|
|
91
|
+
return max_displacement
|
|
92
|
+
|
|
93
|
+
def find_median_index(arr):
|
|
94
|
+
orig_arr = deepcopy(arr)
|
|
95
|
+
sorted_arr = sorted(arr)
|
|
96
|
+
length = len(sorted_arr)
|
|
97
|
+
median_index = (length - 1) // 2
|
|
98
|
+
median_value = sorted_arr[median_index]
|
|
99
|
+
for i, num in enumerate(orig_arr):
|
|
100
|
+
if num == median_value:
|
|
101
|
+
return i, median_value
|
|
102
|
+
|
|
103
|
+
def fix_z(atoms, rate_fix):
|
|
104
|
+
if rate_fix:
|
|
105
|
+
z_max = max(atoms.positions[:, 2])
|
|
106
|
+
z_min = min(atoms.positions[:, 2])
|
|
107
|
+
z_target = z_min + rate_fix * (z_max - z_min)
|
|
108
|
+
|
|
109
|
+
return z_target
|
|
110
|
+
|
|
111
|
+
else:
|
|
112
|
+
return 0
|
|
113
|
+
|
|
114
|
+
def execute_benchmark(calculators, NNP_name, benchmark, F_CRIT_RELAX, N_CRIT_RELAX, rate, disp_thrs_slab, disp_thrs_ads, again_seed, damping):
|
|
115
|
+
path_pkl = os.path.join(os.getcwd(), f"raw_data/{benchmark}.pkl")
|
|
116
|
+
|
|
117
|
+
with open(path_pkl, 'rb') as file:
|
|
118
|
+
cathub_data = pickle.load(file)
|
|
119
|
+
|
|
120
|
+
save_directory = os.path.join(os.getcwd(), "result", NNP_name)
|
|
121
|
+
print(f"Starting {NNP_name} Benchmarking")
|
|
122
|
+
# Basic Settings==============================================================================
|
|
123
|
+
os.makedirs(f'{save_directory}/traj', exist_ok=True)
|
|
124
|
+
os.makedirs(f'{save_directory}/log', exist_ok=True)
|
|
125
|
+
os.makedirs(f'{save_directory}/gases', exist_ok=True)
|
|
126
|
+
|
|
127
|
+
final_result = {}
|
|
128
|
+
|
|
129
|
+
final_outlier = {}
|
|
130
|
+
final_outlier['Time'] = []
|
|
131
|
+
final_outlier['normal'] = []
|
|
132
|
+
final_outlier['outlier'] = []
|
|
133
|
+
|
|
134
|
+
# Calculation Part==============================================================================
|
|
135
|
+
|
|
136
|
+
accum_time = 0
|
|
137
|
+
gas_energies = {}
|
|
138
|
+
|
|
139
|
+
print("Starting calculations...")
|
|
140
|
+
for key in cathub_data.keys():
|
|
141
|
+
print(key)
|
|
142
|
+
final_result[key] = {}
|
|
143
|
+
final_result[key]['cathub'] = {}
|
|
144
|
+
final_result[key]['cathub']['ads_eng'] = cathub_data[key]['cathub_energy']
|
|
145
|
+
for structure in cathub_data[key]['raw'].keys():
|
|
146
|
+
if 'gas' not in str(structure):
|
|
147
|
+
final_result[key]['cathub'][f'{structure}_abs'] = cathub_data[key]['raw'][structure]['energy_cathub']
|
|
148
|
+
final_result[key]['outliers'] = {'slab_conv': 0, 'ads_conv': 0, 'slab_move': 0, 'ads_move': 0, 'slab_seed': 0, 'ads_seed': 0, 'ads_eng_seed' : 0}
|
|
149
|
+
|
|
150
|
+
trag_path = f'{save_directory}/traj/{key}'
|
|
151
|
+
log_path = f'{save_directory}/log/{key}'
|
|
152
|
+
|
|
153
|
+
os.makedirs(trag_path, exist_ok=True)
|
|
154
|
+
os.makedirs(log_path, exist_ok=True)
|
|
155
|
+
|
|
156
|
+
POSCAR_star = cathub_data[key]['raw']['star']['atoms']
|
|
157
|
+
z_target = fix_z(POSCAR_star, rate)
|
|
158
|
+
|
|
159
|
+
informs = {}
|
|
160
|
+
informs['ads_eng'] = []
|
|
161
|
+
informs['slab_disp'] = []
|
|
162
|
+
informs['ads_disp'] = []
|
|
163
|
+
informs['slab_seed'] = []
|
|
164
|
+
informs['ads_seed'] = []
|
|
165
|
+
|
|
166
|
+
time_total_slab = 0
|
|
167
|
+
time_total_ads = 0
|
|
168
|
+
|
|
169
|
+
for i in range(len(calculators)):
|
|
170
|
+
ads_energy_calc = 0
|
|
171
|
+
for structure in cathub_data[key]['raw'].keys():
|
|
172
|
+
if 'gas' not in str(structure):
|
|
173
|
+
POSCAR_str = cathub_data[key]['raw'][structure]['atoms']
|
|
174
|
+
energy_calculated, steps_calculated, CONTCAR_calculated, time_calculated = energy_cal(calculators[i], POSCAR_str, F_CRIT_RELAX, N_CRIT_RELAX, damping, z_target, f'{log_path}/{structure}_{i}.txt', f'{trag_path}/{structure}_{i}')
|
|
175
|
+
ads_energy_calc += energy_calculated * cathub_data[key]['raw'][structure]['stoi']
|
|
176
|
+
accum_time += time_calculated
|
|
177
|
+
if structure == 'star':
|
|
178
|
+
slab_steps = steps_calculated
|
|
179
|
+
slab_displacement = calc_displacement(POSCAR_str, CONTCAR_calculated)
|
|
180
|
+
slab_energy = energy_calculated
|
|
181
|
+
slab_time = time_calculated
|
|
182
|
+
time_total_slab += time_calculated
|
|
183
|
+
else:
|
|
184
|
+
ads_step = steps_calculated
|
|
185
|
+
ads_displacement = calc_displacement(POSCAR_str, CONTCAR_calculated)
|
|
186
|
+
ads_energy = energy_calculated
|
|
187
|
+
ads_time = time_calculated
|
|
188
|
+
time_total_ads += time_calculated
|
|
189
|
+
else:
|
|
190
|
+
gas_tag = f'{structure}_{i}th'
|
|
191
|
+
if gas_tag in gas_energies.keys():
|
|
192
|
+
ads_energy_calc += gas_energies[gas_tag] * cathub_data[key]['raw'][structure]['stoi']
|
|
193
|
+
else:
|
|
194
|
+
print(f'{gas_tag} calculating')
|
|
195
|
+
gas_POSCAR, gas_energy = energy_cal_gas(
|
|
196
|
+
calculators[i], cathub_data[key]['raw'][structure]['atoms'], F_CRIT_RELAX)
|
|
197
|
+
gas_energies[gas_tag] = gas_energy
|
|
198
|
+
ads_energy_calc += gas_energy * cathub_data[key]['raw'][structure]['stoi']
|
|
199
|
+
write(f'{save_directory}/gases/POSCAR_{gas_tag}', gas_POSCAR)
|
|
200
|
+
|
|
201
|
+
if slab_steps == N_CRIT_RELAX:
|
|
202
|
+
final_result[key]['outliers']['slab_conv'] += 1
|
|
203
|
+
|
|
204
|
+
if ads_step == N_CRIT_RELAX:
|
|
205
|
+
final_result[key]['outliers']['ads_conv'] += 1
|
|
206
|
+
|
|
207
|
+
if slab_displacement > disp_thrs_slab:
|
|
208
|
+
final_result[key]['outliers']['slab_move'] += 1
|
|
209
|
+
|
|
210
|
+
if ads_displacement > disp_thrs_ads:
|
|
211
|
+
final_result[key]['outliers']['ads_move'] += 1
|
|
212
|
+
|
|
213
|
+
final_result[key][f'{i}'] = {
|
|
214
|
+
'ads_eng': ads_energy_calc,
|
|
215
|
+
'slab_abs': slab_energy,
|
|
216
|
+
'ads_abs': ads_energy,
|
|
217
|
+
'slab_disp': slab_displacement,
|
|
218
|
+
'ads_disp': ads_displacement,
|
|
219
|
+
'time_slab': slab_time,
|
|
220
|
+
'time_O': ads_time
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
informs['ads_eng'].append(ads_energy_calc)
|
|
224
|
+
informs['slab_disp'].append(slab_displacement)
|
|
225
|
+
informs['ads_disp'].append(ads_displacement)
|
|
226
|
+
informs['slab_seed'].append(slab_energy)
|
|
227
|
+
informs['ads_seed'].append(ads_energy)
|
|
228
|
+
|
|
229
|
+
ads_med_index, ads_med_eng = find_median_index(informs['ads_eng'])
|
|
230
|
+
slab_seed_range = np.max(np.array(informs['slab_seed'])) - np.min(np.array(informs['slab_seed']))
|
|
231
|
+
ads_seed_range = np.max(np.array(informs['ads_seed'])) - np.min(np.array(informs['ads_seed']))
|
|
232
|
+
ads_eng_seed_range = np.max(np.array(informs['ads_eng'])) - np.min(np.array(informs['ads_eng']))
|
|
233
|
+
if slab_seed_range > again_seed:
|
|
234
|
+
final_result[key]['outliers']['slab_seed'] = 1
|
|
235
|
+
if ads_seed_range > again_seed:
|
|
236
|
+
final_result[key]['outliers']['ads_seed'] = 1
|
|
237
|
+
if ads_eng_seed_range > again_seed:
|
|
238
|
+
final_result[key]['outliers']['ads_eng_seed'] = 1
|
|
239
|
+
|
|
240
|
+
final_result[key]['final'] = {
|
|
241
|
+
'ads_eng_median': ads_med_eng,
|
|
242
|
+
'median_num': ads_med_index,
|
|
243
|
+
'slab_max_disp': np.max(np.array(informs['slab_disp'])),
|
|
244
|
+
'ads_max_disp': np.max(np.array(informs['ads_disp'])),
|
|
245
|
+
'slab_seed_range': slab_seed_range,
|
|
246
|
+
'ads_seed_range': ads_seed_range,
|
|
247
|
+
'time_total_slab': time_total_slab,
|
|
248
|
+
'time_total_O': time_total_ads,
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
outlier_sum = sum(final_result[key]['outliers'].values())
|
|
252
|
+
final_outlier['Time'] = accum_time
|
|
253
|
+
|
|
254
|
+
if outlier_sum == 0:
|
|
255
|
+
final_outlier['normal'].append(key)
|
|
256
|
+
else:
|
|
257
|
+
final_outlier['outlier'].append(key)
|
|
258
|
+
|
|
259
|
+
with open(f'{save_directory}/{NNP_name}_result.json', 'w') as file:
|
|
260
|
+
json.dump(final_result, file, indent=4)
|
|
261
|
+
|
|
262
|
+
with open(f'{save_directory}/{NNP_name}_outlier.json', 'w') as file:
|
|
263
|
+
json.dump(final_outlier, file, indent=4)
|
|
264
|
+
|
|
265
|
+
with open(f'{save_directory}/{NNP_name}_gases.json', 'w') as file:
|
|
266
|
+
json.dump(gas_energies, file, indent=4)
|
|
267
|
+
|
|
268
|
+
print("f{NNP_name} Benchmarking Finish")
|
|
269
|
+
|
|
270
|
+
def fetch(query):
|
|
271
|
+
return requests.get(
|
|
272
|
+
GRAPHQL, {'query': query}
|
|
273
|
+
).json()['data']
|
|
274
|
+
|
|
275
|
+
def reactions_from_dataset(pub_id, page_size=40):
|
|
276
|
+
reactions = []
|
|
277
|
+
has_next_page = True
|
|
278
|
+
start_cursor = ''
|
|
279
|
+
page = 0
|
|
280
|
+
while has_next_page:
|
|
281
|
+
data = fetch("""{{
|
|
282
|
+
reactions(pubId: "{pub_id}", first: {page_size}, after: "{start_cursor}") {{
|
|
283
|
+
totalCount
|
|
284
|
+
pageInfo {{
|
|
285
|
+
hasNextPage
|
|
286
|
+
hasPreviousPage
|
|
287
|
+
startCursor
|
|
288
|
+
endCursor
|
|
289
|
+
}}
|
|
290
|
+
edges {{
|
|
291
|
+
node {{
|
|
292
|
+
Equation
|
|
293
|
+
reactants
|
|
294
|
+
products
|
|
295
|
+
reactionEnergy
|
|
296
|
+
reactionSystems {{
|
|
297
|
+
name
|
|
298
|
+
systems {{
|
|
299
|
+
energy
|
|
300
|
+
InputFile(format: "json")
|
|
301
|
+
}}
|
|
302
|
+
}}
|
|
303
|
+
}}
|
|
304
|
+
}}
|
|
305
|
+
}}
|
|
306
|
+
}}""".format(start_cursor=start_cursor,
|
|
307
|
+
page_size=page_size,
|
|
308
|
+
pub_id=pub_id,
|
|
309
|
+
))
|
|
310
|
+
has_next_page = data['reactions']['pageInfo']['hasNextPage']
|
|
311
|
+
start_cursor = data['reactions']['pageInfo']['endCursor']
|
|
312
|
+
page += 1
|
|
313
|
+
print(has_next_page, start_cursor, page_size *
|
|
314
|
+
page, data['reactions']['totalCount'])
|
|
315
|
+
reactions.extend(map(lambda x: x['node'], data['reactions']['edges']))
|
|
316
|
+
|
|
317
|
+
return reactions
|
|
318
|
+
|
|
319
|
+
def aseify_reactions(reactions):
|
|
320
|
+
for i, reaction in enumerate(reactions):
|
|
321
|
+
for j, _ in enumerate(reactions[i]['reactionSystems']):
|
|
322
|
+
system_info = reactions[i]['reactionSystems'][j].pop('systems')
|
|
323
|
+
|
|
324
|
+
with io.StringIO() as tmp_file:
|
|
325
|
+
tmp_file.write(system_info.pop('InputFile'))
|
|
326
|
+
tmp_file.seek(0)
|
|
327
|
+
atoms = read(tmp_file, format='json')
|
|
328
|
+
atoms.pbc = True
|
|
329
|
+
reactions[i]['reactionSystems'][j]['atoms'] = atoms
|
|
330
|
+
|
|
331
|
+
reactions[i]['reactionSystems'][j]['energy'] = system_info['energy']
|
|
332
|
+
|
|
333
|
+
reactions[i]['reactionSystems'] = {
|
|
334
|
+
x['name']: {'atoms': x['atoms'], 'energy': x['energy']}
|
|
335
|
+
for x in reactions[i]['reactionSystems']
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
def json2pkl(benchmark):
|
|
339
|
+
save_directory = os.path.join(os.getcwd(), 'raw_data')
|
|
340
|
+
os.makedirs(save_directory, exist_ok=True)
|
|
341
|
+
path_json = os.path.join(save_directory, f'{benchmark}.json')
|
|
342
|
+
path_output = os.path.join(os.getcwd(), f"raw_data/{benchmark}.pkl")
|
|
343
|
+
if not os.path.exists(path_output):
|
|
344
|
+
if not os.path.exists(path_json):
|
|
345
|
+
raw_reactions = reactions_from_dataset(benchmark)
|
|
346
|
+
raw_reactions_json = {"raw_reactions": raw_reactions}
|
|
347
|
+
with open(path_json, 'w') as file:
|
|
348
|
+
json.dump(raw_reactions_json, file, indent=4)
|
|
349
|
+
|
|
350
|
+
with open(path_json, 'r') as f:
|
|
351
|
+
data = json.load(f)
|
|
352
|
+
loaded_data = data['raw_reactions']
|
|
353
|
+
dat = copy.deepcopy(loaded_data)
|
|
354
|
+
aseify_reactions(dat)
|
|
355
|
+
|
|
356
|
+
data_total = {}
|
|
357
|
+
tags = []
|
|
358
|
+
|
|
359
|
+
for i, _ in enumerate(dat):
|
|
360
|
+
input = {}
|
|
361
|
+
reactants_json = dat[i]['reactants']
|
|
362
|
+
reactants_dict = json.loads(reactants_json)
|
|
363
|
+
|
|
364
|
+
products_json = dat[i]['products']
|
|
365
|
+
products_dict = json.loads(products_json)
|
|
366
|
+
|
|
367
|
+
sym = dat[i]['reactionSystems']['star']['atoms'].get_chemical_formula()
|
|
368
|
+
reaction_name = dat[i]['Equation']
|
|
369
|
+
|
|
370
|
+
tag = sym + "_" + reaction_name
|
|
371
|
+
if tag in tags:
|
|
372
|
+
count = tags.count(tag)
|
|
373
|
+
tags.append(tag)
|
|
374
|
+
tag = f'{tag}_{count}'
|
|
375
|
+
else:
|
|
376
|
+
tags.append(tag)
|
|
377
|
+
|
|
378
|
+
if len(products_dict.keys()) != 1:
|
|
379
|
+
print("error")
|
|
380
|
+
|
|
381
|
+
if 'star' not in reactants_dict.keys():
|
|
382
|
+
raise ValueError("star not exist in reactants")
|
|
383
|
+
|
|
384
|
+
for key in dat[i]['reactionSystems']:
|
|
385
|
+
if key in reactants_dict.keys():
|
|
386
|
+
input[key] = {
|
|
387
|
+
'stoi': -reactants_dict[key],
|
|
388
|
+
'atoms': dat[i]['reactionSystems'][key]['atoms'],
|
|
389
|
+
'energy_cathub': dat[i]['reactionSystems'][key]['energy'],
|
|
390
|
+
}
|
|
391
|
+
elif key in products_dict.keys():
|
|
392
|
+
input[key] = {''
|
|
393
|
+
'stoi': 1,
|
|
394
|
+
'atoms': dat[i]['reactionSystems'][key]['atoms'],
|
|
395
|
+
'energy_cathub': dat[i]['reactionSystems'][key]['energy'],
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
data_total[tag] = {}
|
|
399
|
+
data_total[tag]['raw'] = input
|
|
400
|
+
data_total[tag]['cathub_energy'] = dat[i]['reactionEnergy']
|
|
401
|
+
energy_check = 0
|
|
402
|
+
star_num = 0
|
|
403
|
+
for structure in input.keys():
|
|
404
|
+
if 'star' in str(structure):
|
|
405
|
+
star_num += 1
|
|
406
|
+
energy_check += input[structure]['energy_cathub'] * input[structure]['stoi']
|
|
407
|
+
|
|
408
|
+
if star_num != 2 :
|
|
409
|
+
raise ValueError("Stars are not 2")
|
|
410
|
+
|
|
411
|
+
if dat[i]['reactionEnergy'] - energy_check > 0.001:
|
|
412
|
+
print(tag)
|
|
413
|
+
print(dat[i]['reactionEnergy'] - energy_check)
|
|
414
|
+
print(dat[i]['reactionEnergy'])
|
|
415
|
+
print(energy_check)
|
|
416
|
+
print(data_total[tag])
|
|
417
|
+
raise ValueError("Reaction energy check failed")
|
|
418
|
+
|
|
419
|
+
with open(path_output, 'wb') as file:
|
|
420
|
+
pickle.dump(data_total, file)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: catbench
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MLP benchmarking workflow for catalysis
|
|
5
|
+
Home-page: https://github.com/JinukMoon/catbench
|
|
6
|
+
Author: Jinuk Moon
|
|
7
|
+
Author-email: jumooon@snu.ac.kr
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: MLP benchmarking for catalysis
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Requires-Python: >=3.6
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: korean_lunar_calendar>=0.2.1
|
|
20
|
+
Requires-Dist: requests>=2.0.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: ase>=3.22.1; extra == "dev"
|
|
23
|
+
|
|
24
|
+
# catbench
|
|
25
|
+
MLP benchmarking workflow for catalysis
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
catbench
|
catbench-0.1.0/setup.cfg
ADDED
catbench-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='catbench',
|
|
5
|
+
version='0.1.0',
|
|
6
|
+
author='Jinuk Moon',
|
|
7
|
+
author_email='jumooon@snu.ac.kr',
|
|
8
|
+
packages=find_packages(),
|
|
9
|
+
description='MLP benchmarking workflow for catalysis',
|
|
10
|
+
long_description=open('README.md').read(),
|
|
11
|
+
long_description_content_type='text/markdown',
|
|
12
|
+
url='https://github.com/JinukMoon/catbench',
|
|
13
|
+
license='MIT',
|
|
14
|
+
install_requires=[
|
|
15
|
+
'korean_lunar_calendar>=0.2.1',
|
|
16
|
+
'requests>=2.0.0',
|
|
17
|
+
],
|
|
18
|
+
extras_require={
|
|
19
|
+
'dev': [
|
|
20
|
+
'ase>=3.22.1',
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
classifiers=[
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.6",
|
|
26
|
+
"Programming Language :: Python :: 3.7",
|
|
27
|
+
"Programming Language :: Python :: 3.8",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
],
|
|
31
|
+
keywords='MLP benchmarking for catalysis',
|
|
32
|
+
python_requires='>=3.6',
|
|
33
|
+
)
|