concept-collection / dulcimer
dulcimer / tools / sponge3.m
23 lines · 1.1 KBBlameHistoryRaw
1% Absorption profile for an open boundary, in three dimensions.
2%
3% s = sponge3(x, y, z, Lx, Ly, Lz, 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 face of the box [-Lx/2, Lx/2] x [-Ly/2, Ly/2] x [-Lz/2, Lz/2]
8% and reaching smax at the wall. Added to a scene's absorption, this is what
9% makes the finite grid stand in for open air: a wave that leaves the
10% instrument is attenuated before it reaches the outer boundary, and whatever
11% reflects off that boundary is attenuated again on the way back.
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 = sponge3(x, y, z, Lx, Ly, Lz, w, smax)
18 dx = max(0, w - (Lx/2 - abs(x))) / w;
19 dy = max(0, w - (Ly/2 - abs(y))) / w;
20 dz = max(0, w - (Lz/2 - abs(z))) / w;
21 d = max(max(dx, dy), dz);
22 s = smax * d.^2;
23end