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

Mistake in example "A Simple Eigenvalue Solver" ??

+2 votes

Hi!

Is it possible that there is a mistake in the example "A Simple Eigenvalue Solver"? The lhs of the equation is treated in the weak form, but the rhs is not. Should it not be a generalized eigenvalue problem where the rhs matrix is formed from dot(v,u)*dx? Or am I mistaken?

Thanks for any responses.
Torsten

asked Feb 4, 2014 by torsten FEniCS Novice (240 points)

1 Answer

+4 votes

The example provides, as its title aims to indicate, a simple eigenvalue solver. Hence, the example used is just a basic eigenvalue problem. So, no I wouldn't say that it is a mistake.

One might say that the generalized eigenvalue problem that you are referring to is more interesting, however, but that is the topic of a different demo.

answered Feb 4, 2014 by Marie E. Rognes FEniCS User (5,380 points)

Could you briefly comment on why the eigenfunctions in 2d seem incorrect?

from dolfin import *

# setup mesh, space and form
N = 5
mesh = UnitSquareMesh(N, N)
V = FunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v))*dx

# assemble and solve EVP
A = PETScMatrix()
assemble(a, tensor=A)
eigensolver = SLEPcEigenSolver(A)
eigensolver.solve()
r, c, rx, cx = eigensolver.get_eigenpair(0)

# setup and plot first eigenfunction
u = Function(V)
u.vector()[:] = rx
plot(u, title="EF", interactive=True)

Please ask separate questions as separate questions. If you do so, please also state what you expect the correct answer to be.

My question is actually the same as this question which is why I didn't want to create a duplicate. Or should I?
The resulting eigenfunction for some reason is oscillating (apparently due to mesh dependent sign switches in the coefficient vector).

Keep in mind that SLEPc's Eigensolver returns a vector containing the eigenvalues in descending order of magnitude. The first eigenvalue has the largest magnitude. This corresponds to a high frequency mode (extremely oscillatory). You may notice that smallest eigenvalue (greater than 1.0 in magnitude) corresponds to the fundamental (lowest order) mode. This mode has far fewer oscillations and is probably what you're most interested in.

...