Closed K-Karo closed 4 years ago
You can use dolfinx.fem.assemble_matrix()
to get a PETSc matrix from the variational form. The PETSc matrix can then be directly use in the SLEPc eigensolver.
Following on the comment by @adeebkor , SLEPcEigenSolver
has been removed in DOLFINX in favour of working directly with slepc4py
.
dear @adeebkor and @garth-wells Thanks for your reply, I am trying to use your guidance, but it is steel confusing to me. This is a proposed code by using dolfin:
from dolfin import *
mesh = …….
V = FunctionSpace(mesh, "Lagrange", 1)
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v))*dx
# Assemble stiffness form
A = PETScMatrix()
assemble(a, tensor=A)
# Create eigensolver
eigensolver = SLEPcEigenSolver(A)
# Compute all eigenvalues
eigensolver.solve()
# Extract largest (first) eigenpair
r, c, rx, cx = eigensolver.get_eigenpair(0)
print "Largest eigenvalue: ", r
Achieving the (r, c, rx, cx)
values, help me to analyze waveguides (chapter 34 of FEniCS book).
There is an ambiguity how to create eigensolver and compute the eigenvalues in DOLFIN-X, and how to use the PETSc matrix directly in the SLEPc eigensolver? Thanks in advance.
Please post your question to https://fenicsproject.discourse.group/.
Hi, I am trying to write a simple eigenvalue solver code in dolfin-x, but I have a problem in how to define a matrix as a PETScMatrix() and assembling the form into it. In the following, there is a problem in order to define an eigensolver.
There is a proposed code in dolfin which I am trying to write it in dolfin-x:
A = PETScMatrix() assemble(a, tensor=A) eigensolver = SLEPcEigenSolver(A) eigensolver.solve() r, c, rx, cx = eigensolver.get_eigenpair(0)