% Absorption profile for an open boundary, in three dimensions. % % s = sponge3(x, y, z, Lx, Ly, Lz, w, smax) % % All in SI: positions and widths in metres, the result in inverse seconds. % Zero in the interior, ramping up quadratically over a layer of width w % inside each face of the box [-Lx/2, Lx/2] x [-Ly/2, Ly/2] x [-Lz/2, Lz/2] % and reaching smax at the wall. Added to a scene's absorption, this is what % makes the finite grid stand in for open air: a wave that leaves the % instrument is attenuated before it reaches the outer boundary, and whatever % reflects off that boundary is attenuated again on the way back. % % The ramp is gradual on purpose. An absorbing layer is itself an impedance % mismatch, so a sudden one reflects; spreading it over a couple of % wavelengths keeps that reflection small. It is not a perfectly matched % layer, and at grazing incidence it does leak. function s = sponge3(x, y, z, Lx, Ly, Lz, w, smax) dx = max(0, w - (Lx/2 - abs(x))) / w; dy = max(0, w - (Ly/2 - abs(y))) / w; dz = max(0, w - (Lz/2 - abs(z))) / w; d = max(max(dx, dy), dz); s = smax * d.^2; end