Esempio n. 1
0
def string(rotor_lst):
    """ Write a list torsions to a string
    """
    def _encode_idxs(idxs):
        if len(idxs) == 1:
            idx_str = idxs[0] + 1
        else:
            idx_str = '-'.join(str(val + 1) for val in idxs)
        return idx_str

    tors_dct = {}
    for rotor in rotor_lst:
        for torsion in rotor:
            _axis = torsion.axis
            _grps = torsion.groups
            tors_dct[torsion.name] = {
                'axis1': _axis[0] + 1,
                'group1': _encode_idxs(_grps[0]),
                'axis2': _axis[1] + 1,
                'group2': _encode_idxs(_grps[1]),
                'symmetry': torsion.symmetry,
            }

    sort_tors_dct = {}
    tors_names = sort_tors_names(list(tors_dct.keys()))
    for name in tors_names:
        sort_tors_dct[name] = tors_dct[name]

    tors_str = yaml.dump(sort_tors_dct, sort_keys=False)

    return tors_str
Esempio n. 2
0
def reaction_torsion_lst(zma, zrxn):
    """ torsions from zrxn obj
    """

    zbnd_keys = automol.reac.rotational_bond_keys(zrxn)
    tors_axes = tuple(tuple(keys) for keys in zbnd_keys)
    tors_names = tuple(
        automol.zmat.torsion_coordinate_name(zma, *keys) for keys in tors_axes)

    grxn = automol.reac.relabel_for_geometry(zrxn)
    gbnd_keys = automol.reac.rotational_bond_keys(grxn)
    tors_axes = tuple(tuple(keys) for keys in gbnd_keys)

    # Get the sorted tors names for building the list
    name_dct = dict(zip(tors_names, tors_axes))

    tors_obj_lst = ()
    sorted_tors_names = sort_tors_names(tuple(name_dct.keys()))
    for name in sorted_tors_names:

        gaxis = name_dct[name]
        gaxis = tuple(sorted(gaxis))
        ggrps = automol.reac.rotational_groups(grxn, *gaxis)
        symm = automol.reac.rotational_symmetry_number(grxn, *gaxis)

        # not for filesys
        # zgrps = tuple(automol.zmat.shift_up(zma, grp)
        #               for grp in ggrps)
        # zaxis = automol.zmat.shift_up(zma, gaxis)

        # Build the torsion object and add to the list
        tors_obj_lst += (Torsion(zma, name, gaxis, ggrps, symm), )

    return tors_obj_lst
Esempio n. 3
0
def torsion_lst(zma):
    """  Build a list of torsion objects
    """

    # Get the necessary graph and lin keys
    gra = automol.zmat.graph(zma, stereo=True, dummy=True)
    lin_keys = sorted(
        automol.graph.dummy_atoms_neighbor_atom_key(gra).values())

    # Build the torsion objects
    _name_axis_dct = name_axis_dct(zma, gra, lin_keys)

    # Get the sorted tors names for building the list
    sorted_tors_names = sort_tors_names(tuple(_name_axis_dct.keys()))

    tors_obj_lst = ()
    for name in sorted_tors_names:

        # Determine constituent rotor pieces in graph system
        axis = _name_axis_dct[name]
        grps = torsion_groups(gra, axis)
        symm = torsion_symmetry(gra, axis, lin_keys)

        # Build the torsion object and add to the list
        tors_obj_lst += (Torsion(zma, name, axis, grps, symm), )

    return tors_obj_lst
Esempio n. 4
0
def torsion_lst(zma, gra, lin_keys):
    """  Build a list of torsion objects
    """

    # Build the torsion objects
    _name_axis_dct = name_axis_dct(zma, gra, lin_keys)

    # Get the sorted tors names for building the list
    sorted_tors_names = sort_tors_names(tuple(_name_axis_dct.keys()))

    tors_obj_lst = ()
    for name in sorted_tors_names:

        # Determine constituent rotor pieces in graph system
        axis = _name_axis_dct[name]
        grps = torsion_groups(gra, axis)
        symm = torsion_symmetry(gra, axis, lin_keys)

        # Build the torsion object and add to the list
        tors_obj_lst += (Torsion(zma, name, axis, grps, symm), )

    return tors_obj_lst