# LRFTubes example: radiation impedance of a baffled piston¶

This example shows how to use the radiation impedance of a baffled piston as a boundary condition on an acoustic network. See picture below: In :
# Import necessary stuff
from lrftubes import Air, PrsDuct, System, Z_piston
%pylab inline

Populating the interactive namespace from numpy and matplotlib

In :
# Create a material, with default temperature and pressure
mat = Air()
# Create a system
sys = System(mat)

# Dimensions of a simple circular duct
r = 0.1
L = 2.0
S = np.pi*r**2

duct = PrsDuct(L, S, cs='circ')
# Add the duct to the system, set the left node at 0, the right node at 1

# Set a unit pressure boundary condition on node 0

# Create the radiation impedance functor
Zp = Z_piston(mat, r)

# Add the radiation impedance functor as impedance boundary condition on the
# right side.

# Create a range of frequencies, solve for these.
f = np.linspace(10, 10000, 500)
sol = sys.solve(f)

# Obtain the pressure and velocity at the impendance b.c. node
pR = sol[duct]['pR']
uR = sol[duct]['UR']/S

# Compute and plot impedance
zr = pR/uR

figure(figsize=(12,6))
semilogx(f,zr.real)
semilogx(f,zr.imag)
title('Real and imaginary part of the radiation impedance of a baffled piston')
xlabel('Frequency [Hz]')
ylabel('Z [rayls]')

legend(['Real part', 'Imaginary part'])

Out:
<matplotlib.legend.Legend at 0x7f898fde8cf8> 