# Eigenvalues/Eigenfunctions of an Operator

**URL:** <https://fenicsproject.discourse.group/t/eigenvalues-eigenfunctions-of-an-operator/9334>\
**Category:** Linear Algebra\
**Created:** [September 22, 2022, 8:12am UTC](https://fenicsproject.discourse.group/t/eigenvalues-eigenfunctions-of-an-operator/9334 "2022-09-22T08:12:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![CastriMik](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/castrimik/32/2069_2.png) [@CastriMik](https://fenicsproject.discourse.group/u/CastriMik)\
**Post date:** [September 22, 2022, 8:41am UTC](https://fenicsproject.discourse.group/t/eigenvalues-eigenfunctions-of-an-operator/9334/2 "2022-09-22T08:41:54Z")

</div>

You need to define your weak form in DOLFINx as usual, then you need to assemble your matrices with PETSc, and then you can finally find the solutions of your problem with SLEPc (slepc4py).

For more information you can check these posts:

> [@A simple eigenvalue solver in DOLFIN-X](https://fenicsproject.discourse.group/t/a-simple-eigenvalue-solver-in-dolfin-x/3790):
>
> 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. There is a proposed code in dolfin which I am trying to write it in dolfin-x: 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,…

> [@Waveguide number of eigenmodes](https://fenicsproject.discourse.group/t/waveguide-number-of-eigenmodes/6849):
>
> I’m trying to implement this [Dolfin waveguide example](https://bitbucket.org/fenics-project/dolfin/src/master/python/demo/undocumented/waveguide/demo_waveguide.py) in DolfinX. The implementation below calculates only one eigenpair. If I set solver to SLEPc.EPS.Type.LAPACK, it calculats about a 2500 eigenpairs. What settings should I use to get a number of eigenpairs requested by eps.setDimensions? import dolfinx import dolfinx.io import ufl from mpi4py import MPI from slepc4py import SLEPc import numpy as np c0 = 299792458 mesh = dolfinx.RectangleMesh( MPI.COMM\_WORLD, [np.array([0, 0, 0]), …

or this demo:

[https://mikics.github.io/gsoc-jupyterbook/chapter3/demo\_half\_loaded\_waveguide.html](https://mikics.github.io/gsoc-jupyterbook/chapter3/demo_half_loaded_waveguide.html)

---

_[View the full topic](https://fenicsproject.discourse.group/t/eigenvalues-eigenfunctions-of-an-operator/9334)._
