本文整理汇总了Python中pymatgen.symmetry.analyzer.SpacegroupAnalyzer.get_spacegroup方法的典型用法代码示例。如果您正苦于以下问题:Python SpacegroupAnalyzer.get_spacegroup方法的具体用法?Python SpacegroupAnalyzer.get_spacegroup怎么用?Python SpacegroupAnalyzer.get_spacegroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.symmetry.analyzer.SpacegroupAnalyzer
的用法示例。
在下文中一共展示了SpacegroupAnalyzer.get_spacegroup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_snl
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_spacegroup [as 别名]
def add_snl(self, snl, force_new=False, snlgroup_guess=None):
try:
self.lock_db()
snl_id = self._get_next_snl_id()
spstruc = snl.structure.copy()
spstruc.remove_oxidation_states()
sf = SpacegroupAnalyzer(spstruc, SPACEGROUP_TOLERANCE, ANGLE_TOLERANCE)
sf.get_spacegroup()
sgnum = sf.get_spacegroup_number() if sf.get_spacegroup_number() \
else -1
sgsym = sf.get_spacegroup_symbol() if sf.get_spacegroup_symbol() \
else 'unknown'
sghall = sf.get_hall() if sf.get_hall() else 'unknown'
sgxtal = sf.get_crystal_system() if sf.get_crystal_system() \
else 'unknown'
sglatt = sf.get_lattice_type() if sf.get_lattice_type() else 'unknown'
sgpoint = sf.get_point_group()
mpsnl = MPStructureNL.from_snl(snl, snl_id, sgnum, sgsym, sghall,
sgxtal, sglatt, sgpoint)
snlgroup, add_new, spec_group = self.add_mpsnl(mpsnl, force_new, snlgroup_guess)
self.release_lock()
return mpsnl, snlgroup.snlgroup_id, spec_group
except:
self.release_lock()
traceback.print_exc()
raise ValueError("Error while adding SNL!")
示例2: test_tensor
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_spacegroup [as 别名]
def test_tensor(self):
"""Initialize Tensor"""
lattice = Lattice.hexagonal(4,6)
#rprimd = np.array([[0,0.5,0.5],[0.5,0,0.5],[0.5,0.5,0]])
#rprimd = rprimd*10
#lattice = Lattice(rprimd)
structure = Structure(lattice, ["Ga", "As"],
[[0, 0, 0], [0.5, 0.5, 0.5]])
#finder = SymmetryFinder(structure)
finder = SpacegroupAnalyzer(structure)
spacegroup = finder.get_spacegroup()
pointgroup = finder.get_point_group()
cartesian_tensor = [[2,3,1.2],[3,4,1.0],[1.2,1.0,6]]
tensor = Tensor.from_cartesian_tensor(cartesian_tensor,lattice.reciprocal_lattice,space="g")
red_tensor = tensor.reduced_tensor
tensor2 = Tensor(red_tensor,lattice.reciprocal_lattice,space="g")
assert(((np.abs(tensor2.cartesian_tensor)-np.abs(cartesian_tensor)) < 1E-8).all())
self.assertTrue(tensor==tensor2)
print(tensor)
#print("non-symmetrized cartesian_tensor = ",tensor2.cartesian_tensor)
tensor2.symmetrize(structure)
#print("symmetrized_cartesian_tensor = ",tensor2.cartesian_tensor)
self.serialize_with_pickle(tensor)
示例3: complete_ordering
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_spacegroup [as 别名]
def complete_ordering(self, structure, num_remove_dict):
self.logger.debug("Performing complete ordering...")
all_structures = []
symprec = 0.2
s = SpacegroupAnalyzer(structure, symprec=symprec)
self.logger.debug("Symmetry of structure is determined to be {}."
.format(s.get_spacegroup_symbol()))
sg = s.get_spacegroup()
tested_sites = []
starttime = time.time()
self.logger.debug("Performing initial ewald sum...")
ewaldsum = EwaldSummation(structure)
self.logger.debug("Ewald sum took {} seconds."
.format(time.time() - starttime))
starttime = time.time()
allcombis = []
for ind, num in num_remove_dict.items():
allcombis.append(itertools.combinations(ind, num))
count = 0
for allindices in itertools.product(*allcombis):
sites_to_remove = []
indices_list = []
for indices in allindices:
sites_to_remove.extend([structure[i] for i in indices])
indices_list.extend(indices)
s_new = structure.copy()
s_new.remove_sites(indices_list)
energy = ewaldsum.compute_partial_energy(indices_list)
already_tested = False
for i, tsites in enumerate(tested_sites):
tenergy = all_structures[i]["energy"]
if abs((energy - tenergy) / len(s_new)) < 1e-5 and \
sg.are_symmetrically_equivalent(sites_to_remove,
tsites,
symm_prec=symprec):
already_tested = True
if not already_tested:
tested_sites.append(sites_to_remove)
all_structures.append({"structure": s_new, "energy": energy})
count += 1
if count % 10 == 0:
timenow = time.time()
self.logger.debug("{} structures, {:.2f} seconds."
.format(count, timenow - starttime))
self.logger.debug("Average time per combi = {} seconds"
.format((timenow - starttime) / count))
self.logger.debug("{} symmetrically distinct structures found."
.format(len(all_structures)))
self.logger.debug("Total symmetrically distinct structures found = {}"
.format(len(all_structures)))
all_structures = sorted(all_structures, key=lambda s: s["energy"])
return all_structures