Beispiel #1
0
 def test_eigenvalues(self):
     """Ensure that the characteristic polynomial can be solved."""
     A = mechanics.symmetric(np.random.rand(self.n, 3, 3))
     lambd = mechanics.eigenvalues(A)
     s = np.random.randint(self.n)
     for i in range(3):
         assert np.allclose(np.linalg.det(A[s] - lambd[s, i] * np.eye(3)),
                            .0)
Beispiel #2
0
 def test_eigenvalues_and_vectors(self):
     """Ensure that eigenvalues and -vectors are the solution to the characteristic polynomial."""
     A = mechanics.symmetric(np.random.rand(self.n, 3, 3))
     lambd = mechanics.eigenvalues(A)
     x = mechanics.eigenvectors(A)
     s = np.random.randint(self.n)
     for i in range(3):
         assert np.allclose(
             np.dot(A[s] - lambd[s, i] * np.eye(3), x[s, :, i]), .0)
Beispiel #3
0
 def test_stress_measures(self, function):
     """Ensure that all stress measures are equivalent for no deformation."""
     P = np.random.rand(self.n, 3, 3)
     assert np.allclose(
         function(P, np.broadcast_to(np.eye(3), (self.n, 3, 3))),
         mechanics.symmetric(P))
Beispiel #4
0
 def test_spherical_no_shear(self):
     """Ensure that sherical stress has max shear of 0.0."""
     A = mechanics.spherical_part(
         mechanics.symmetric(np.random.rand(self.n, 3, 3)), True)
     assert np.allclose(mechanics.maximum_shear(A), 0.0)
Beispiel #5
0
 def test_eigenvectors_RHS(self):
     """Ensure that RHS coordinate system does only change sign of determinant."""
     A = mechanics.symmetric(np.random.rand(self.n, 3, 3))
     LRHS = np.linalg.det(mechanics.eigenvectors(A, RHS=False))
     RHS = np.linalg.det(mechanics.eigenvectors(A, RHS=True))
     assert np.allclose(np.abs(LRHS), RHS)
Beispiel #6
0
 def test_transpose(self):
     """Ensure that a symmetric tensor equals its transpose."""
     x = mechanics.symmetric(np.random.rand(self.n, 3, 3))
     assert np.allclose(mechanics.transpose(x), x)
Beispiel #7
0
 def test_symmetric(self):
     """Ensure that a symmetric tensor is half of the sum of a tensor and its transpose."""
     x = np.random.rand(self.n, 3, 3)
     assert np.allclose(
         mechanics.symmetric(x) * 2.0,
         mechanics.transpose(x) + x)