Esempio n. 1
0
def hydrogen_abstraction_linear_atom_keys(rxn, zma=None):
    """ Obtain the linear atom keys for a hydrogen abstraction

    :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))

    _, hyd_key, _ = hydrogen_abstraction_atom_keys(rxn)

    lin_keys.append(hyd_key)
    lin_keys = tuple(sorted(set(lin_keys)))
    return lin_keys
Esempio n. 2
0
def hydrogen_abstraction_ts_zmatrix(rxn, ts_geo):
    """ z-matrix for a hydrogen abstraction transition state geometry

    :param rxn: a Reaction object
    :param ts_geo: a transition state geometry
    """
    rxn = rxn.copy()

    # 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
    att_key, hyd_key, _ = hydrogen_abstraction_atom_keys(rxn)
    lin_idxs.append(hyd_key)

    if hydrogen_abstraction_is_sigma(rxn):
        if att_key not in lin_idxs:
            lin_idxs.append(att_key)

    lin_idxs = sorted(lin_idxs)

    # 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