# Eigensolver with Mass matrix

**URL:** <https://fenicsproject.discourse.group/t/eigensolver-with-mass-matrix/4740>\
**Category:** Linear Algebra\
**Created:** [December 15, 2020, 11:27am UTC](https://fenicsproject.discourse.group/t/eigensolver-with-mass-matrix/4740 "2020-12-15T11:27:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karlosjusus](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karlosjusus](https://fenicsproject.discourse.group/u/Karlosjusus)\
**Post date:** [December 15, 2020, 11:27am UTC](https://fenicsproject.discourse.group/t/eigensolver-with-mass-matrix/4740/1 "2020-12-15T11:27:04Z")

</div>

Hi everyone!  
I have to solve the next eigenvalue’s problem:  
\begin{equation} \sigma M u=Ju \end{equation}  
where M is the matrix mass and J is the Jacobian of Navier-Stokes equations.

```auto
from dolfin import *

P2 = VectorElement("P", mesh.ufl_cell(), 2)
P1 = FiniteElement("P", mesh.ufl_cell(), 1)
TH = MixedElement([P2, P1])
W = FunctionSpace(mesh, TH)

w = Function(W)
u,p= split(w) 
v, q=TestFunctions(W)
#Dummy problem
a=dot(u,v)*dx
#Jacobian, bcs are boundary conditions
J = derivative(a,w)
JM = PETScMatrix()

#mass matrix

vm = TestFunction(W)
um = TrialFunction(W)

mass_form = dot(vm,um)*dx
mass_action_form = action(mass_form, Constant((1.0,1.0,1.0)))
Mass= PETScMatrix()

dummy = inner(Constant((1.0, 1.0)), v) * dx
assemble_system(J, dummy, bcs, A_tensor = JM)
assemble_system(mass_form, dummy, bcs, A_tensor = Mass)

eigensolver = SLEPcEigenSolver(JM,Mass)

```

This works but I don’t know if it is correct.  
My question is: is it necessary to add the boundary conditions to the mass matrix or other conditions?

Thanks!
