diff --git a/rmgpy/data/kinetics/family.py b/rmgpy/data/kinetics/family.py index 4bb0ee949e..3072a71e93 100644 --- a/rmgpy/data/kinetics/family.py +++ b/rmgpy/data/kinetics/family.py @@ -3388,7 +3388,14 @@ def prune_tree(self, rxns, newrxns, thermo_database=None, new_fraction_threshold parent.children.remove(entry) del self.groups.entries[key] else: - entry.item.clear_reg_dims() + for atm in entry.item.atoms: + atm.reg_dim_atm[0] = [] #only clear the optimization dimension, preserve the regularization dimension + atm.reg_dim_u[0] = [] + atm.reg_dim_r[0] = [] + atm.reg_dim_site[0] = [] + atm.reg_dim_morphology[0] = [] + for bd in entry.item.get_all_edges(): + bd.reg_dim[0] = [] def make_tree_nodes(self, template_rxn_map=None, obj=None, T=1000.0, nprocs=0, depth=0, min_splitable_entry_num=2, min_rxns_to_spawn=20, extension_iter_max=np.inf, extension_iter_item_cap=np.inf): @@ -3791,10 +3798,17 @@ def simple_regularization(self, node, template_rxn_map, test=True): if isinstance(node.item, Group): indistinguishable = [] + + if node.children==[]: #if this is a leaf node, run it through get_extension_edge so that the regularization info is passed to leaf node + print('extending leaf nodes to get regularization info') + _, _ = self.get_extension_edge(node, template_rxn_map, obj=None, T=1000.0, iter_max=1, iter_item_cap=1) + for i, atm1 in enumerate(grp.atoms): skip = False - if node.children == []: # if the atoms or bonds are graphically indistinguishable don't regularize + if node.children == []: + + # if the atoms or bonds are graphically indistinguishable don't regularize bdpairs = {(atm, tuple(bd.order)) for atm, bd in atm1.bonds.items()} for atm2 in grp.atoms: if atm1 is not atm2 and atm1.atomtype == atm2.atomtype and len(atm1.bonds) == len(atm2.bonds): diff --git a/rmgpy/molecule/group.py b/rmgpy/molecule/group.py index f0af3727b7..c6fb6c03ce 100644 --- a/rmgpy/molecule/group.py +++ b/rmgpy/molecule/group.py @@ -1571,7 +1571,7 @@ def get_extensions(self, r=None, r_bonds=None, r_un=None, basename='', atm_ind=N """ cython.declare(atoms=list, atm=GroupAtom, atm2=GroupAtom, bd=GroupBond, i=int, j=int, extents=list, RnH=list, typ=list) - + extents = [] if r_bonds is None: r_bonds = [1, 1.5, 2, 3, 4] @@ -1726,6 +1726,8 @@ def specify_atom_extensions(self, i, basename, r): grps = [] Rset = set(r) + + #consider node splitting for item in r: grp = deepcopy(self) grpc = deepcopy(self) @@ -1751,6 +1753,32 @@ def specify_atom_extensions(self, i, basename, r): grps.append( (grp, grpc, basename + '_' + str(i + 1) + old_atom_type_str + '->' + item.label, 'atomExt', (i,))) + #generate an extension without node splitting + if len(self.atoms[i].atomtype)>len(Rset): + print('generating a non-splitting extension') + if all(r in self.atoms[i].atomtype for r in Rset): + #that means even if we update the atomtype of the atom to the Rset, it will still be a specification + grp = deepcopy(self) + grp.atoms[i].atomtype = list(Rset) + + #rename + old_atom_type = grp.atoms[i].atomtype + + if len(old_atom_type) > 1: + labelList = [] + old_atom_type_str = '' + for k in old_atom_type: + labelList.append(k.label) + for p in sorted(labelList): + old_atom_type_str += p + elif len(old_atom_type) == 0: + old_atom_type_str = "" + else: + old_atom_type_str = old_atom_type[0].label + + grps.append( + (grp, None, basename + '_' + str(i + 1) + old_atom_type_str + '->' + ''.join(r.label for r in Rset), 'atomExt', (i,))) + return grps def specify_ring_extensions(self, i, basename):