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

Using test/trial Function in eigenproblem

0 votes

Hello,

I am trying to solve an eigenvalue problem with FEniCS (SLEPc) and I don't really understand the concept of using trial/test function for this probleme !
Is it possible to don't use it?

V = FunctionSpace(mesh, "Nedelec 1st kind H(curl)", 3)
u = Function(V)
s = curl_t(u)*dx
S = PETScMatrix()
assemble(s, tensor=S)

For example, if I want calculate the eigenvalue of the curl_t operator, what is the procedure?
Thanks in advance !!

asked Apr 25, 2014 by Shizu FEniCS Novice (350 points)
edited Apr 25, 2014 by Shizu

1 Answer

+1 vote
 
Best answer

Hi, in the eigenvalue problem, you need TrialFunction and TestFunction to assemble matrix and then you compute its eigenvalues. I am not familiar with curl t but consider example below which shows how to calculate eigenvalues of Laplacian (see also here)

from dolfin import *
''' Eigenvalue problem
    -laplace(u) = lmbda * u on (0, 1)
    u(0) = u(1) = 0
'''

mesh = UnitIntervalMesh(100)
V = FunctionSpace(mesh, 'CG', 1)
u = TrialFunction(V)
v = TestFunction(V)

# Lhs mult. by v and integrated by-parts gives
a = inner(grad(u), grad(v))*dx
# Rhs mult by v and integrated gives
m = inner(u, v)*dx
# Auxiliary
L = Constant(0)*v*dx

bc = DirichletBC(V, Constant(0.), DomainBoundary())

# Assemble matrices
A = PETScMatrix()
M = PETScMatrix()
b = PETScVector()
assemble_system(a, L, bc, A_tensor=A, b_tensor=b)
assemble_system(m, L, bc, A_tensor=M, b_tensor=b)

# Setup the eigensolver
eigensolver = SLEPcEigenSolver(A, M)
eigensolver.solve()

# Get the eigenpairs real/complex eigenvalues, real/complex eigenvectors
for i in range(eigensolver.get_number_converged()):
    r, c, rx, cx = eigensolver.get_eigenpair(i)
    print r


  [1]: http://fenicsproject.org/documentation/dolfin/dev/python/demo/la/eigenvalue/python/documentation.html
answered Apr 26, 2014 by MiroK FEniCS Expert (80,920 points)
selected Apr 29, 2014 by Marie E. Rognes

Thanks a lot for this example ;) It's unblock me !!

...