Hi, everybody
I am a newer to fenics. So everyone's answer is helpful to me. Thanks.
When I run the below code, I got an error below.
begin.......
('the number of converged eigenvalues is :', 0)
Traceback (most recent call last):
File "test4.py", line 41, in <module>
r,c = solver.get_eigenvalue(i)
File "/usr/lib/python2.7/dist-packages/dolfin/cpp/la.py", line 4673, in get_eigenvalue
return self._get_eigenvalue(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 eigenvalue from SLEPc eigenvalue solver.
*** Reason: Requested eigenvalue (0) has not been computed.
*** Where: This error was encountered inside SLEPcEigenSolver.cpp.
*** Process: 0
***
*** DOLFIN version: 2016.2.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------
Aborted (core dumped)
The full code is below,
from fenics import *
import numpy as np
import pdb
mesh = UnitCubeMesh(10, 10, 10)
cell = "tetrahedron"
P0 = FiniteElement('DG',cell,0)
P1 = FiniteElement('P',cell,1)
P3_vec = VectorElement('P',cell,1)
Nedelec_1st = FiniteElement('N1curl',cell,1)
element=MixedElement([P0,P1,P1,P3_vec,Nedelec_1st,P1])
V=FunctionSpace(mesh,element)
z,v,q,eta,deta,s=TestFunctions(V)
y,u,p,zeta,gamma,r=TrialFunctions(V)
# define the 2 bilinear forms
alpha=Constant(1.3)
beta=Constant(1.5)
a = y*z*dx-inner(grad(r),grad(v))*dx+inner(gamma,grad(q))*dx+\
alpha*div(zeta)*div(eta)*dx+inner(curl(zeta),curl(eta))*dx+inner(curl(gamma),curl(eta))*dx+\
inner(grad(r),eta)*dx+inner(grad(p),deta)*dx+\
inner(curl(zeta),curl(deta))*dx-inner(grad(u),grad(s))*dx+\
inner(zeta,grad(s))*dx
b=beta*u*z*dx-alpha*(y+div(zeta))*v*dx+inner(grad(alpha*beta*u),eta)*dx
# forming the eigenvalue problem
A=PETScMatrix()
B=PETScMatrix()
assemble(a, tensor=A)
assemble(b, tensor=B)
# define a solver of general eigenvalue problem
solver = SLEPcEigenSolver(A, B)
print("begin.......")
solver.solve(10)
print('the number of converged eigenvalues is :', solver.get_number_converged())
for i in range(5):
r,c = solver.get_eigenvalue(i)
print r,c
print("end.........")