Reverberations in Acoustic Layers

Manipulate[
If[nl == 3,ρv = {ρv1,ρv2,ρv3}];
If[nl == 4,ρv = {ρv1,ρv2,ρv3,ρv4}];
(*nl = Length[ρv];  number of layers includes the bottom and top half\[Hyphen]spaces*)
 nb = nl -1; (*number of boundaries is one less than number of layers*)
r = Table[((ρv[[i]] - ρv[[i-1]])/(ρv[[i]] + ρv[[i-1]])),{i,2,nl}];(*reflection coefficients*)
t = 1 + r;(*transmission coefficients*)
rp = -r;
tp = 1 + rp;
F=1;
G=r[[1]];
Do[
FF=F+r[[k]]*z*G;
GG=r[[k]]*F+z*G;
F=FF;
G=GG,
{k,2,nb}
];
T = (z^((nl-2)/2))Product[tp[[k]],{k,1,nb}]/F;
R=G/F;
(*Because inverse Z transform only works for integer exponents, multiply the z expression for T by (z^(-1/2)) when nl is odd only. It will be compensated by a 1/2 unit shift in time sequence later. The one-way time through a layer is one-half unit (m = 1/2). For example, the first arrival through a stack of 1 layer between 2 half\[Hyphen]spaces is given by an impulse at KroneckerDelta[1/2] with amplitude equal to the product of the 2 transmission factors.*)
If[OddQ[nl],
up = InverseZTransform[((z^(-1/2))T)/.z->(1/z),z,m],
up = InverseZTransform[T/.z -> (1/z),z,m]
];
down = InverseZTransform[-R/.z->(1/z),z,m];
shift = (nl-2)/2;
rseq = Chop[Table[Evaluate[down],{m,0,np-1}]];
tseq = Chop[Table[Evaluate[up],{m,0,np-1}]];
rmax =Ceiling[ Max[rseq]];
tmax =Ceiling[ Max[tseq]];
rlist = Table[{k,rseq[[k+1]]},{k,0,np-1}];
kstart = Floor[nl/2];
tlist = Table[{k - kstart + shift ,tseq[[k]]},{k,kstart,np }];
GraphicsRow[{ListPlot[rlist,PlotLabel->"Reflected Sequence",PlotStyle ->{Red,PointSize[0.05]},PlotRange->{{-.1,np},{-rmax,rmax}},AxesOrigin->{0,0},AxesStyle->Thick],ListPlot[tlist,PlotLabel->"Transmitted Sequence",PlotStyle ->{Blue,PointSize[0.05]},PlotRange->{{0,np},{-tmax,tmax}},AxesOrigin->{0,0},AxesStyle->Thick]},ImageSize->600],
(*
Remarks on the range of input parameters:
nl > 4 results in too slow calculation for demonstrations.
np > 8 does not show anything of significance -- most reverberations have gone to zero amplitude. 
Increments finer than 0.05 in ρv can result in InverseZTransform not evaluating due to nature of internal algorithm.
*)
{{nl,3,"number of layers"},{3,4}},{{np,5,"number of output points"},{3,4,5,6,7,8}},
{{ρv1,0.0,"layer 1 impedance"},0.0,1.0,0.05,Appearance->"Labeled"},
{{ρv2,0.5,"layer 2 impedance"},0.05,1.0,0.05,Appearance->"Labeled"},{{ρv3,0.8,"layer 3 impedance"},0.05,1.0,0.05,Appearance->"Labeled"},{{ρv4,1.0,"layer 4 impedance"},0.05,1.0,0.05,Appearance->"Labeled"},TrackedSymbols :> {nl,np,ρv1,ρv2,ρv3,ρv4},SynchronousUpdating->False
]

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Reverberations in Acoustic Layers" from The Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/ReverberationsInAcousticLayers/

Contributed by: David von Seggern (University of Nevada)

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© The Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »