The error I got is very strange to me, and I tried many many times. But still it didn't work. So if anyone could help me, it's amazing. I'll appreciate your help.
The error message is bellow:
Traceback (most recent call last):
File "test4.py", line 51, in
r,c,rv,cv = solver.get_eigenpair(0)
File "/usr/lib/python2.7/dist-packages/dolfin/cpp/la.py", line 4650, in get_eigenpair
lr, lc = self._get_eigenpair(r_vec, c_vec, i)
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
*** fenics-support@googlegroups.com
*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.
*** -------------------------------------------------------------------------
*** Error: Unable to extract eigenpair from SLEPc eigenvalue solver.
*** Reason: Requested eigenpair (0) has not been computed.
*** Where: This error was encountered inside SLEPcEigenSolver.cpp.
*** Process: 0
*** DOLFIN version: 2016.1.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------
Aborted (core dumped)
The source code is below:
from fenics import *
import numpy as np
mesh = UnitCubeMesh(5,5,5)
pdb.set_trace()
cell = "tetrahedron"
P0 = FiniteElement('DG',cell,0)
P1 = FiniteElement('P',cell,1)
P1_vec = VectorElement('P',cell,1)
Nedelec_1st = FiniteElement('N1curl',cell,1)
element=MixedElement(P0,P1,P1,P1_vec,Nedelec_1st,P1)
V=FunctionSpace(mesh,element)
print(str(element))
z,v,q,eta,deta,s=TestFunctions(V)
U=TrialFunction(V)
y,u,p,zeta,gamma,r=split(U)
define the boundary conditions
boundary = DomainBoundary()
bc1=DirichletBC(V.sub(1),Constant(0.0),boundary)
bc2=DirichletBC(V.sub(2),Constant(0.0),boundary)
bc3=DirichletBC(V.sub(3),Constant([0.0,0.0,0.0]),boundary)
bc4 = DirichletBC(V.sub(4),Constant([0.0,0.0,0.0]),boundary)
bc5=DirichletBC(V.sub(5),Constant(0.0),boundary)
bcs=[bc1,bc2,bc3,bc4,bc5]
define the 2 bilinear forms
alpha=Constant(1.5)
beta=Constant(1.2)
a = yzdx-dot(grad(r),grad(v))dx+dot(gamma,grad(q))dx+\
alphadiv(zeta)div(eta)dx+dot(curl(gamma),curl(eta))dx+\
dot(grad(r),eta)dx+dot(grad(p),deta)dx+\
dot(curl(zeta),curl(deta))dx-dot(grad(u),grad(s))dx+\
dot(zeta,grad(s))dx
b=betauzdx-alpha(y+div(zeta))vdx+dot(grad(alphabetau),eta)dx
forming the eigenvalue problem
A=PETScMatrix()
B=PETScMatrix()
assemble(a,tensor=A)
assemble(b,tensor=B)
for bc in bcs:
bc.apply(A) and bc.apply(B)
solver = SLEPcEigenSolver(A,B)
solver.parameters["solver"] = "krylov-schur"
solver.solve(10)
print solver.get_number_converged()
r,c,rv,cv = solver.get_eigenpair(0)
print r,c,rv,cv
plot(mesh)
interactive()