def test_eigenvalues_and_vectors(self): """Ensure that eigenvalues and -vectors are the solution to the characteristic polynomial.""" A = tensor.symmetric(np.random.rand(self.n, 3, 3)) lambd = tensor.eigenvalues(A) x = tensor.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)
def test_eigenvectors_RHS(self): """Ensure that RHS coordinate system does only change sign of determinant.""" A = tensor.symmetric(np.random.rand(self.n, 3, 3)) LRHS = np.linalg.det(tensor.eigenvectors(A, RHS=False)) RHS = np.linalg.det(tensor.eigenvectors(A, RHS=True)) assert np.allclose(np.abs(LRHS), RHS)
def test_add_eigenvector(self, default, eigenvalue, idx): default.add_stress_Cauchy('P', 'F') default.add_eigenvector('sigma', eigenvalue) in_memory = tensor.eigenvectors(default.place('sigma'))[:, idx] in_file = default.place(f'v_{eigenvalue}(sigma)') assert np.allclose(in_memory, in_file)