Can anyone show me how to solve this same problem under Neumann conditions? I have a solution for the Dirichlet boundary conditions (perfect rectangular wave guide) and I want to solve for Neumann conditions to plot TM mode solutions

from dolfin import *



width = 1.0

height = 0.5

mesh = RectangleMesh(Point(0, 0), Point(width, height), 8, 4, "left/right")



V = FunctionSpace(mesh, "Nedelec 1st kind H(curl)", 2)



v = TestFunction(V)

u = TrialFunction(V)



s = inner(curl(v), curl(u))*dx

t = inner(v, u)*dx

L = dot(Constant((0.0, 0.0)), v)*dx



# Hermitian assembly

perf_conductor_bc = DirichletBC(V, Constant((0, 0)), "on_boundary")

S = PETScMatrix()

T = PETScMatrix()

dummy = PETScVector()

assemble_system(s, L, A_tensor=S, b_tensor=dummy, bcs=perf_conductor_bc)

assemble_system(t, L, A_tensor=T, b_tensor=dummy, bcs=perf_conductor_bc)



esolver = SLEPcEigenSolver(S, T)

esolver.parameters["spectrum"] = "smallest real"

esolver.parameters["solver"] = "lapack"

esolver.solve()



from vtkplotter.dolfin import plot

cutoff = None

count = 0

for i in range(S.size(1)):

    (lr, lc, rr, rc) = esolver.get_eigenpair(i)

    u = Function(V)

    if lr > 1 and lc == 0:

        cutoff = sqrt(lr)

        u.vector()[:] = rr



        plot(u, shape=((2,2)), at=count)

        count += 1

        if count > 4:

            break



if cutoff is None:

    print("Unable to find dominant mode")

else:

    print("Cutoff frequency:", cutoff)

Hi, what about just ignoring the BCs ?

So I just have no bcs in my assemble system equations?

I’m a bit rusty here, but here’s what I remember:

Excluding the DirichletBC classes will indeed naturally enforce n \times (\mu^{-1} \nabla \times u) = 0, which is a symmetry BC in the context of TM waveguides. But port boundary conditions are more complicated having a Robin type and complex formulation.

Jin’s book is a great resource for practical EM finite elements.

2 Likes