% A random smooth medium: many weak scatterers rather than one strong one. % % The speed field is a sum of 60 plane waves with random directions, random % wavenumbers around kc (radians per metre), and random phases — a % band-limited Gaussian random field, built here with an ordinary MATLAB loop % because a scene is evaluated once on the CPU and has the whole language % available, not the element-wise subset a compiled step is held to. % % A pulse crossing this does not scatter once and leave: it scatters weakly % and repeatedly, and what comes out the far side is a spread-out coda rather % than a clean wavefront. Turn `amp` down and the medium becomes transparent; % turn it up and the direct arrival disappears into the noise. % % The field is windowed to the interior so the absorbing layer stays uniform. % Structure inside the sponge would scatter sound back into the domain from % the very place that is supposed to be swallowing it. function [c, sig] = medium(x, y, L, npts, c0, amp, kc, seed) nm = 60; rng(seed); g = zeros(npts, 1); for k = 1:nm th = 2*pi*rand(); kk = kc * (0.5 + rand()); ph = 2*pi*rand(); g = g + cos(kk * (cos(th)*x + sin(th)*y) + ph); end g = g / sqrt(nm); r = sqrt(x.^2 + y.^2); window = 0.5 * (1 - tanh((r - 0.28*L) / (0.03*L))); c = c0 * (1 + amp * (g .* window)); sig = sponge(x, y, L, 0.2*L, 1700); end