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))
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