pml on waveguides

[attachment=undefined]schema.PNG[/attachment] [attachment=undefined]schema.PNG[/attachment] NGSolve developers,
I have trouble with pml when used for a waveguide problem. Consider a 2D geometry: \Omega = [0, Range] X [0, Depth] and the Helmholtz equation:

\Delta u + k^2 u = -f in \Omega


\frac{\partial u}{\partial n} = 0 on \Gamma_N (top and bottom boundaries).
To the left and right, we have \Gamma_R where we use the PML, so that \partial \Omega = \Gamma_N \cup \Gamma_R

I wish to prescribe f as a point source at (x0,y0) located in \Omega so I followed the pulse implementation given in the NGSolve’s the i-tutorials page (1.7 Complex-valued waves — NGS-Py 6.2.2302-87-ga5a5eff3b documentation)
For the geometry described above, I created the mesh externally in GMsh and specified the regions for PML (to left and right of the source) by using the domain keywords i used in GMsh. While I can see that the solution decays within the PML regions, I would have expected it to undergo an exponential decay due to geometrical spreading loss as it travels to left and right of the point source. Does the NGSolve pml implementation take into account the modal behaviour of waves in a confined cavity unlike fully exterior problem?
I have attached the script that I am using and a schematic of the problem to get an idea.
Many thanks for your help.

Not sure why the attachment is not visible in my earlier message. Here i am pasting the code below:

[code]from ngsolve import *
from netgen.geom2d import SplineGeometry
import numpy as np
import subprocess
from netgen.read_gmsh import ReadGmsh

Rmax = 3e3
Depth = 1e2
Lpml = 1e2

import the Gmsh file to a Netgen mesh object

mesh = ReadGmsh(‘…/…/…/meshes/waveguide2d_sym.msh’)

wrap it into an NGSolve mesh

from ngsolve import *
mesh = Mesh(mesh)
pcR = pml.HalfSpace((Rmax,0.),(1,0),2j)
pcL = pml.HalfSpace((0,0.),(-1,0),2j)

pc2 = pml.Cartesian((Rmax,0.),(Rmax+Lpml,Depth),2j) # doesn’t absorb!


fes = H1(mesh, order=2, complex=True)
u, v = fes.TnT()

Wavenumber & source

cspeed = 1500.
freq = 20.
omega = / cspeed
ScaleFactor = 1e1

a = BilinearForm(fes, symmetric=True)
a += grad(u)grad(v)dx - omegaomegauvdx

pulse = ScaleFactor exp(-(omega**2)((x-x0)(x-x0) + (y-y0)(y-y0)))
f = LinearForm(fes)
f += -pulse * v * dx
gfu = GridFunction(fes, name=“u”) = a.mat.Inverse() * f.vec

vtk = VTKOutput(ma=mesh, coefs=[gfu.real], names = [“ureal”],filename=“wgfem_real”,subdivision=3)
vtk = VTKOutput(ma=mesh, coefs=[gfu.imag], names = [“uimag”],filename=“wgfem_imag”,subdivision=3)


can you attach the mesh as well? In your example the left side pml starts at 0 and the right at Rmax, the cartesian at Rmax and Rmax+Lpml
Cartesian specifies a box, and outside of the box there are pml layers

Hi Christopher,
Thanks for your reply.

[quote]Cartesian specifies a box, and outside of the box there are pml layers
Yes, but i have commented that specific line for cartesian pml as i did not understand how to use that or why it did not show any reduction in wave amplitude in the pml region. Most likely i have got the halfspace pml wrong as well as by definition it should be applied on one side alone, right?
I have attached my geo file below.
Thanks again for your help.

Attachment: waveguide2d_sym_2019-12-20-5.geo