class DeformationTest(PymatgenTest): def setUp(self): self.norm_defo = Deformation.from_index_amount((0, 0), 0.02) self.ind_defo = Deformation.from_index_amount((0, 1), 0.02) self.non_ind_defo = Deformation([[1.0, 0.02, 0.02], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) self.structure = Structure(lattice, ["Si", "Si"], [[0, 0, 0], [0.75, 0.5, 0.75]]) def test_properties(self): # green_lagrange_strain self.assertArrayAlmostEqual( self.ind_defo.green_lagrange_strain, [[0., 0.01, 0.], [0.01, 0.0002, 0.], [0., 0., 0.]]) self.assertArrayAlmostEqual( self.non_ind_defo.green_lagrange_strain, [[0., 0.01, 0.01], [0.01, 0.0002, 0.0002], [0.01, 0.0002, 0.0002]]) def test_independence(self): self.assertFalse(self.non_ind_defo.is_independent()) self.assertEqual(self.ind_defo.get_perturbed_indices()[0], (0, 1)) def test_apply_to_structure(self): strained_norm = self.norm_defo.apply_to_structure(self.structure) strained_ind = self.ind_defo.apply_to_structure(self.structure) strained_non = self.non_ind_defo.apply_to_structure(self.structure) # Check lattices self.assertArrayAlmostEqual( strained_norm.lattice.matrix, [[3.9170018886, 0, 0], [1.958500946136, 3.32571019, 0], [0, -2.21713849, 3.13550906]]) self.assertArrayAlmostEqual( strained_ind.lattice.matrix, [[3.84019793, 0, 0], [1.9866132, 3.32571019, 0], [-0.04434277, -2.21713849, 3.13550906]]) self.assertArrayAlmostEqual( strained_non.lattice.matrix, [[3.84019793, 0, 0], [1.9866132, 3.3257102, 0], [0.0183674, -2.21713849, 3.13550906]]) # Check coordinates self.assertArrayAlmostEqual(strained_norm.sites[1].coords, [3.91700189, 1.224e-06, 2.3516318]) self.assertArrayAlmostEqual(strained_ind.sites[1].coords, [3.84019793, 1.224e-6, 2.3516318]) self.assertArrayAlmostEqual(strained_non.sites[1].coords, [3.8872306, 1.224e-6, 2.3516318]) # Check convention for applying transformation for vec, defo_vec in zip(self.structure.lattice.matrix, strained_non.lattice.matrix): new_vec = np.dot(self.non_ind_defo, np.transpose(vec)) self.assertArrayAlmostEqual(new_vec, defo_vec) for coord, defo_coord in zip(self.structure.cart_coords, strained_non.cart_coords): new_coord = np.dot(self.non_ind_defo, np.transpose(coord)) self.assertArrayAlmostEqual(new_coord, defo_coord)
class DeformationTest(PymatgenTest): def setUp(self): self.norm_defo = Deformation.from_index_amount((0, 0), 0.02) self.ind_defo = Deformation.from_index_amount((0, 1), 0.02) self.non_ind_defo = Deformation([[1.0, 0.02, 0.02], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) self.structure = Structure(lattice, ["Si", "Si"], [[0, 0, 0], [0.75, 0.5, 0.75]]) def test_properties(self): # green_lagrange_strain self.assertArrayAlmostEqual(self.ind_defo.green_lagrange_strain, [[0., 0.01, 0.], [0.01, 0.0002, 0.], [0., 0., 0.]]) self.assertArrayAlmostEqual(self.non_ind_defo.green_lagrange_strain, [[0., 0.01, 0.01], [0.01, 0.0002, 0.0002], [0.01, 0.0002, 0.0002]]) def test_independence(self): self.assertFalse(self.non_ind_defo.is_independent()) self.assertEqual(self.ind_defo.get_perturbed_indices()[0], (0, 1)) def test_apply_to_structure(self): strained_norm = self.norm_defo.apply_to_structure(self.structure) strained_ind = self.ind_defo.apply_to_structure(self.structure) strained_non = self.non_ind_defo.apply_to_structure(self.structure) # Check lattices self.assertArrayAlmostEqual(strained_norm.lattice.matrix, [[3.9170018886, 0, 0], [1.958500946136, 3.32571019, 0], [0, -2.21713849, 3.13550906]]) self.assertArrayAlmostEqual(strained_ind.lattice.matrix, [[3.84019793, 0.07680396, 0], [1.92009897, 3.36411217, 0], [0, -2.21713849, 3.13550906]]) self.assertArrayAlmostEqual(strained_non.lattice.matrix, [[3.84019793, 0.07680396, 0.07680396], [1.92009897, 3.36411217, 0.0384019794], [0, -2.21713849, 3.13550906]]) # Check coordinates self.assertArrayAlmostEqual(strained_norm.sites[1].coords, [3.91700189, 1.224e-06, 2.3516318]) self.assertArrayAlmostEqual(strained_ind.sites[1].coords, [3.84019793, 0.07680518, 2.3516318]) self.assertArrayAlmostEqual(strained_non.sites[1].coords, [3.84019793, 0.07680518, 2.42843575])
class DeformationTest(PymatgenTest): def setUp(self): self.norm_defo = Deformation.from_index_amount((0, 0), 0.02) self.ind_defo = Deformation.from_index_amount((0, 1), 0.02) self.non_ind_defo = Deformation([[1.0, 0.02, 0.02], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) self.structure = Structure(lattice, ["Si", "Si"], [[0, 0, 0], [0.75, 0.5, 0.75]]) def test_properties(self): # green_lagrange_strain self.assertArrayAlmostEqual( self.ind_defo.green_lagrange_strain, [[0., 0.01, 0.], [0.01, 0.0002, 0.], [0., 0., 0.]]) self.assertArrayAlmostEqual( self.non_ind_defo.green_lagrange_strain, [[0., 0.01, 0.01], [0.01, 0.0002, 0.0002], [0.01, 0.0002, 0.0002]]) def test_independence(self): self.assertFalse(self.non_ind_defo.is_independent()) self.assertEqual(self.ind_defo.get_perturbed_indices()[0], (0, 1)) def test_apply_to_structure(self): strained_norm = self.norm_defo.apply_to_structure(self.structure) strained_ind = self.ind_defo.apply_to_structure(self.structure) strained_non = self.non_ind_defo.apply_to_structure(self.structure) # Check lattices self.assertArrayAlmostEqual( strained_norm.lattice.matrix, [[3.9170018886, 0, 0], [1.958500946136, 3.32571019, 0], [0, -2.21713849, 3.13550906]]) self.assertArrayAlmostEqual( strained_ind.lattice.matrix, [[3.84019793, 0.07680396, 0], [1.92009897, 3.36411217, 0], [0, -2.21713849, 3.13550906]]) self.assertArrayAlmostEqual(strained_non.lattice.matrix, [[3.84019793, 0.07680396, 0.07680396], [1.92009897, 3.36411217, 0.0384019794], [0, -2.21713849, 3.13550906]]) # Check coordinates self.assertArrayAlmostEqual(strained_norm.sites[1].coords, [3.91700189, 1.224e-06, 2.3516318]) self.assertArrayAlmostEqual(strained_ind.sites[1].coords, [3.84019793, 0.07680518, 2.3516318]) self.assertArrayAlmostEqual(strained_non.sites[1].coords, [3.84019793, 0.07680518, 2.42843575])
class DeformationTest(PymatgenTest): def setUp(self): self.norm_defo = Deformation.from_index_amount((0, 0), 0.02) self.ind_defo = Deformation.from_index_amount((0, 1), 0.02) self.non_ind_defo = Deformation([[1.0, 0.02, 0.02], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) self.structure = Structure(lattice, ["Si", "Si"], [[0, 0, 0], [0.75, 0.5, 0.75]]) def test_properties(self): # green_lagrange_strain self.assertArrayAlmostEqual(self.ind_defo.green_lagrange_strain, [[0., 0.01, 0.], [0.01, 0.0002, 0.], [0., 0., 0.]]) self.assertArrayAlmostEqual(self.non_ind_defo.green_lagrange_strain, [[0., 0.01, 0.01], [0.01, 0.0002, 0.0002], [0.01, 0.0002, 0.0002]]) def test_independence(self): self.assertFalse(self.non_ind_defo.is_independent()) self.assertEqual(self.ind_defo.get_perturbed_indices()[0], (0, 1)) def test_apply_to_structure(self): strained_norm = self.norm_defo.apply_to_structure(self.structure) strained_ind = self.ind_defo.apply_to_structure(self.structure) strained_non = self.non_ind_defo.apply_to_structure(self.structure) # Check lattices self.assertArrayAlmostEqual(strained_norm.lattice.matrix, [[3.9170018886, 0, 0], [1.958500946136, 3.32571019, 0], [0, -2.21713849, 3.13550906]]) self.assertArrayAlmostEqual(strained_ind.lattice.matrix, [[3.84019793, 0, 0], [1.9866132, 3.32571019, 0], [-0.04434277, -2.21713849, 3.13550906]]) self.assertArrayAlmostEqual(strained_non.lattice.matrix, [[3.84019793, 0, 0], [1.9866132, 3.3257102, 0], [0.0183674, -2.21713849, 3.13550906]]) # Check coordinates self.assertArrayAlmostEqual(strained_norm.sites[1].coords, [3.91700189, 1.224e-06, 2.3516318]) self.assertArrayAlmostEqual(strained_ind.sites[1].coords, [3.84019793, 1.224e-6, 2.3516318]) self.assertArrayAlmostEqual(strained_non.sites[1].coords, [3.8872306, 1.224e-6, 2.3516318]) # Check convention for applying transformation for vec, defo_vec in zip(self.structure.lattice.matrix, strained_non.lattice.matrix): new_vec = np.dot(self.non_ind_defo, np.transpose(vec)) self.assertArrayAlmostEqual(new_vec, defo_vec) for coord, defo_coord in zip(self.structure.cart_coords, strained_non.cart_coords): new_coord = np.dot(self.non_ind_defo, np.transpose(coord)) self.assertArrayAlmostEqual(new_coord, defo_coord)