Complex eigenvalue problem

Hi,
I would like to solve a complex eigenvalue problem.
Since Fenics does not support complex numbers I built two PETSC matrices containing the real and imaginary part of the matrix I want to diagonalize.

V = dol.FunctionSpace(my_mesh, “Lagrange”, 1)
u = dol.TrialFunction(V)
v = dol.TestFunction(V)
a1 = (dol.inner(dol.grad(u), dol.grad(v))*dx(0)
+ dol.inner(eps_1 * dol.grad(u), dol.grad(v))*dx(1)
+ dol.inner(dol.grad(u), dol.grad(v))*dx(2))

a2 = (dol.inner(dol.grad(u), dol.grad(v))*dx(0)
+ dol.inner(eps_2 * dol.grad(u), dol.grad(v))*dx(1)
+ dol.inner(dol.grad(u), dol.grad(v))*dx(2))

A1 = dol.PETScMatrix()
dol.assemble(a1, tensor=A1)
A2 = dol.PETScMatrix()
dol.assemble(a2, tensor=A2)

Then I would like to solve the eigenvalue problem using something like

eigensolver = dol.SLEPcEigenSolver(A1 + 1.j *A2)

But I cannot multiply a PETSc matrix by a complex number.

Any suggestion?
Iacopo

You’re missing a few factors:

The variational forumation should be sesquilinear, you need to define the inner product to respect that, i.e. (u, v) = \int_\Omega u \overline{v} \; \mathrm{d} x = (u_r + j u_j, v_r - j v_j).

You can create a mixed function space to solve for the real and imaginary parts, e.g:

# mesh etc

W = FunctionSpace(mesh, MixedElement([FiniteElement("CG", mesh.ufl_cell(), 1), FiniteElement("CG", mesh.ufl_cell(), 1)]))
U, V = TrialFunction(W), TestFunction(W)
u_r, u_j = split(U)
v_r, v_j  = split(V)

# do variational forms and solve

Separate to this, if you’re feeling ambitious, dolfinx supports complex numbers. See the Helmholtz demo for example.

I need to solve an eigenvalue problem that is
A x = \lambda x
I cannot separate the real and imaginary part of A since they do not commute.
Anyone has useful suggestions?
I

It would probably help if you explain the formulation that A discretises. Then we can see why your operator “does not commute”.