# Calculating local eigenvalues and eigenvectors for use in weak form

Hello.

I’m currently doing some work which involves finding the eigenvalues and eigenvectors of the 2D stress tensor. I can calculate them per element but my issue is that I need to use them to form three new tensors: M, Omega and B pictured below. These then get used in a weak formulation to solve for stress at the next time step.

My question therefore is, how do I calculate the eigenvalues and eigenvectors such that they can be used to construct new tensors that are used in the weak formulation and are unique depending on the element.

Thanks in advance.

Hi @dohertyw1 ,

once you have eigenvalues and eigenvectors symbolically obtained in UFL, you could do

``````l1, l2, v1, v2 = eigendecomposition(u)

R = ufl.as_matrix([[v1[0], v2[0]],
[v1[1], v2[1]]])

def w(x):
return ufl.exp(x)

omega = R*ufl.as_matrix([[0, w(l1)],
[-w(l1), 0]])*R.T
``````

There are plenty resources available how to produce spectral decomposition symbolically for 2x2 or 3x3 matrix.

1 Like