This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

plot eigenmodes using eigs

+1 vote

Hello

I'm solving an eigenvalue problem using "eigs" as i show below

 A=PETScMatrix()
 assemble(a, tensor = A)
 B=PETScMatrix()
 assemble(m, tensor = B)
 A = sp.csr_matrix(A.mat().getValuesCSR()[::-1])
 B = sp.csr_matrix(B.mat().getValuesCSR()[::-1])
 AA=(A+A.T)/2.0 #only to ensure symmetry
 BB=(B+B.T)/2.0 #only to ensure symmetry
 neig=3
 v, VV= eigs(AA, neig, BB, sigma=38.) #v is the eigenvalue, VV eigenvector, sigma is the shift

the examples online show how to solve the problem, but nothing about plotting the eigenmodes. Any suggestion?

asked Dec 22, 2016 by alberin FEniCS Novice (150 points)

1 Answer

+1 vote

Hi,
see the demo here

Once you have eigenvector rx selected from VV you can plot it with following code snippet:

# Initialize function and assign eigenvector
u = Function(V)
u.vector()[:] = rx

# Plot eigenfunction
plot(u)
interactive()

hope it helps.
P.

answered Jan 3, 2017 by petrH FEniCS Novice (580 points)
...