[petsc-users] SLEPc/NEP for shell matrice T(lambda) and T'(lambda)
Kenneth C Hall
kenneth.c.hall at duke.edu
Thu Oct 5 17:37:04 CDT 2023
Hi all,
I have a very large eigenvalue problem of the form T(\lambda).x = 0. The eigenvalues appear in a complicated way, and I must use a matrix-free approach to compute the products T.x and T’.x.
I am trying to implement in SLEPc/NEP. To get started, I have defined a much smaller and simpler system of the form
A.x - \lambda x = 0 where A is a 10x10 matrix. This is of course a simple standard eigenvalue problem, but I am using it as a surrogate to understand how to use NEP.
I have set the problem up using shell matrices (as that is my ultimate goal). The full code is attached, but here is a smaller snippet of code:
!.... Create matrix-free operators for A and B
PetscCall(MatCreateShell(PETSC_COMM_SELF,n,n,PETSC_DETERMINE,PETSC_DETERMINE, PETSC_NULL_INTEGER, A, ierr))
PetscCall(MatCreateShell(PETSC_COMM_SELF,n,n,PETSC_DETERMINE,PETSC_DETERMINE, PETSC_NULL_INTEGER, B, ierr))
PetscCall(MatShellSetOperation(A, MATOP_MULT, MatMult_A, ierr))
PetscCall(MatShellSetOperation(B, MATOP_MULT, MatMult_B, ierr))
!.... Create nonlinear eigensolver
PetscCall(NEPCreate(PETSC_COMM_SELF, nep, ierr))
!.... Set the problem type
PetscCall(NEPSetProblemType(nep, NEP_GENERAL, ierr))
!
!.... set the solver type
PetscCall(NEPSetType(nep, NEPNLEIGS, ierr))
!
!.... Set functions and Jacobians for NEP
PetscCall(NEPSetFunction(nep, A, A, MyNEPFunction, PETSC_NULL_INTEGER, ierr))
PetscCall(NEPSetJacobian(nep, B, MyNEPJacobian, PETSC_NULL_INTEGER, ierr))
The code runs, calls MyNEPFunction and MatMult_A multiple times, sweeping over the prescribed RG range, but crashes before it ever calls MyNEPJacobian or MatMult_B. The NEP viewer and error messages are attached.
Any help on getting this problem properly set up would be greatly appreciated.
Kenneth Hall
ATTACHMENTS:
test_nep.f90
code_output
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231005/26fd298f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: code_output
Type: application/octet-stream
Size: 3674 bytes
Desc: code_output
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231005/26fd298f/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_nep.f90
Type: application/octet-stream
Size: 7440 bytes
Desc: test_nep.f90
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231005/26fd298f/attachment-0003.obj>
More information about the petsc-users
mailing list