How to use the spglib.get_symmetry_dataset 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 qzhu2017 / PyXtal / pyxtal / test_cases / Random_vasp_ase.py View on Github external
struc.set_calculator(set_vasp(level=3, pstress=pstress, setup=setup))
            print(struc.get_potential_energy())
            time, ncore = read_OUTCAR()
            time0 += time
            print("time for vasp calcs3 (seconds):  ", time)
            struc = read("CONTCAR", format="vasp")

            if good_lattice(struc):
                struc = symmetrize_cell(struc, mode="P")
                struc.set_calculator(set_vasp(level=4, pstress=pstress, setup=setup))
                struc.get_potential_energy()
                time, ncore = read_OUTCAR()
                print("time for vasp calcs4 (seconds):  ", time)
                time0 += time
                result = vasprun().values
                spg = get_symmetry_dataset(struc, symprec=5e-2)["international"]
                print(
                    "#####%-10s %-10s %12.6f %6.2f %8.2f %4d %12s"
                    % (
                        dir1,
                        struc.get_chemical_formula(),
                        result["calculation"]["energy_per_atom"],
                        result["gap"],
                        time0,
                        ncore,
                        spg,
                    )
github qzhu2017 / PyXtal / pyxtal / test_cases / test_all.py View on Github external
t = str(timespent)
            if len(t) == 3:
                t += "0"
            t += " s"
            if timespent >= 1.0:
                t += " ~"
            if timespent >= 3.0:
                t += "~"
            if timespent >= 10.0:
                t += "~"
            if timespent >= 60.0:
                t += "~"
                slow.append(num)
            if rand_crystal.valid:
                try:
                    ans1 = get_symmetry_dataset(rand_crystal.spg_struct, symprec=1e-1)
                except:
                    ans1 = "???"
                if ans1 is None or ans1 == "???":
                    ans1 = "???"
                else:
                    ans1 = ans1["number"]
                sga = SpacegroupAnalyzer(rand_crystal.struct)
                try:
                    ans2 = sga.get_space_group_number()
                except:
                    ans2 = "???"
                if ans2 is None:
                    ans2 = "???"

                check = True
github SINGROUP / matid / systax / analysis / symmetryanalyzer.py View on Github external
def get_symmetry_dataset(self):
        """Calculates the symmetry dataset with spglib for the given system.
        """
        if self._symmetry_dataset is not None:
            return self._symmetry_dataset

        description = self._system_to_spglib_description(self.system)
        # Spglib has been observed to cause segmentation faults when fed with
        # invalid data, so run in separate process to catch those cases
        try:
            symmetry_dataset = segfault_protect(
                spglib.get_symmetry_dataset,
                description,
                self.spglib_precision)
        except RuntimeError:
            raise CellNormalizationError(
                "Segfault in spglib when finding symmetry dataset. Please check "
                " the given cell, scaled positions and atomic numbers."
            )
        if symmetry_dataset is None:
            raise CellNormalizationError(
                'Spglib error when finding symmetry dataset.')

        self._symmetry_dataset = symmetry_dataset

        return symmetry_dataset
github pyiron / pyiron / pyiron / atomistics / structure / atoms.py View on Github external
def get_symmetry_dataset(self, symprec=1e-5, angle_tolerance=-1.0):
        """
        
        Args:
            symprec: 
            angle_tolerance: 

        Returns:

        https://atztogo.github.io/spglib/python-spglib.html
        """
        lattice = np.array(self.get_cell().T, dtype='double', order='C')
        positions = np.array(self.get_scaled_positions(), dtype='double', order='C')
        numbers = np.array(self.get_atomic_numbers(), dtype='intc')
        return spglib.get_symmetry_dataset(cell=(lattice, positions, numbers),
                                           symprec=symprec,
                                           angle_tolerance=angle_tolerance)
github LaurentRDC / scikit-ued / skued / structure / crystal.py View on Github external
* ``'international_number'`` : International Tables of Crystallography space-group number (between 1 and 230);

            * ``'hall_number'`` : Hall number (between 1 and 531).

            If symmetry-determination has failed, None is returned.
        
        Raises
        ------
        RuntimeError : If symmetry-determination has yielded an error.
        
        Notes
        -----
        Note that crystals generated from the Protein Data Bank are often incomplete; 
        in such cases the space-group information will be incorrect.
        """
        dataset = get_symmetry_dataset(cell = self._spglib_cell(),
                                       symprec = symprec, 
                                       angle_tolerance = angle_tolerance)

        if dataset: 
            spg_type = get_spacegroup_type(dataset['hall_number'])

            info = {'international_symbol': dataset['international'],
                    'hall_symbol'         : dataset['hall'],
                    'international_number': dataset['number'],
                    'hall_number'         : dataset['hall_number'],
                    'international_full'  : spg_type['international_full'],
                    'pointgroup'          : spg_type['pointgroup_international']} 

            err_msg = get_error_message()
            if (err_msg != 'no error'):
                raise RuntimeError('Symmetry-determination has returned the following error: {}'.format(err_msg))
github MaterialsDiscovery / PyChemia / pychemia / crystal / symmetry.py View on Github external
def get_symmetry_dataset(self, symprec=1e-5):
        ret = spg.get_symmetry_dataset(cell=self.spglib_cell, symprec=symprec)
        if ret is None:
            raise ValueError(self.spglib_cell)
        return ret
github wolverton-research-group / qmpy / qmpy / analysis / symmetry / routines.py View on Github external
to standardized unit cell
        - `translations`: Nx3 array of float with translation operations
        - `wyckoffs`: Nx1 array of string with the Wyckoff symbol of each site

        The original reference for the dataset is at
        https://atztogo.github.io/spglib/python-spglib.html#get-symmetry-dataset
        and may change in future versions.

        None if `spglib` fails to determine symmetry.

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

    """
    _check_spglib_install()
    return spglib.get_symmetry_dataset(
        _structure_to_cell(structure),
        symprec=symprec
    )
github qzhu2017 / PyXtal / examples / example_03_3D_ICE_lammps.py View on Github external
)
            break
    # struc = struc.repeat((2,2,2))
    lammps = LAMMPSlib(lmp=lmp, lmpcmds=parameters, mol=True)
    struc.set_calculator(lammps)
    box = mushybox(struc)
    dyn = FIRE(box)
    dyn.run(fmax=0.01, steps=200)
    dyn = BFGS(box)
    dyn.run(fmax=0.01, steps=200)
    Eng = struc.get_potential_energy() * 96 / len(struc) * 3
    Vol = struc.get_volume() / len(struc) * 3
    stress = np.max(struc.get_stress())
    struc = sort(struc)
    try:
        spg = get_symmetry_dataset(struc, symprec=1e-1)["number"]
    except:
        spg = 1
    struc.write(out_folder + "/" + str(i) + ".vasp", format="vasp", vasp5=True)
    logging.info(
        "{:4d} Spg: {:4d} Eng: {:8.4f} Vol: {:8.4f} Stress: {:5.2f}".format(
            i, spg, Eng, Vol, stress
        )
    )
    abc = struc.get_cell_lengths_and_angles()
    abc = [int(i * 1000) / 1000 for i in abc]
    # data['ID'].append(i)
    data["Sym"].append(spg)
    data["Eng"].append(Eng)
    data["abc"].append(abc)
    data["Volume"].append(Vol)