Dear @adeebkor, @bhaveshshrimali,
Thanks again for your kind reply.
It is exactly my new problem about extracting more eigenvalues.
In this code, dolfin returns selected numbers of eigenvalues:
import numpy as np
import matplotlib.pyplot as plt
from dolfin import *
mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v))*dx
A = PETScMatrix()
assemble(a, tensor=A)
eigensolver = SLEPcEigenSolver(A)
eigensolver.solve()
for i in range (10):
r, c, rx, cx = eigensolver.get_eigenpair(i)
print(r)
The result is:
7.822379233170962
7.5635582373483015
7.5635582373482855
7.306318516404323
7.15614193137886
7.156030031719445
6.901377998228639
6.901377998228612
6.6339159619522885
6.6339159619522565
But dolfin-x just returns the first eigenvalue:
import numpy as np
from mpi4py import MPI
from dolfinx import Function, FunctionSpace, UnitSquareMesh, RectangleMesh
from dolfinx.fem import assemble_matrix, Form
from ufl import TrialFunction, TestFunction, grad, dx, dot
from slepc4py import SLEPc
import dolfinx
mesh = UnitSquareMesh(MPI.COMM_WORLD, 10, 10)
V = FunctionSpace(mesh, ("CG", 1))
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v))*dx
A = assemble_matrix(a, [])
A.assemble()
eigensolver = SLEPc.EPS().create(MPI.COMM_WORLD)
eigensolver.setOperators(A)
eigensolver.solve()
self = eigensolver.getConverged()
vr, vi = A.createVecs()
print( "Number of converged eigenpairs %d" % self )
if self > 0:
for i in range (self):
l = eigensolver.getEigenpair(i ,vr, vi)
print(l.real)
and The result is:
Number of converged eigenpairs 1
7.822379233170955
and it doesn’t return more eigenvalues. Please let me know if there is a solution to solve this problem. Thanks in advance.