def cons_specific_cell(self, sites, e_num=None, symprec=1e-5): """ cons_specific_cell_and_c generate configurations of specific cell and specific concentration. parameters: sites: list of (lists or tuples), represent element disorder of each sites e_num: tuple, number of atoms in disorderd sites. e_num 特指无序位点的浓度,也就是原子比,而不是整体构型的元素原子比。有可能其他位点存在相同构型。 !!限制,无序位点的组成必须是相同的,而上面几个函数的无序位点是可以不同的。!! """ lat_cell = self._cell.lattice lat_pcell = self._pcell.lattice mat = numpy.matmul(lat_cell, numpy.linalg.inv(lat_pcell)) if is_int_np_array(mat): mat = numpy.around(mat).astype('intc') else: print("cell:\n", lat_cell) print("primitive cell:\n", lat_pcell) raise ValueError( "cell lattice and its primitive cell lattice not convertable") hfpg = PermutationGroup(self._pcell, mat) perms = hfpg.get_symmetry_perms(symprec) supercell = self._pcell.extend(mat) for mol, d in remove_redundant(supercell.positions, sites, perms, e_num=e_num): c = Cell(supercell.lattice, mol[0], mol[1]) yield (c, d)
def get_perms(cell,symprec=1e-3): latt = cell.lattice pos = cell.positions pos = np.dot(pos,latt) n = pos.shape[0] pcell = cell.get_primitive_cell() lat_pcell = pcell.lattice mat = np.matmul(latt, np.linalg.inv(lat_pcell)) if is_int_np_array(mat): mat = np.around(mat).astype('intc') else: print("cell:\n", lat_cell) print("primitive cell:\n", lat_pcell) raise ValueError( "cell lattice and its primitive cell lattice not convertable") hfpg = PG(pcell, mat) return hfpg.get_symmetry_perms(symprec)
def _is_hnf_dup(hnf_x, hnf_y, rot_list, prec=1e-5): """ A hnf act in a cell, if H_x * R.T^-1 * H_y ^-1 is an int matrix: H_x and H_y produce the same supercell. Algorithm: Hermite normal form (HNF) matrices remove translation symmetry duplications However, rotation symmetry duplications also need to be removedself. That is what this function ``_is_hnf_dup`` do. """ for rot in rot_list: m = numpy.matmul(numpy.matmul(hnf_x, numpy.linalg.inv(rot.T)), numpy.linalg.inv(hnf_y)) # TODO: stackoverflow add answer # is_int1 = numpy.all(numpy.isclose(m, m.astype(numpy.int), atol=1e-3)) # is_int2 = numpy.allclose(numpy.mod(m, 1), numpy.zeros_like(m), atol=prec) # is_array_int = numpy.all(numpy.isclose(m, numpy.around(m), atol=prec)) if is_int_np_array(m, prec): return True return False