예제 #1
0
def get_tsites(code):
    from zse.collections import get_tsites
    z = framework(code)
    tsites, tmult = get_tsites(code)
    tinds = [atom.index for atom in z if atom.symbol != 'O']
    index = 0
    first_ts = []
    for i, m in enumerate(tmult):
        first_ts.append(tinds[index])
        index += m
    return tsites, tmult, first_ts
예제 #2
0
def get_unique_trings(code, ring_size):
    z = framework(code)
    pr = get_fwrings(code)
    tsites, tmult = get_tsites(code)
    tinds = [atom.index for atom in z if atom.symbol != 'O']
    index = 0
    firstts = []
    for i, m in enumerate(tmult):
        firstts.append(tinds[index])
        index += m
    allrings = []
    for f in firstts:
        c, r, ringatoms, repeat = tring_driver(z, f, pr, delete=False)
        for ring in r:
            allrings.append(ring)
    tinds = [atom.index for atom in ringatoms if atom.symbol != 'O']
    rp = np.prod(repeat)
    Dict = {}
    j = 0
    for i in range(rp):
        for s, t in enumerate(tsites):
            for q in range(tmult[s]):
                Dict[tinds[j]] = t
                j += 1
    ring_tsites = []
    for ring in allrings:
        tmp = []
        for i in ring:
            if ringatoms[i].symbol != 'O':
                tmp.append(Dict[i])
        ring_tsites.append(tmp)
    desired_rings_tsites = []
    desired_rings_full = []
    for i, r in enumerate(ring_tsites):
        if len(r) == ring_size:
            desired_rings_tsites.append(r)
            desired_rings_full.append(allrings[i])
    unique_tsites = []
    unique_full = []
    d = []
    for i in range(len(desired_rings_tsites)):
        for j in range((i + 1), len(desired_rings_tsites)):
            if i != j:
                st1 = ' '.join(map(str, desired_rings_tsites[i]))
                st2 = ' '.join(map(str, desired_rings_tsites[j]))
                st2_2 = ' '.join(map(str, reversed(desired_rings_tsites[j])))
                # st1 = set(desired_rings_tsites[i])
                # st2 = set(desired_rings_tsites[j])
                # if st1 == st2:
                if st2 in st1 + ' ' + st1 or st2_2 in st1 + ' ' + st1:
                    d.append(int(j))
    for i in range(len(desired_rings_tsites)):
        if i not in d:
            unique_tsites.append(desired_rings_tsites[i])
            unique_full.append(desired_rings_full[i])

    traj = []
    com = ringatoms.get_center_of_mass()
    for ring in unique_full:
        keepers = []
        atoms = ringatoms.copy()
        for i in ring:
            if i not in keepers:
                keepers.append(i)
        d = [atom.index for atom in atoms if atom.index not in keepers]
        del atoms[d]
        position = atoms[0].position
        trans = com - position
        atoms.translate(trans)
        atoms.wrap()
        traj += [atoms]

    return traj, unique_tsites
예제 #3
0
def get_all_rings(code):
    '''
    For developmental testing only.
    '''
    z = framework(code)
    pr = get_fwrings(code)
    tsites, tmult, first = get_tsites(code)
    tinds = [atom.index for atom in z if atom.symbol != 'O']
    index = 0
    firstts = []
    for i, m in enumerate(tmult):
        firstts.append(tinds[index])
        index += m
    allrings = []
    for f in firstts:
        c, r, ringatoms, repeat = all_trings(z, f, pr, delete=False)
        for ring in r:
            allrings.append(ring)
    tinds = [atom.index for atom in ringatoms if atom.symbol != 'O']
    rp = np.prod(repeat)
    Dict = {}
    j = 0
    for i in range(rp):
        for s, t in enumerate(tsites):
            for q in range(tmult[s]):
                Dict[tinds[j]] = t
                j += 1
    ring_tsites = []
    for ring in allrings:
        tmp = []
        for i in ring:
            if ringatoms[i].symbol != 'O':
                tmp.append(Dict[i])
        ring_tsites.append(tmp)
    unique_tsites = {}
    unique_full = {}
    for i, r in enumerate(ring_tsites):
        length = len(r)
        if length not in unique_tsites:
            unique_tsites[length] = [r]
            unique_full[length] = [allrings[i]]
        else:
            unique_tsites[length].append(r)
            unique_full[length].append(allrings[i])
    trajectories = {}
    com = ringatoms.get_center_of_mass()
    for length in pr:
        ring_tlist = unique_tsites[length]
        ring_full = unique_full[length]
        d = []
        for i in range(len(ring_tlist)):
            for j in range((i + 1), len(ring_tlist)):
                st1 = ' '.join(map(str, ring_tlist[i]))
                st2 = ' '.join(map(str, ring_tlist[j]))
                st2_2 = ' '.join(map(str, reversed(ring_tlist[j])))
                if st2 in st1 + ' ' + st1 or st2_2 in st1 + ' ' + st1:
                    d.append(int(j))
        tmp1 = []
        tmp2 = []
        for i in range(len(ring_tlist)):
            if i not in d:
                tmp1.append(ring_tlist[i])
                tmp2.append(ring_full[i])
        unique_tsites[length] = tmp1
        unique_full[length] = tmp2
        traj = []
        for ring in tmp2:
            keepers = []
            atoms = ringatoms.copy()
            for i in ring:
                if i not in keepers:
                    keepers.append(i)
            d = [atom.index for atom in atoms if atom.index not in keepers]
            del atoms[d]
            position = atoms[0].position
            trans = com - position
            atoms.translate(trans)
            atoms.wrap()
            traj += [atoms]
        trajectories[length] = traj

    return unique_tsites, unique_full, trajectories