% A single circular scatterer in a uniform background: the reference case. % % In two dimensions this is the classical "scattering by a circular cylinder" % problem — the 2D problem is the 3D one for fields that do not vary along z, % so a disk in the (x, y) plane is the cross-section of an infinite cylinder. % That is the object with an exact series solution in Bessel and Hankel % functions, which makes it the thing to look at first. % % Sound speed only, at constant density, so the impedance ratio across the % interface is just the speed ratio cin: cin much greater than 1 behaves % nearly rigid (sound-hard), cin much less than 1 nearly pressure-release % (sound-soft), and cin = 1 is no scatterer at all. `c0` is the speed of sound % in air (343 m/s), which the app supplies; `cin` is a plain ratio to it, so % the slider means the same thing whatever c0 is. % % `R` and `absorb` are in the app's own units — metres and inverse seconds — % since they are lengths and rates, not ratios to anything. % % The interface is smoothed over about a cell so that the discrete medium is % resolved by the grid. A jump between two neighbouring cells is not: it % scatters the grid's own staircase rather than a circle. function [c, sig] = medium(x, y, L, h, c0, cin, R, absorb) r = sqrt(x.^2 + y.^2); inside = 0.5 * (1 - tanh((r - R) / (1.5*h))); c = c0 * (1 + (cin - 1) * inside); sig = sponge(x, y, L, 0.2*L, 1700) + absorb * inside; end