本文整理汇总了Python中pymatgen.analysis.elasticity.strain.Strain.get_deformation_matrix方法的典型用法代码示例。如果您正苦于以下问题:Python Strain.get_deformation_matrix方法的具体用法?Python Strain.get_deformation_matrix怎么用?Python Strain.get_deformation_matrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.analysis.elasticity.strain.Strain
的用法示例。
在下文中一共展示了Strain.get_deformation_matrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_new
# 需要导入模块: from pymatgen.analysis.elasticity.strain import Strain [as 别名]
# 或者: from pymatgen.analysis.elasticity.strain.Strain import get_deformation_matrix [as 别名]
def test_new(self):
test_strain = Strain([[0., 0.01, 0.],
[0.01, 0.0002, 0.],
[0., 0., 0.]])
self.assertArrayAlmostEqual(
test_strain,
test_strain.get_deformation_matrix().green_lagrange_strain)
self.assertRaises(ValueError, Strain, [[0.1, 0.1, 0],
[0, 0, 0],
[0, 0, 0]])
示例2: StrainTest
# 需要导入模块: from pymatgen.analysis.elasticity.strain import Strain [as 别名]
# 或者: from pymatgen.analysis.elasticity.strain.Strain import get_deformation_matrix [as 别名]
class StrainTest(PymatgenTest):
def setUp(self):
self.norm_str = Strain.from_deformation([[1.02, 0, 0],
[0, 1, 0],
[0, 0, 1]])
self.ind_str = Strain.from_deformation([[1, 0.02, 0],
[0, 1, 0],
[0, 0, 1]])
self.non_ind_str = Strain.from_deformation([[1, 0.02, 0.02],
[0, 1, 0],
[0, 0, 1]])
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
self.no_dfm = Strain([[0., 0.01, 0.],
[0.01, 0.0002, 0.],
[0., 0., 0.]])
def test_new(self):
test_strain = Strain([[0., 0.01, 0.],
[0.01, 0.0002, 0.],
[0., 0., 0.]])
self.assertArrayAlmostEqual(
test_strain,
test_strain.get_deformation_matrix().green_lagrange_strain)
self.assertRaises(ValueError, Strain, [[0.1, 0.1, 0],
[0, 0, 0],
[0, 0, 0]])
def test_from_deformation(self):
self.assertArrayAlmostEqual(self.norm_str,
[[0.0202, 0, 0],
[0, 0, 0],
[0, 0, 0]])
self.assertArrayAlmostEqual(self.ind_str,
[[0., 0.01, 0.],
[0.01, 0.0002, 0.],
[0., 0., 0.]])
self.assertArrayAlmostEqual(self.non_ind_str,
[[0., 0.01, 0.01],
[0.01, 0.0002, 0.0002],
[0.01, 0.0002, 0.0002]])
def test_from_index_amount(self):
# From voigt index
test = Strain.from_index_amount(2, 0.01)
should_be = np.zeros((3, 3))
should_be[2, 2] = 0.01
self.assertArrayAlmostEqual(test, should_be)
# from full-tensor index
test = Strain.from_index_amount((1, 2), 0.01)
should_be = np.zeros((3, 3))
should_be[1, 2] = should_be[2, 1] = 0.01
self.assertArrayAlmostEqual(test, should_be)
def test_properties(self):
# deformation matrix
self.assertArrayAlmostEqual(self.ind_str.get_deformation_matrix(),
[[1, 0.02, 0],
[0, 1, 0],
[0, 0, 1]])
symm_dfm = Strain(self.no_dfm).get_deformation_matrix(shape="symmetric")
self.assertArrayAlmostEqual(symm_dfm, [[0.99995,0.0099995, 0],
[0.0099995,1.00015, 0],
[0, 0, 1]])
self.assertArrayAlmostEqual(self.no_dfm.get_deformation_matrix(),
[[1, 0.02, 0],
[0, 1, 0],
[0, 0, 1]])
# voigt
self.assertArrayAlmostEqual(self.non_ind_str.voigt,
[0, 0.0002, 0.0002, 0.0004, 0.02, 0.02])
def test_convert_strain_to_deformation(self):
strain = Tensor(np.random.random((3, 3))).symmetrized
while not (np.linalg.eigvals(strain) > 0).all():
strain = Tensor(np.random.random((3, 3))).symmetrized
upper = convert_strain_to_deformation(strain, shape="upper")
symm = convert_strain_to_deformation(strain, shape="symmetric")
self.assertArrayAlmostEqual(np.triu(upper), upper)
self.assertTrue(Tensor(symm).is_symmetric())
for defo in upper, symm:
self.assertArrayAlmostEqual(defo.green_lagrange_strain, strain)