-
Notifications
You must be signed in to change notification settings - Fork 2
/
construct_feats.py
38 lines (28 loc) · 1.24 KB
/
construct_feats.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
import ase.db
import pickle
from utils.features import db_to_zonedfeats, db_to_graphs
# Reference energies
ref_dict = {'ontop_OH':ase.db.connect('../data/3x3x5_pt111_ontop_OH.db').get().energy,
'fcc_O':ase.db.connect('../data/3x3x5_pt111_fcc_O.db').get().energy,
'slab':ase.db.connect('../data/3x3x5_pt111_slab.db').get().energy
}
project_name = 'agirpdptru'
site_list = ['ontop','fcc']
ads_list = ['OH','O']
surface_elements = ['Ag','Ir','Pd','Pt','Ru']
adsorbate_elements = ['O','H']
for i in range(len(site_list)):
## load joined ASE datebase
db = ase.db.connect(f'../data/{project_name}.db')
## filename used for pickling
filename = f'{project_name}_{site_list[i]}_{ads_list[i]}'
## Construct zoned features and pickle
print(f'Performing zonefeat construction of {project_name}_{site_list[i]}_{ads_list[i]}')
samples = db_to_zonedfeats(surface_elements, site_list[i], ads_list[i], 0.1, db, ref_dict)
with open(filename + '.zonefeats', 'wb') as output:
pickle.dump(samples, output)
## Construct graphs and pickle
print(f'Performing graph construction of {project_name}')
samples = db_to_graphs(surface_elements, adsorbate_elements, 2, 0.1, db, ref_dict)
with open(f'{project_name}.graphs', 'wb') as output:
pickle.dump(samples, output)