1% Absorption profile for an open boundary.
2%
3% s = sponge(x, y, L, w, smax)
4%
5% All in SI: positions and widths in metres, the result in inverse seconds.
6% Zero in the interior, ramping up quadratically over a layer of width w
7% inside each edge of the square [-L/2, L/2]^2 and reaching smax at the wall.
8% Added to a scene's absorption, this is what makes the finite grid stand in
9% for an unbounded medium: a wave that leaves the region of interest is
10% attenuated before it reaches the outer boundary, and whatever reflects off
11% that boundary is attenuated again on the way back.
12%
13% The ramp is gradual on purpose. An absorbing layer is itself an impedance
14% mismatch, so a sudden one reflects; spreading it over a couple of
15% wavelengths keeps that reflection small. It is not a perfectly matched
16% layer, and at grazing incidence it does leak.
17function s = sponge(x, y, L, w, smax)
18 dx = max(0, w - (L/2 - abs(x))) / w;
19 dy = max(0, w - (L/2 - abs(y))) / w;
20 d = max(dx, dy);
21 s = smax * d.^2;
22end