Пример #1
0
    def test_get_permutations(self):
        pos = numpy.array([
            0.5288, 0.1610, 0.9359, 0.0000, 0.0000, 0.0000, 0.2051, 0.8240,
            -0.6786, 0.3345, -0.9314, -0.4496, -1.0685, -0.0537, 0.1921
        ]).reshape((-1, 3))
        atoms = ['H', 'C', 'H', 'H', 'H']
        methane = Molecule(pos, atoms)

        symprec = 1e-2
        perm = methane.get_symmetry_permutation(symprec)
        num_sym = numpy.shape(perm)[0]
        # methane have 12 symmetry operation
        expected_num_sym = 12
        self.assertEqual(num_sym, expected_num_sym)
Пример #2
0
def get_perms(cell,str_type='crystal',symprec=1e-3):
    latt = cell.lattice
    pos = cell.positions
    pos = np.dot(pos,latt)
    if str_type == "crystal":
        symm = cell.get_symmetry()
        trans,rots = symm['translations'],symm['rotations']
        perms = np.zeros((np.shape(trans)[0],len(cell.atoms)))
        origin_positions = refine_positions(cell.positions)
        for ix, rot in enumerate(rots):
            for iy,o_pos in enumerate(origin_positions):
                new_pos = np.dot(rot,o_pos.T) + trans[ix]
                new_pos = np.mod(new_pos,1)
                new_pos = refine_positions(new_pos)
                idx = np.argmin(np.linalg.norm(new_pos-origin_positions,axis=1))
                perms[ix,iy] = idx
        perms_table = np.unique(perms,axis=0)
    else:
        mol = Molecule(pos,cell.atoms)
        perms_table = mol.get_symmetry_permutation(symprec)
    return perms_table