11.07.2014 Views

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

204 APPENDIX B. PROGRAM LISTINGS<br />

Z_u = unflangedZ(f, c, rho, a);<br />

Z_f = flangedZ(f, c, rho, a);<br />

/* calculate the characteristic impedance */<br />

Z0 = charZ(c, rho, a);<br />

/* calculate complex end corrections for unflanged <strong>and</strong> flanged<br />

pipe */<br />

d_u = divz(arctanz(divz(Z_u, multz(j, Z0))),real(k));<br />

d_f = divz(arctanz(divz(Z_f, multz(j, Z0))),real(k));<br />

b = a * (1+flange);<br />

a_on_b = a / b;<br />

/* calculate the length correction */<br />

d = addz(addz(d_f,multz(real(a_on_b),subz(d_u,d_f))),<br />

real(0.057*a_on_b*(1 - pow(a_on_b,5))*a));<br />

/* calculate the reflection coefficient (42) */<br />

R_norefl = multz(real(-1), expz(multz(imaginary(-2 * k), d)));<br />

modR_edge = -0.43 * (b - a) * a / pow(b,2)<br />

* pow(sin(k * b / (1.85 - a_on_b)),2);<br />

phaseR_edge = -k * b * (1 + a_on_b * (2.3 - a_on_b - 0.3<br />

* pow(ka,2)));<br />

R_edge = multz(real(modR_edge), expjz(real(phaseR_edge)));<br />

R = addz(R_norefl,R_edge);<br />

/* calculate <strong>and</strong> return the impedance */<br />

Z = multz(Z0, divz(addz(one, R), subz(one, R)));<br />

return Z;<br />

}<br />

complex unflangedZ(double f, double c, double rho, double a) {<br />

double k = (2*M_PI*f)/c;<br />

double ka = k*a;<br />

complex d;<br />

double modR;<br />

complex Z0 = charZ(c, rho, a), Z;<br />

/* define the end correction for the low frequency limit */<br />

d.Re = 0.6133 * a;<br />

/* determine the frequency-dependent end correction (14b) */<br />

d.Re = d.Re * ((1 + 0.044 * pow(ka,2)) / (1 + 0.19 * pow(ka,2))<br />

- 0.02 * pow(sin(2 * ka),2));<br />

/* determine the modulus <strong>of</strong> the reflection coefficient (14c) */<br />

modR = (1 + 0.2 * ka - 0.084 * pow(ka,2)) / (1 + 0.2 * ka<br />

+ (0.5 - 0.084) * pow(ka,2));<br />

/* calculate the imaginary part <strong>of</strong> the end correction */<br />

d.Im = log(modR) / (2 * k);<br />

/* calculate the impedance (9) */<br />

Z = multz(j, multz(Z0, tanz(multz(real(k), d))));<br />

return Z;<br />

}<br />

complex flangedZ(double f, double c, double rho, double a) {<br />

double k = (2*M_PI*f)/c;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!