Boundary conditions for 3D eddy current problem

Hello everybody,

I’m currently working on a 3D eddy current problem regarding a conducting cube in homogenous magnetic field in the time domain. While doing this some questions arose about the correct implementation of non-homogeneous Dirichlet boundary conditions.

I tried the following so far:

coeff_dirichlet = CoefficientFunction((
     CoefficientFunction([0,0,0,0,0,-25e-3*y*B0*sin(omega * t)]), 
     CoefficientFunction([0,0,0,25e-3*B0*x*sin(omega * t),0,0]), 
uh.Set(coeff_dirichlet, BND)

with the entries in the list being the different surfaces (1: bottom, 2: top, 3: left, 4: right, 5: front, 6: back). Drawing these onto the mesh shows in the GUI that the values are set to the correct surfaces.

Even though there is a lot of well written documentation I don’t fully understand how to mark the boundaries correctly as the keyword BND tells Set that the CoefficientFunction need only be interpolated at the marked boundaries.
Note the attached code. Any help is very much appreciated as I’m pretty new to FEM-Simulation in general.



Attachment: cube_2020-08-30.vol

Hi Sebastian,

it is much easier to work with labels for the boundary conditions. Try to set them already in the geometry.

If you don’t have them, you can assign them like here:

mesh = Mesh("cube.vol")
names = [ "bottom", "top", "left", "right", "front", "back", "inner" ]
for i, name in enumerate(names):
    mesh.ngmesh.SetBCName(i, name)
print (mesh.GetBoundaries())

Be careful, there is some inconsistency whether we enumerate boundaries 0-based or 1-based. We check and see that we got 7 distinct boundary regions.

We use the names when defining dirichlet boundaries:

V = HCurl(mesh, order = 1, dirichlet = "right|back")

and use them later as you do for the material coefficients. See the attached file.

Best, Joachim


Hi Joachim,

thanks again for your super fast help. Unfortunately I still have a problem with my current test case for Eddy currents.

To slim the overall problem I’m currently tryin to solve a simple test case for a pure homogenous magnetic field. Here I’m using [tex]A = \left(
for my Dirichlet boundary conditions. Unfortunately that doesn’t result the correct magnetic field.

I also found some examples for Eddy current problems (pretty much the same problem) from your User-Meeting 2019. Sadly I currently can’t completely comprehend why these boundary conditions have been used.

I attached the volume and the code again. I’m sure there is just a small mistake about the implementation. Maybe someone knows where the problem is.

EDIT: Could solve it myself will be marked as resolved!


Attachment: cube_simple.vol