本文整理汇总了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
)
示例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]),
}
示例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
示例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
示例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)
示例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))