This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Electromagnetic waveguide example from the FEniCS book

+1 vote

Hi folks,

I am trying to code the EM waveguide example from the section 34 of the FEniCS book. Here is the python code written so far. Unfortunately, I am puzzled by the way to assemble the system and apply the BCS using PETscMatrix and SLEPcEigenSolver. Any hints ?

from dolfin import *

width, height = 1, 0.5

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

transverse_order, axial_order = 2, 1

V_N = FunctionSpace(mesh, "Nedelec 1st kind H(curl)", transverse_order)
V_L = FunctionSpace(mesh, "Lagrange", axial_order)

combined_space = V_N * V_L

(N_i, L_i) = TestFunctions(combined_space)
(N_j, L_j) = TrialFunctions(combined_space)

class HalfLoadedDielectric(Expression):
    def eval(self, values, x):
        if x[1] < 0.25:
            values[0] = 4.0
        else:
            values[0] = 1.0;

e_r = HalfLoadedDielectric()
one_over_u_r = Expression("1.0") # no magnetic material

k_o_squared = Expression("4*pi*pi*nu*nu*1e-4/9", nu=0.0) # nu is given in MHz

def curl_t(w):
    return Dx(w[1],0)-Dx(w[0],1)

s_tt = one_over_u_r*dot(curl_t(N_i), curl_t(N_j))
t_tt = e_r*dot(N_i, N_j)

s_zz = one_over_u_r*dot(grad(L_i), grad(L_j))
t_zz = e_r*L_i*L_j

b_tt = one_over_u_r*dot(N_i, N_j)
b_tz = one_over_u_r*dot(N_i, grad(L_j))
b_zt = one_over_u_r*dot(grad(L_i), N_j)

a_tt = s_tt - k_o_squared*t_tt
b_zz = s_zz - k_o_squared*t_zz

class ElectricWalls(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary

zero = Constant((0.0, 0.0, 0.0)) # a vector constant value

dirichlet_bc = DirichletBC(combined_space, zero, ElectricWalls())

# Now assemble the matrices
TO DO
# Form the system
TO DO
# Apply the dirichlet_bc
TO DO
# plot the tranverse and longitudinal part

f = Function(combined_space, e)
(transverse, axial) = f.split()
plot(transverse)
plot(axial)
interactive()
asked Feb 11, 2014 by jcharles FEniCS Novice (130 points)
edited Feb 28, 2014 by jcharles

2 Answers

+2 votes

Hello jcharles !!

I am trying to do the same work as you currently !!!

Perhaps it will help you, I have find the real work of Evan: http://www.evanlezar.com/files/publications/evan_lezar_2011_03_dissertation.pdf

Do you have completed this work without error?

answered Mar 28, 2014 by Shizu FEniCS Novice (350 points)

Hello Shizu, jcharles,

The pdf link doesn't exist anymore. Here is a direct link to Evan Lezar's disseration: http://scholar.sun.ac.za/handle/10019.1/6507

Also, the FEniCS code can be found on page 104 of his dissertation. I will try it out soon. Hope it works :D

+1 vote

Hi,

I'm working on the the same topic and I've found some code at http://bazaar.launchpad.net/~evanlezar/+junk/fenics-electromagnetics/files/head:/python/
It doesn't work in my FEnICS build but maybe it helps

Saludos,

Carlos

answered Dec 22, 2014 by CarlosRevillas FEniCS Novice (170 points)
...