Skip to content

Commit d607641

Browse files
committed
load SIDT correction trees and feed them in as appropriate
1 parent 770b388 commit d607641

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

pynta/tasks.py

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,8 +1231,59 @@ def run_task(self, fw_spec):
12311231
nslab = len(slab)
12321232
allowed_structure_site_structures = generate_allowed_structure_site_structures(os.path.join(pynta_dir,"Adsorbates"),sites,site_adjacency,nslab,max_dist=np.inf)
12331233

1234-
ad_energy_dict = get_lowest_adsorbate_energies(os.path.join(pynta_dir,"Adsorbates"))
1235-
coad_Es = {coadname: get_adsorbate_energies(coad_paths[coadname])[0] for coadname in coadnames}
1234+
from pysidt.sidt import read_nodes, MultiEvalSubgraphIsomorphicDecisionTreeRegressor
1235+
from molecule.molecule import Group, ATOMTYPES
1236+
import pynta.models
1237+
import os
1238+
nodes_file = os.path.join(os.path.split(pynta.models.__file__)[0],"finetuned_to_dft_delta_model.json")
1239+
nodes = read_nodes(nodes_file)
1240+
def bond_decomposition_adsorbate(mol):
1241+
pairs = []
1242+
bonds = mol.get_all_edges()
1243+
for bond in bonds:
1244+
if not (bond.atom1.is_surface_site() and bond.atom2.is_surface_site()):
1245+
pairs.append((mol.atoms.index(bond.atom1), mol.atoms.index(bond.atom2)))
1246+
1247+
structs = []
1248+
for pair in pairs:
1249+
m = mol.copy(deep=True)
1250+
for ind in pair:
1251+
m.atoms[ind].label = "*"
1252+
structs.append(m)
1253+
1254+
return structs
1255+
1256+
sidt_finetuned_to_dft = MultiEvalSubgraphIsomorphicDecisionTreeRegressor(
1257+
bond_decomposition_adsorbate,
1258+
nodes=nodes,
1259+
root_group = Group().from_adjacency_list("""1 * R u0 px cx {2,[vdW,R,S,D,T,Q]}
1260+
2 * Rx u0 px cx {1,[vdW,R,S,D,T,Q]}"""),
1261+
r=[ATOMTYPES[x] for x in ["C", "O", "H", "N", "X"]],
1262+
r_bonds=[0, 0.05, 1, 2, 3, 4],
1263+
r_un=[0],
1264+
r_site=["","fcc","hcp","ontop","bridge"],
1265+
fract_nodes_expand_per_iter=0.1,
1266+
)
1267+
1268+
from pynta.coveragedependence import adsorbate_interaction_decomposition
1269+
nodes_file = os.path.join(os.path.split(pynta.models.__file__)[0],"finetuned_to_dft_delta_model.json")
1270+
nodes = read_nodes(nodes_file)
1271+
1272+
sidt_finetuned_to_covdep = MultiEvalSubgraphIsomorphicDecisionTreeRegressor([adsorbate_interaction_decomposition],
1273+
nodes=pairnodes,
1274+
r=[ATOMTYPES[x] for x in r_atoms],
1275+
r_bonds=[1,2,3,4,0.05],
1276+
r_un=[0],
1277+
r_site=r_site,
1278+
max_structures_to_generate_extensions=100,
1279+
fract_nodes_expand_per_iter=0.025,
1280+
iter_max=2,
1281+
iter_item_cap=100,
1282+
weigh_node_selection_by_occurrence=True,
1283+
)
1284+
1285+
ad_energy_dict = get_lowest_adsorbate_energies(os.path.join(pynta_dir,"Adsorbates"),sidt_finetuned_to_dft=sidt_finetuned_to_dft)
1286+
coad_Es = {coadname: get_adsorbate_energies(coad_paths[coadname],sidt_finetuned_to_dft=sidt_finetuned_to_dft)[0] for coadname in coadnames}
12361287

12371288
coadmol_E_dicts = dict()
12381289
coadmol_stability_dicts = dict()
@@ -1297,7 +1348,7 @@ def run_task(self, fw_spec):
12971348
init_config = Molecule().from_adjacency_list(adjlist,check_consistency=False)
12981349
new_computed_configs.append(init_config)
12991350
datum_E,datums_stability = process_calculation(d,ad_energy_dict,slab,metal,facet,sites,site_adjacency,pynta_dir,coadmol_E_dicts[coadname],max_dist=3.0,rxn_alignment_min=0.7,
1300-
coad_disruption_tol=1.1,out_file_name="out",init_file_name="init",vib_file_name="vib_vib",is_ad=None)
1351+
coad_disruption_tol=1.1,out_file_name="out",init_file_name="init",vib_file_name="vib_vib",is_ad=None,sidt_finetuned_to_dft=sidt_finetuned_to_dft,sidt_finetuned_to_covdep=sidt_finetuned_to_covdep)
13011352
if datum_E:
13021353
new_datums_E.append(datum_E)
13031354
if datum_E and not datum_E.mol.is_isomorphic(init_config,save_order=True):

0 commit comments

Comments
 (0)