本文整理汇总了Python中spglib.get_symmetry_dataset方法的典型用法代码示例。如果您正苦于以下问题:Python spglib.get_symmetry_dataset方法的具体用法?Python spglib.get_symmetry_dataset怎么用?Python spglib.get_symmetry_dataset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spglib
的用法示例。
在下文中一共展示了spglib.get_symmetry_dataset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_symmetry_dataset
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
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(wrap=False), 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,
)
示例2: __init__
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
def __init__(self, atoms, tol=1e-5, ang_tol=-1):
"""Atoms object interface with spglib symmetry finder:
https://atztogo.github.io/spglib/python-spglib.html#python-spglib
Parameters
----------
atoms : Atoms object
Atomic structure to return the symmetry operations for.
tol : float
Tolerance for floating point precision errors.
"""
self.lattice = atoms.cell
self.positions = atoms.get_scaled_positions()
self.numbers = atoms.get_atomic_numbers()
self.magmoms = atoms.get_initial_magnetic_moments()
self.modified_numbers = get_modified_spin_symbols(
self.numbers, self.magmoms)
self.tol = tol
cell = (self.lattice, self.positions, self.modified_numbers)
self.data = spglib.get_symmetry_dataset(
cell, symprec=tol, angle_tolerance=ang_tol)
示例3: get_symmetry_dataset
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
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
示例4: number
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
def number(self, symprec=1e-5):
return int(self.get_symmetry_dataset(symprec)['number'])
示例5: symbol
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
def symbol(self, symprec=1e-5):
return deep_unicode(self.get_symmetry_dataset(symprec)['international'])
示例6: hall_number
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
def hall_number(self, symprec=1e-5):
return self.get_symmetry_dataset(symprec)['hall_number']
示例7: get_symmetry_dataset
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
def get_symmetry_dataset(structure,
symprec=1e-3):
"""
Get complete symmetry information for `structure` using `spglib`.
Args:
structure: :class:`qmpy.Structure` object with the crystal structure.
symprec: Float with the Cartesian distance tolerance.
Returns:
Dictionary of various symmetry related information:
- `choice`: Choice of origin, basis vector centering
- `equivalent_atoms`: Nx1 array of integers specifying which atoms are
symmetrically equivalent
- `hall`: String with the Hall symbol
- `hall_number`: Long integer with the Hall number
- `international`: String ITC space group short symbol
- `mapping_to_primitive`: Nx1 array of integers with the atomic indices
in the primitive unit cell
- `number`: Long integer with the ITC space group number
- `origin_shift`: 1x3 array of float with shift of origin
- `pointgroup`: String with the point group symbol
- `rotations`: Nx(3x3) array of float with rotation operations
- `std_lattice`: 3x3 array of float with standardized lattice vectors
- `std_positions`: Nx3 array of float with standardized atomic
positions in fractional coordinates
- `std_types`: Nx1 array of integers with atomic indices in the
standardized unit cell
- `std_mapping_to_primitive`: Nx1 array of integers with the atomic
indices in the standardized primitive unit cell
- `transformation_matrix`: 3x3 array of float with the transformation
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
)
示例8: test_cluster
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
def test_cluster():
global outstructs
global outstrings
print("=== Testing generation of point group clusters. This may take some time. ===")
from time import time
from spglib import get_symmetry_dataset
from pyxtal.symmetry import Group
from pyxtal.crystal import random_cluster
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
slow = []
failed = []
print(" Point group # | Symbol | Time Elapsed")
skip = []#[32,55,56]#[28,29,30,31,32,55,56]
for sg in range(1, 57):
if sg not in skip:
multiplicity = len(Group(sg, dim=0)[0])#multiplicity of the general position
start = time()
rand_crystal = random_cluster(sg, ['C'], [multiplicity], 1.0)
end = time()
timespent = np.around((end - start), decimals=2)
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(sg)
if rand_crystal.valid:
if check_struct_group(rand_crystal, sg, dim=0):
pass
else:
t += " xxxxx"
outstructs.append(rand_crystal.struct)
outstrings.append(str("Cluster_"+str(sg)+".vasp"))
pgsymbol = Group(sg, dim=0).symbol
print("\t"+str(sg)+"\t|\t"+pgsymbol+"\t|\t"+t)
else:
print("~~~~ Error: Could not generate space group "+str(sg)+" after "+t)
failed.append(sg)
if slow != []:
print("~~~~ The following space groups took more than 60 seconds to generate:")
for i in slow:
print(" "+str(i))
if failed != []:
print("~~~~ The following space groups failed to generate:")
for i in failed:
print(" "+str(i))
示例9: optimize
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
def optimize(struc, dir1):
os.mkdir(dir1)
os.chdir(dir1)
time0 = 0
# Step1: ISIF = 2
struc.set_calculator(set_vasp(level=0, pstress=pstress)) #, setup=setup))
print(struc.get_potential_energy())
time, ncore = read_OUTCAR()
time0 += time
print('time for vasp calcs0 (seconds): ', time)
# Step2: ISIF = 3
struc = read('CONTCAR',format='vasp')
struc.set_calculator(set_vasp(level=1, pstress=pstress)) #, setup=setup))
print(struc.get_potential_energy())
time, ncore = read_OUTCAR()
time0 += time
print('time for vasp calcs1 (seconds): ', time)
# Step3: ISIF = 3 with high precision
struc = read('CONTCAR',format='vasp')
if good_lattice(struc):
struc = symmetrize_cell(struc, mode='C')
struc.set_calculator(set_vasp(level=2, pstress=pstress)) #, setup=setup))
print(struc.get_potential_energy())
time, ncore = read_OUTCAR()
time0 += time
print('time for vasp calcs2 (seconds): ', time)
struc = read('CONTCAR',format='vasp')
if good_lattice(struc):
struc = symmetrize_cell(struc, mode='P')
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))
示例10: step
# 需要导入模块: import spglib [as 别名]
# 或者: from spglib import get_symmetry_dataset [as 别名]
def step(self):
f = np.vstack((self.stress, self.force))
pos = np.vstack((self.struc.lattice_matrix, self.struc.cart_coords))
vf = np.vdot(f, self.v)
if vf > 0.0:
self.v = (1.0 - self.a) * self.v + self.a * f / np.sqrt(
np.vdot(f, f)) * np.sqrt(np.vdot(self.v, self.v))
if self.Nsteps > self.Nmin:
self.dt = min(self.dt * self.finc, self.dtmax)
self.a *= self.fa
self.Nsteps += 1
else:
self.v[:] *= 0.0
self.a = self.astart
self.dt *= self.fdec
self.Nsteps = 0
self.v += self.dt * f
dr = self.dt * self.v #needs to impose constraints
normdr = np.sqrt(np.vdot(dr, dr))
if normdr > self.maxmove:
dr = self.maxmove * dr / normdr
#print('frac0', np.dot(pos[3:,:], np.linalg.inv(pos[:3,:])))
#Symmetrize the force
if self.symmetrize:
# f[:3, :] is the gradient for force, need to symmetrize it as well
dr[:3, :] = self.symmetrized_stress(dr[:3, :])
dr[3:, :] = np.dot(self.struc.frac_coords, dr[:3, :])
f_frac = np.dot(dr[3:,:], np.linalg.inv(pos[:3,:] - dr[:3, :]))
f_frac = self.symmetrized_force(f_frac)
dr[3:,:] += np.dot(f_frac, pos[:3,:] - dr[:3, :])
#pos = pos - dr
#Symmetrize positions
#if self.symmetrize:
# pos = self.symmetrized_coords(pos)
#print(self.force)
#print(self.v)
self.struc.lattice_matrix = pos[:3, :] - dr[:3, :]
self.struc.cart_coords = pos[3:, :] - dr[3:, :]
self.struc.frac_coords = np.dot(self.struc.cart_coords, np.linalg.inv(self.struc.lattice_matrix))
self.volume = np.linalg.det(self.struc.lattice_matrix)
#sg = get_symmetry_dataset((pos[:3, :], self.struc.frac_coords, [6]*4), symprec=0.1)['number']
#print(sg)
#if self.symmetrize and sg <19:
# print(sg)
# print('dr\n', dr)
# print('pos\n', pos)
# print('frac\n', self.struc.frac_coords)
# print('force\n', f_frac)
# sys.exit()
self.update()