当前位置: 首页>>代码示例>>Python>>正文


Python spglib.get_spacegroup方法代码示例

本文整理汇总了Python中spglib.get_spacegroup方法的典型用法代码示例。如果您正苦于以下问题:Python spglib.get_spacegroup方法的具体用法?Python spglib.get_spacegroup怎么用?Python spglib.get_spacegroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spglib的用法示例。


在下文中一共展示了spglib.get_spacegroup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_spacegroup

# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_spacegroup [as 别名]
def get_spacegroup(structure,
                   symprec=1e-3,
                   symbol_type=0):
    """
    Get the space group symbol and number of a crystal structure.

    Args:
        structure: :class:`qmpy.Structure` object with the crystal structure.
        symprec: Float with the Cartesian distance tolerance.
        symbol_type: Integer with the type: 0 - Schoenflies, 1 - ITC short

    Returns:
        String with the space group symbol and number. E.g. u"R-3m (166)"

        None if `spglib` fails to determine the space group.

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

    """
    _check_spglib_install()
    return spglib.get_spacegroup(
        _structure_to_cell(structure),
        symprec=symprec,
        symbol_type=symbol_type
    ) 
开发者ID:wolverton-research-group,项目名称:qmpy,代码行数:28,代码来源:routines.py

示例2: get_spacegroup

# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_spacegroup [as 别名]
def get_spacegroup(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(), dtype="double", order="C")
        positions = np.array(
            self.get_scaled_positions(wrap=False), dtype="double", order="C"
        )
        numbers = np.array(self.get_atomic_numbers(), dtype="intc")
        space_group = spglib.get_spacegroup(
            cell=(lattice, positions, numbers),
            symprec=symprec,
            angle_tolerance=angle_tolerance,
        ).split()
        if len(space_group) == 1:
            return {"Number": ast.literal_eval(space_group[0])}
        else:
            return {
                "InternationalTableSymbol": space_group[0],
                "Number": ast.literal_eval(space_group[1]),
            } 
开发者ID:pyiron,项目名称:pyiron,代码行数:30,代码来源:atoms.py

示例3: get_primitive_cell

# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_spacegroup [as 别名]
def get_primitive_cell(self, symprec=1e-5, angle_tolerance=-1.0):
        """

        Args:
            symprec:
            angle_tolerance:

        Returns:

        """
        el_dict = {}
        for el in set(self.get_chemical_elements()):
            el_dict[el.AtomicNumber] = el
        lattice = np.array(self.get_cell().T, dtype="double", order="C")
        positions = np.array(
            self.get_scaled_positions(wrap=False), dtype="double", order="C"
        )
        numbers = np.array(self.get_atomic_numbers(), dtype="intc")
        cell, coords, atomic_numbers = spglib.find_primitive(
            cell=(lattice, positions, numbers),
            symprec=symprec,
            angle_tolerance=angle_tolerance,
        )
        # print atomic_numbers, type(atomic_numbers)
        el_lst = [el_dict[i_a] for i_a in atomic_numbers]

        # convert lattice vectors to standard (experimental feature!) TODO:
        red_structure = Atoms(elements=el_lst, scaled_positions=coords, cell=cell)
        space_group = red_structure.get_spacegroup(symprec)["Number"]
        # print "space group: ", space_group
        if space_group == 225:  # fcc
            alat = np.max(cell[0])
            amat_fcc = alat * np.array([[1, 0, 1], [1, 1, 0], [0, 1, 1]])

            red_structure.cell = amat_fcc
        return red_structure 
开发者ID:pyiron,项目名称:pyiron,代码行数:38,代码来源:atoms.py

示例4: get_lattice_type

# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_spacegroup [as 别名]
def get_lattice_type(cryst):
    '''Find the symmetry of the crystal using spglib symmetry finder.

    Derive name of the space group and its number extracted from the result.
    Based on the group number identify also the lattice type and the Bravais
    lattice of the crystal. The lattice type numbers are
    (the numbering starts from 1):

    Triclinic (1), Monoclinic (2), Orthorombic (3),
    Tetragonal (4), Trigonal (5), Hexagonal (6), Cubic (7)

    :param cryst: ASE Atoms object

    :returns: tuple (lattice type number (1-7), lattice name, space group
                     name, space group number)
    '''

    # Table of lattice types and correcponding group numbers dividing
    # the ranges. See get_lattice_type method for precise definition.
    lattice_types = [
            [3,   "Triclinic"],
            [16,  "Monoclinic"],
            [75,  "Orthorombic"],
            [143, "Tetragonal"],
            [168, "Trigonal"],
            [195, "Hexagonal"],
            [231, "Cubic"]
        ]

    sg = spg.get_spacegroup(cryst)
    m = re.match(r'([A-Z].*\b)\s*\(([0-9]*)\)', sg)
    sg_name = m.group(1)
    sg_nr = int(m.group(2))

    for n, l in enumerate(lattice_types):
        if sg_nr < l[0]:
            bravais = l[1]
            lattype = n+1
            break

    return lattype, bravais, sg_name, sg_nr 
开发者ID:jochym,项目名称:Elastic,代码行数:43,代码来源:elastic.py

示例5: get_spacegroup

# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_spacegroup [as 别名]
def get_spacegroup(self, symprec=1e-5):
        return spg.get_spacegroup(cell=self.spglib_cell, symprec=symprec) 
开发者ID:MaterialsDiscovery,项目名称:PyChemia,代码行数:4,代码来源:symmetry.py

示例6: _make_atoms_dict

# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_spacegroup [as 别名]
def _make_atoms_dict(atoms):
    '''
    Convert an ase.Atoms object into a dictionary for json storage.

    Arg:
        atoms   ase.Atoms object
    Returns:
        atoms_dict  A dictionary with various atoms information stored
    '''
    # If the atoms object is relaxed, then get the magnetic moments from the
    # calculator. We do this because magnetic moments of individual atoms
    # within a structure are mutable and actually change when the atom is
    # pulled from the structure (even inside a list comprehension).
    try:
        magmoms = atoms.get_magnetic_moments()
        atoms_dict = OrderedDict(atoms=[{'symbol': atom.symbol,
                                         'position': json.loads(encode(atom.position)),
                                         'tag': atom.tag,
                                         'index': atom.index,
                                         'charge': atom.charge,
                                         'momentum': json.loads(encode(atom.momentum)),
                                         'magmom': magmoms[i]}
                                        for i, atom in enumerate(atoms)],
                                 cell=atoms.cell,
                                 pbc=atoms.pbc,
                                 info=atoms.info,
                                 constraints=[c.todict() for c in atoms.constraints])

    # If the atoms object is unrelaxed, then get the magnetic moment from the
    # individual atom
    except RuntimeError:
        atoms_dict = OrderedDict(atoms=[{'symbol': atom.symbol,
                                         'position': json.loads(encode(atom.position)),
                                         'tag': atom.tag,
                                         'index': atom.index,
                                         'charge': atom.charge,
                                         'momentum': json.loads(encode(atom.momentum)),
                                         'magmom': atom.magmom}
                                        for atom in atoms],
                                 cell=atoms.cell,
                                 pbc=atoms.pbc,
                                 info=atoms.info,
                                 constraints=[c.todict() for c in atoms.constraints])

    # Redundant information for search convenience.
    atoms_dict['natoms'] = len(atoms)
    cell = atoms.get_cell()
    atoms_dict['mass'] = sum(atoms.get_masses())
    syms = atoms.get_chemical_symbols()
    atoms_dict['spacegroup'] = spglib.get_spacegroup(make_spglib_cell_from_atoms(atoms))
    atoms_dict['chemical_symbols'] = list(set(syms))
    atoms_dict['symbol_counts'] = {sym: syms.count(sym) for sym in syms}
    if cell is not None and np.linalg.det(cell) > 0:
        atoms_dict['volume'] = atoms.get_volume()

    return json.loads(encode(atoms_dict)) 
开发者ID:ulissigroup,项目名称:GASpy,代码行数:58,代码来源:mongo.py


注:本文中的spglib.get_spacegroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。