How to use the spglib.spglib.spg.refine_cell function in spglib

To help you get started, we’ve selected a few spglib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MaterialsDiscovery / PyChemia / pychemia / symm / symmetry.py View on Github external
>>> symm2 = pychemia.symm.StructureSymmetry(fcc2)
>>> symm2.number()
225
>>> symm2.symbol()
u'Fm-3m'
        """
        natom = self.structure.natom
        cell = np.array(self.structure.cell.transpose(), dtype='double', order='C')

        pos = np.zeros((natom * 4, 3), dtype='double')
        pos[:natom] = self._reduced

        numbers = np.zeros(natom * 4, dtype='intc')
        numbers[:natom] = np.array(self._numbers, dtype='intc')

        natom_bravais = spg.spglib.spg.refine_cell(cell, pos, numbers, natom, symprec, angle_tolerance)
        if natom_bravais == 0:
            return self.structure.copy()

        cell = np.array(cell.T, dtype='double', order='C')
        reduced = np.array(pos[:natom_bravais], dtype='double', order='C')
        symbols = [self.structure.species[x] for x in (numbers[:natom_bravais] - 1)]

        return Structure(cell=cell, symbols=symbols, reduced=reduced)