How to use the spglib.spglib.spg.primitive 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
If no primitive cell is found a copy of the original structure is returned

        :param symprec: (float) Tolerance of distance between atomic positions and between lengths of lattice vectors
        to be tolerated in the symmetry finding.
        :param angle_tolerance: (float) Tolerance of angle between lattice vectors in degrees to be tolerated in the
        symmetry finding.

        :return: A new pychemia Structure in a Bravais lattice
        :rtype : (pychemia.Structure)
        """
        # Create copies of the arguments
        cell = np.array(self._transposed_cell, dtype='double', order='C')
        reduced = np.array(self._reduced, dtype='double', order='C')
        numbers = np.array(self._numbers, dtype='intc')

        natom_prim = spg.spglib.spg.primitive(cell, reduced, numbers, symprec, angle_tolerance)
        symbols = [self.structure.species[x] for x in (numbers[:natom_prim] - 1)]
        reduced = reduced[:natom_prim]

        if natom_prim > 0:
            return Structure(cell=cell.T, reduced=reduced, symbols=symbols)
        else:
            return self.structure.copy()