How to get eigenvectors from eigenvalues?
7 weeks ago by
I was using eigensolver to solve a Neumann eigenfunction problem, and it didn't converge for most 1<=N<=50, but for N=37, it printed out a list of 37 eigenvalues. I am trying to get the .pvd files which come associated with each eigenfunction on my domain, but I don't have all 37 now. Does anybody know how to get a particular eigenvector for FENICS reading in a particular eigenvalue? I feel like this should be possible, but all the functions I see in the documentation seem like they accept the solving conditions and return an eigenvalue and update the vector within the working directory to the eigenvalue.
Thanks in advance,
Community: FEniCS Project
7 weeks ago by
A = assemble(a) M = assemble(m) # downcast to PETSc matrices A = as_backend_type(A) M = as_backend_type(M) # Create eigensolver eigensolver = SLEPcEigenSolver(A, M) eigensolver.parameters["solver"] = "krylov-schur" eigensolver.parameters["spectrum"] = "smallest magnitude" eigensolver.parameters["problem_type"] = "gen_hermitian" eigensolver.parameters["spectral_transform"] = "shift-and-invert" eigensolver.parameters["spectral_shift"] = 0.3 eigensolver.parameters["tolerance"] = 1.0e-5 eigensolver.parameters["maximum_iterations"] = 1000 eigensolver.solve(20) nconv = eigensolver.get_number_converged() eigenvalues =  eigenfunctions =  for i in range(nconv): r, _, rx, _ = eigensolver.get_eigenpair(i) eigenvalues.append(r) # normalize eigenfunction so max = max magnitude = 1 rxmax = rx.max() rxmin = rx.min() if rxmax < -rxmin: rx = rx/rxmin else: rx = rx/rxmax eigenfun = Function(V) eigenfun.vector()[:] = rx eigenfunctions.append(eigenfun)
Please login to add an answer/comment or follow this question.