本文整理汇总了Python中pymatgen.core.structure_modifier.StructureEditor.modify_lattice方法的典型用法代码示例。如果您正苦于以下问题:Python StructureEditor.modify_lattice方法的具体用法?Python StructureEditor.modify_lattice怎么用?Python StructureEditor.modify_lattice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.core.structure_modifier.StructureEditor
的用法示例。
在下文中一共展示了StructureEditor.modify_lattice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _calc_rms
# 需要导入模块: from pymatgen.core.structure_modifier import StructureEditor [as 别名]
# 或者: from pymatgen.core.structure_modifier.StructureEditor import modify_lattice [as 别名]
def _calc_rms(self, struct1, struct2, break_on_match):
"""
Calculate RMS displacement between two structures
Args:
struct1:
1st structure
struct2:
2nd structure
break_on_match:
True or False. Will break if the maximum
distance found is less than the
provided stol
Returns:
rms displacement normalized by (Vol / nsites) ** (1/3) and
maximum distance found between two paired sites
"""
stol = self.stol
comparator = self._comparator
#initial stored rms
stored_rms = None
if comparator.get_structure_hash(struct1) != \
comparator.get_structure_hash(struct2):
return None
#primitive cell transformation
if self._primitive_cell and struct1.num_sites != struct2.num_sites:
struct1 = struct1.get_primitive_structure()
struct2 = struct2.get_primitive_structure()
# Same number of sites
if struct1.num_sites != struct2.num_sites:
return None
# Get niggli reduced cells. Though technically not necessary, this
# minimizes cell lengths and speeds up the matching of skewed
# cells considerably.
struct1 = struct1.get_reduced_structure(reduction_algo="niggli")
struct2 = struct2.get_reduced_structure(reduction_algo="niggli")
nl1 = struct1.lattice
nl2 = struct2.lattice
#rescale lattice to same volume
if self._scale:
scale_vol = (nl2.volume / nl1.volume) ** (1 / 6)
se1 = StructureEditor(struct1)
nl1 = Lattice(nl1.matrix * scale_vol)
se1.modify_lattice(nl1)
struct1 = se1.modified_structure
se2 = StructureEditor(struct2)
nl2 = Lattice(nl2.matrix / scale_vol)
se2.modify_lattice(nl2)
struct2 = se2.modified_structure
#Volume to determine invalid lattices
vol_tol = nl2.volume / 2
#fractional tolerance of atomic positions (2x for initial fitting)
frac_tol = \
np.array([stol / ((1 - self.ltol) * np.pi) * i for
i in struct1.lattice.reciprocal_lattice.abc]) * \
((nl1.volume + nl2.volume) /
(2 * struct1.num_sites)) ** (1.0 / 3)
#generate structure coordinate lists
species_list = []
s1 = []
for site in struct1:
found = False
for i, species in enumerate(species_list):
if comparator.are_equal(site.species_and_occu, species):
found = True
s1[i].append(site.frac_coords)
break
if not found:
s1.append([site.frac_coords])
species_list.append(site.species_and_occu)
zipped = sorted(zip(s1, species_list), key=lambda x: len(x[0]))
s1 = [x[0] for x in zipped]
species_list = [x[1] for x in zipped]
s2_cart = [[] for i in s1]
for site in struct2:
found = False
for i, species in enumerate(species_list):
if comparator.are_equal(site.species_and_occu, species):
found = True
s2_cart[i].append(site.coords)
break
#if no site match found return None
if not found:
return None
#check that sizes of the site groups are identical
for f1, c2 in zip(s1, s2_cart):
#.........这里部分代码省略.........