from __future__ import division
from math import pi
# Pressure amplitude, Energy density and Energy flux
#given data :
A=1*10**-5 # in m
n=500 # in per sec
v=340 # in m/s
p=1.29 # in kg/m**3
Pa=2*pi*n*v*p*A
print "Pressure amplitude, Pa = %0.1f N/m^2 "%Pa
Ed=2*pi**2*n**2*p*A**2
print "Energy density, Ed = %0.1e J/m^3 " %Ed
Ev=Ed*v
print "Energy flux, Ev = %0.2f J/m^2-s " %Ev
# Pressure
#given data :
gama=1.4
u=10**-3 # in m/s
v=340 # in m/s
P=10**5 # in N/m**2
p=gama*P*u/v
print "The pressure, p = %0.2f N/m^2 " %p
from math import sqrt
# The amplitude
#given data :
n=350 # in Hz
v=330 # in m/s
p=1.293 # in kg/m**3
I=1*10**-6 # in W/m**2
A=sqrt(I/(2*pi*n**2*p*v))
print "The amplitude of wave, A = %0.2e m " %A
# Velocity, Amplitude of pressure and particle velocity amplitude
#given data :
gama=1.4
P=1.013*10**5
p1=1.29 # in kg/m**3
A=2.5*10**-7 # in m
v=sqrt(gama*P/p1)
print "The velocity, v = %0.1f m/s " %v
n=1000 # in Hz
lamda=v/n
print "Wavelength, lamda = %0.4f m " %lamda
p=p1*v*2*pi*n*A
print "Amplitude of pressure, p = %0.2f N/m^2 " % p
u=2*pi*n*A
print "Particle velocity amplitude, u = %0.2e m/s " %u
from math import pi
# Amplitude
#given data :
v=(1/3)*10**3 # in m/s
p=1.25 # in kg/m**3
E=v**2*p
n=10**4 # in rad/sec
print "Bulk modulus of medium, E = %0.2e N/m^2" %E
I=10**-12 # in W/m**2
A=sqrt(I/(2*pi**2*n**2*p*v))
print "Amplitude of wave, A = %0.2e m " %A
P=sqrt(2*I*p*v)
print "Pressure amplitude, P = %0.2e N/m^2 " %P
# answer A and E is wrong in textbook
from math import sqrt
# Root mean squre velocity
#given data :
vs=330 # in m/s
gama=1.41
c=round(sqrt(3/gama)*vs)
print "The root mean square velocity of modulus, c = %0.f m/s "%c
# Acoustic power entering
#given data :
A=1*2 # in m**2
a=80 # in dB
I0=10**-12 # in W/m**2
IbyI0=10**(80/10)
I=I0*IbyI0
Ape=I*A
print "Acoustic power entering the room = %0.e Watt " %Ape
from math import log10
# Acoustic intensity level
#given data :
Pr=3 # in W
r=15 # in m
I=Pr/(4*pi*r**2) # in W/m**2
I0=10**-12 # in W/m**2
L=round(10*log10(I/I0))
print "Acoustic intensity level, L = %0.f dB " %L
# frequency
n2=200 #second**-1
l21=2 #
f=l21*n2 #
print "Frequency = %0.f second^-1 " %f
# length
l1=66 #cm
v=330 #m/s
nbs=5 #beats/sec
x=(2*(v-(nbs*2*l1*10**-2))/(v*2*l1*10**-2)) #
l2=1/x #cm
print "Length = %0.1f cm "%(l2*100)
# length
f=110 #Hz
v=330 #m/s
l=v/(2*f) #m
print "Fundamental frequency = %0.f Hz" %f
print "Length = %0.1f m" %l
# equation,frequency,amplitude ,wavelength and distance
#y=6*(sin(2*pi*x)/6)*cos(160*pi*t) #given equation
a=3 #cm
T=(2*pi)/(160*pi) #sec
h=((2*pi*6)/(2*pi)) #cm
print "wave equation is 3*sin((160*pi*t)+(2*pi*x)/6)"
print "Amplitude = %0.2f cm " %a
print "Frequency = %0.2f Hz " %(1/T)
print h,"wavelength is,(cm)="
db=h/2 #
print "Distance between consecutive antinodes = %0.2f cm" %db
from math import cos, pi
# length,amlitude,pressure
f=440 #Hz
v=330 #m/s
l=((5*v)/(4*f))*100 #cm
print "Length, L = %0.2f cm " %l