def substitution_ts_zmatrix(rxn, ts_geo): """ z-matrix for a substitution transition state geometry :param rxn: a Reaction object :param ts_geo: a transition state geometry """ rxn = rxn.copy() rxn.forward_ts_graph = rxn.forward_ts_graph # 1. Get keys to linear or near-linear atoms lin_idxs = list(automol.geom.linear_atoms(ts_geo)) # Add a dummy atom over the transferring hydrogen _, tra_key, _ = substitution_atom_keys(rxn) lin_idxs.append(tra_key) # 2. Add dummy atoms over the linear atoms rcts_gra = ts.reactants_graph(rxn.forward_ts_graph) geo, dummy_key_dct = automol.geom.insert_dummies_on_linear_atoms( ts_geo, lin_idxs=lin_idxs, gra=rcts_gra) # 3. Add dummy atoms to the Reaction object as well rxn = add_dummy_atoms(rxn, dummy_key_dct) # 4. Generate a z-matrix for the geometry tsg = rxn.forward_ts_graph rct1_keys, rct2_keys = rxn.reactants_keys vma, zma_keys = automol.graph.vmat.vmatrix(tsg, rct1_keys) vma, zma_keys = automol.graph.vmat.continue_vmatrix( tsg, rct2_keys, vma, zma_keys) zma_geo = automol.geom.from_subset(geo, zma_keys) zma = automol.zmat.from_geometry(vma, zma_geo) return zma, zma_keys, dummy_key_dct
def substitution_linear_atom_keys(rxn, zma=None): """ Obtain the linear atom keys for a substitution :param rxn: a Reaction object :param zma: a z-matrix; if passed in, the linear atoms will be determined from this; otherwise they will be determined heuristically from the reaction object :returns: the keys of the linear atoms in the graph :rtype: tuple[int] """ tsg = rxn.forward_ts_graph if zma is not None: lin_keys = list(automol.zmat.linear_atom_keys(zma)) else: lin_keys = list(automol.graph.linear_atom_keys(tsg)) _, tra_key, _ = substitution_atom_keys(rxn) lin_keys.append(tra_key) lin_keys = tuple(sorted(set(lin_keys))) return lin_keys