Example #1
0
def hydrogen_migration_constraint_coordinates(rxn, zma):
    """ Obtain the constraint coordinates for a hydrogen migration

    :param rxn: a Reaction object
    :returns: the names of the constraint coordinates in the z-matrix
    :rtype: tuple[str]
    """
    att_key, _, _, ngb_key = hydrogen_migration_atom_keys(rxn)
    dist_name = automol.zmat.distance_coordinate_name(zma, att_key, ngb_key)
    return (dist_name, )
Example #2
0
def hydrogen_migration_ts_zmatrix(rxn, ts_geo):
    """ z-matrix for a hydrogen migration 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))

    # 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
    # Start the z-matrix from the forming bond ring
    rng_keys, = ts.forming_rings_atom_keys(rxn.forward_ts_graph)
    _, hyd_key, don_key, _ = hydrogen_migration_atom_keys(rxn)
    # Cycle the migrating h to the front of the ring keys and, if
    # needed, reverse the ring so that the donating atom is last:
    #       (migrating h atom, attacking atom, ... , donating atom)
    # This ensures that the forming bond coordinate is included in the z-matrix
    # and drops the breaking bond coordinate from the z-matrix.
    rng_keys = automol.graph.cycle_ring_atom_key_to_front(rng_keys,
                                                          hyd_key,
                                                          end_key=don_key)
    vma, zma_keys = automol.graph.vmat.vmatrix(rxn.forward_ts_graph,
                                               rng_keys=rng_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