Compute only desired several eigenvalue for a generalized eigenvalue problem
Issue #92
closed
Hello, I have a generalized eigenvalue problem Aq = wBq. Sparse matrix A and B are shown below, neither are symmetry.
matrix A:
matrix B:
My question is how can I compute only several interested eigenvalue? I used the following code, where the sigma is the desired a eigenvalue, and I want to compute for example 15 eigenvalues around Sigma. As I tried, the code seems to compute the largest imaginary of the overall eigenvalue spectrum.
import sys, slepc4py
slepc4py.init(sys.argv)
from petsc4py import PETSc
from slepc4py import SLEPc
opts = PETSc.Options()
kk = 15
# create petsc sparse matrix (createAIJ) and assigh lhs and rhs data
A = PETSc.Mat().createAIJ(size=LHS.shape,
csr=(LHS.indptr, LHS.indices,
LHS.data),comm=PETSc.COMM_WORLD)
A.assemble()
B = PETSc.Mat().createAIJ(size=RHS.shape,
csr=(RHS.indptr, RHS.indices,
RHS.data),comm=PETSc.COMM_WORLD)
B.assemble()
# create SLEPc Eigenvalue solver
E = SLEPc.EPS().create(PETSc.COMM_WORLD)
E.setOperators(A,B)
E.setDimensions(kk,PETSc.DECIDE) # set number of eigenvalues to compute
E.setWhichEigenpairs(E.Which.LARGEST_IMAGINARY)
E.setProblemType(SLEPc.EPS.ProblemType.GNHEP) # generalized non-Hermitian eigenvalue problem
E.setTolerances(tol,500) # set tolerance
if sigma is not None:
E.setTarget(sigma) # set the desired eigenvalue
E.setTarget(sigma)
if v0 is not None:
E.setInitialSpace(v0) # set the initial vector
st = E.getST()
st.setType('sinvert')
E.setFromOptions()
E.solve()
Comments (2)
-
-
- changed status to closed
- Log in to comment
This issue is misplaced. petsc4py has no business computing eigenvalue problems.