def test_add_eigenvalue(self, default, eigenvalue, function): default.add_stress_Cauchy('P', 'F') default.add_eigenvalue('sigma', eigenvalue) in_memory = function(tensor.eigenvalues(default.place('sigma')), axis=1) in_file = default.place(f'lambda_{eigenvalue}(sigma)') assert np.allclose(in_memory, in_file)
def test_eigenvalues(self): """Ensure that the characteristic polynomial can be solved.""" A = tensor.symmetric(np.random.rand(self.n, 3, 3)) lambd = tensor.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)
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)