Using NGSolve to solve Maxwell's equations in time-harmonic form

Hello. I try to find shielding effectiveness of shielding enclosure using ngsolve.
For finite element analysis in the frequency domain, the governing wave equation can be written as: curl(1/mucurl(E)) + kkE=f.
I created FES as: fes = HCurl(mesh, order=4, nograds = True, complex=True),
defined materials and constants,
defined bilinear form: a = BilinearForm(fes)
a += SymbolicBFI(1/mu
curl(u)curl(v) + kkuv).

But I don’t now how to define boundary conditions and how to set the incident electric field as a plane wave.

Can anyone give me some example how to solve Maxwell’s equations in time-harmonic form in NGSolve?

Hi,

here is an jupyter-notebook example for solving Helmholtz with first order absorbing bc.
We choose a Gaussian beam as incoming boundary condition.

It’s very similar for Maxwell:
For the complex-valued Robin boundary condition you add the term

a += SymbolicBFI( -1j * omega * u.Trace() * v.Trace(), BND)

The trace-operator u.Trace() gives you the tangential component at the boundary.

Best, Joachim

Attachment: absorbing.ipynb

Attachment: absorbing.pdf

Joachim, thank you very much for your answer.

I try to find the total electric field in region of space. The region consists of two domains: air and metal plate. For material of plate I choose the PEC (perfect electric conductor with electrical conductivity equal to 1e30). And I don’t need to culculate the field inside the plate.
There are no current sources in region. The excitation is a plane wave.

I add the complex-valued Robin boundary condition to my scrypt file, but i can’t get the right result.

I try to implement something like that in the paper.

Here is my python file. What am I doing wrong?

Thank you in advance, Dmitry

Attachment: paper.pdf

Attachment: box10.py

you have to debug your script step by step:

visualize the incoming wave, the CoefficientFunction Einc as well as the interpolation E - is this what you expect ? (answer is on)

also don’t use the nograds flag which works only for magnetostatics.

Joachim

Thank you for reply, Joachim.

Yes, you are right. The incoming wave is not that I expect. I correct this. But the problem still exists.
I understand, that I do not have enough knowledge about ngsolve. That’s why I deside to use more simple 2D example.
There is file scattering.py in py_tutorials folder. I tried to modify it for maxwell equations. But despite the fact that this is a simple example I did not succeed.
Now I can’t find there is the problem. Two files are in attachments.

Attachment: scattering.py

Attachment: scattering_maxwell.py

I found mistake in coefficient. Now it works.
But I am not sure about PML. Is it necessary to use it in my problem? The results are diferent whith it and without.

Attachment: scattering_maxwel_PML.py

Attachment: scattering_maxwell_2018-05-05.py