How to use the spglib.get_symmetry 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 / crystal / symmetry.py View on Github external
def get_symmetry(self, symprec=1e-5):
        return spg.get_symmetry(cell=self.spglib_cell, symprec=symprec)
github materialsproject / pymatgen / pymatgen / symmetry / analyzer.py View on Github external
def _get_symmetry(self):
        """
        Get the symmetry operations associated with the structure.

        Returns:
            Symmetry operations as a tuple of two equal length sequences.
            (rotations, translations). "rotations" is the numpy integer array
            of the rotation matrices for scaled positions
            "translations" gives the numpy float64 array of the translation
            vectors in scaled positions.
        """
        d = spglib.get_symmetry(self._cell, symprec=self._symprec,
                                angle_tolerance=self._angle_tol)
        # Sometimes spglib returns small translation vectors, e.g.
        # [1e-4, 2e-4, 1e-4]
        # (these are in fractional coordinates, so should be small denominator
        # fractions)
        trans = []
        for t in d["translations"]:
            trans.append([float(Fraction.from_float(c).limit_denominator(1000))
                          for c in t])
        trans = np.array(trans)

        # fractional translations of 1 are more simply 0
        trans[np.abs(trans) == 1] = 0
        return d["rotations"], trans
github pyiron / pyiron / pyiron / atomistics / structure / atoms.py View on Github external
"""
        lattice = np.array(self.get_cell().T, dtype='double', order='C')
        positions = np.array(self.get_scaled_positions(), dtype='double', order='C')
        if use_elements:
            numbers = np.array(self.get_atomic_numbers(), dtype='intc')
        else:
            numbers = np.ones_like(self.get_atomic_numbers(), dtype='intc')
        if use_magmoms:
            magmoms = self.get_initial_magnetic_moments()
            return spglib.get_symmetry(cell=(lattice, positions, numbers, magmoms),
                                       symprec=symprec,
                                       angle_tolerance=angle_tolerance)
        else:
            return spglib.get_symmetry(cell=(lattice, positions, numbers),
                                       symprec=symprec,
                                       angle_tolerance=angle_tolerance)
github wolverton-research-group / qmpy / qmpy / analysis / symmetry / routines.py View on Github external
structure: :class:`qmpy.Structure` object with the crystal structure.
        symprec: Float with the Cartesian distance tolerance.

    Returns:
        Dictionary of symmetry operations with keys "translations",
        "rotations", "equivalent_atoms" and values Nx(3x3) array of float,
        Nx3 array of integers, Nx3 array of integers, respectively.

        None if `spglib` is unable to determine symmetry.

    Raises:
        ImportError: If `spglib` cannot be imported.

    """
    _check_spglib_install()
    return spglib.get_symmetry(
        _structure_to_cell(structure),
        symprec=symprec
    )
github SUNCAT-Center / CatKit / catkit / gen / utils / symmetry.py View on Github external
Atoms object to search for symmetric structures of.
    tol : float
        Tolerance for floating point rounding errors.

    Returns
    -------
    symmetry operations: ndarray (n, n)
        Symmetry operations from spglib.
    """
    lattice = atoms.cell
    positions = atoms.get_scaled_positions()
    numbers = atoms.get_atomic_numbers()

    cell = (lattice, positions, numbers)

    symmetry = spglib.get_symmetry(cell, symprec=tol)

    rotations, translations = symmetry['rotations'], symmetry['translations']

    return rotations, translations
github pyscf / pyscf / pyscf / pbc / symm / symmetry.py View on Github external
def get_space_group(self):
        try:
            import spglib
            cell = cell_to_spgcell(self.cell)
            self.symbol = spglib.get_spacegroup(cell, symprec=self.symprec)
            symmetry = spglib.get_symmetry(cell, symprec=self.symprec)
            self.rotations = symmetry['rotations']
            self.translations = symmetry['translations']
        except:
            raise NotImplementedError("use spglib to determine space group for now")

        return self