本文整理汇总了Python中pymatgen.core.operations.SymmOp.reflection方法的典型用法代码示例。如果您正苦于以下问题:Python SymmOp.reflection方法的具体用法?Python SymmOp.reflection怎么用?Python SymmOp.reflection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.core.operations.SymmOp
的用法示例。
在下文中一共展示了SymmOp.reflection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _find_mirror
# 需要导入模块: from pymatgen.core.operations import SymmOp [as 别名]
# 或者: from pymatgen.core.operations.SymmOp import reflection [as 别名]
def _find_mirror(self, axis):
"""
Looks for mirror symmetry of specified type about axis. Possible
types are "h" or "vd". Horizontal (h) mirrors are perpendicular to
the axis while vertical (v) or diagonal (d) mirrors are parallel. v
mirrors has atoms lying on the mirror plane while d mirrors do
not.
"""
mirror_type = ""
# First test whether the axis itself is the normal to a mirror plane.
if self.is_valid_op(SymmOp.reflection(axis)):
self.symmops.append(SymmOp.reflection(axis))
mirror_type = "h"
else:
# Iterate through all pairs of atoms to find mirror
for s1, s2 in itertools.combinations(self.centered_mol, 2):
if s1.species_and_occu == s2.species_and_occu:
normal = s1.coords - s2.coords
if np.dot(normal, axis) < self.tol:
op = SymmOp.reflection(normal)
if self.is_valid_op(op):
self.symmops.append(op)
if len(self.rot_sym) > 1:
mirror_type = "d"
for v, r in self.rot_sym:
if not np.linalg.norm(v - axis) < self.tol:
if np.dot(v, normal) < self.tol:
mirror_type = "v"
break
else:
mirror_type = "v"
break
return mirror_type
示例2: test_reflection
# 需要导入模块: from pymatgen.core.operations import SymmOp [as 别名]
# 或者: from pymatgen.core.operations.SymmOp import reflection [as 别名]
def test_reflection(self):
normal = np.random.rand(3)
origin = np.random.rand(3)
refl = SymmOp.reflection(normal, origin)
point = np.random.rand(3)
newcoord = refl.operate(point)
# Distance to the plane should be negatives of each other.
self.assertAlmostEqual(np.dot(newcoord - origin, normal),
-np.dot(point - origin, normal))