from __future__ import division
# wavelength
#given data :
v=960 # in m/s
n=3600/60 # in per sec
lamda=v/n
print "The wavelength, lamda = %0.f m " %lamda
# Frequency
#given data :
c=3*10**8 # in m/s
lamda=300 # in m
n=c*10**-6/lamda
print "The frequency, n = %0.f MHz " %n
# velocity and direction
#y=1.2*sin(3.5*t+0.5*x) #equation
w=3.5 #from equation
k=0.5 #from equation
v=w/k #m/s
print "wave velocity =",v,"m/s and direction of the wave is along negative X-axis"
from sympy import symbols, pi, sin
#equation of wave propogation
amp=0.02 #m
fr=110 #Hz
v=330 #m/s
w=2*pi*fr #s**-1
k=w/v #constant
t, x = symbols('t x')
y=amp*sin(w*t-k*x) #refrence equation
print "Equation of wave is",y
from numpy import pi
#path difference
v=360 #m/s
fr=500 #Hz
h=v/fr #wavelength in metre
ang=60 #degree
angr=ang*(pi/180) #radian
pth=(h)/(2*pi) #metre
print "Path difference = %0.2f m " %pth
from math import pi
#path difference
pth=15 #cm
pd=(2*pi)/3 #radians
h=(pth*2*pi)/pd #cm
print "Wavelength = %0.f cm " %h
from math import sin,degrees
from sympy import pi
#displacement ,particle velocity and acceleration
x=200 #cm
a=3 # cm
v=1000#cm/s
n=25
lamda=v/n
y=a*sin(2*pi/lamda*(v*t-x))
v=1000 #cm/s
n=25 #vibrations
h=v/n #cm
a=3 #cm
t=2 #seconds
vl=2*pi*a*n #cm/s
acc=0 #
print "Displacement c = %0.f m " %round(abs(y))
print "Velocity =",vl,"cm/s "
print "Acceleration = %0.2f cm/s^2 " %acc
#amplitude,frequency,velocity ,wavelength and speed
#y=5*sin*(4t-0.02x) #given
a=5 #cm
h=(2*pi)/0.02 #
v=0.02*10000 #cm/s
n=v/h #cycles/seconds
print "Amplitude = %0.2f cm " %a
print "Frequency = %0.3f cycles/s " %n
print "Velocity = %0.f cm/s " %v
print "Wavelength = %0.f cm " %h
ma1x=a*4 #cm/s
print "Maximum speed = %0.2f cm/s " %ma1x
from math import pi
#wave intensity
nt=1 #watt source
r=1 #n
Is=(nt/(4*pi*r**2)) # joule/sec-m**2
print "Intensity on the surface = %0.2f J/s-m^2 " %Is
# Energy flux
#given data :
A=.10 # in m
w=4 # in per sec
k=0.1 # in per cm
p=1.25*10**3 # in kg/m**3
v=w*10**-2/k # in m/s
n=w/(2*pi)
Ef=2*pi**2*n**2*A**2*p*v
print "Energy flux of the wave, Ef = %0.f W/m^2 " %Ef
# Energy radiated and energy current
#given data :
p=1.29 # in kg/m**3
a=.15*10**-2 # in m/s
n=76 # in Hz
E=2*pi**2*n**2*a**2*p
print "(a) Energy radiated, E = %0.3f J/m^3 " %E
v=332 # in m/s
Ev=E*v
print "(b) The energy current, Ev = %0.2f W/s " %Ev
# energy current is calculated wrong in the textbook
# Pressure amplitude, Energy density and energy flux
#given data :
a=10**-5 # in m
n=500 # in per sec
p=1.29 # in kg/m**3
v=340 # in m/s
Pa=2*pi*a*n*v*p
print "(i) Pressure amplitude, Pa = %0.1f N/m^2 " %Pa
Ed=2*pi**2*a**2*n**2*p
print "(ii) Energy density, Ed = %0.1e J/m^3 "%Ed
Ef=2*pi**2*a**2*n**2*p*v
print "(iii) The energy flux, Ef = %0.2f J/m^2-s " %Ef
# 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
#speed
sa=332 #m/s
pa=16 #density of air
ph=1 #density of hydrogen
vn=sa*sqrt(pa/ph) #m/s
t1=0 #degree celsius
t2=546 #degree celsius
t1k=0+273 #kelvin
t2k=t2+273 #kelvin
v2=vn*sqrt(t2k/t1k) #m/s
print "Speed of sound in first case = %0.f m/s " %vn
print "speed of sound in second case is = %0.f m/s" %v2
#temperature
t1=0 #degree celsius
t1k=t1+273 #kelvin
rt=2 #
tk=rt**2*t1k #Kelvin
t=tk-273 #degree celsius
print "Temperature = %0.f degree-celsius " %t
#temperature
rtd=16/14 #ratio of densities
tk=15+273 #degree celsius
x=(tk*rtd)-273 #degree celsius
print "Temperature = %0.2f degree-celsius " %x
#speed
rt=4/1 #
ss=332 #m/s
rd=32/28 #ratio of densities
rt1=((1+(1/rt)*rd)/(1+(1/rt))) #
v1=ss*sqrt(rt1) #m/s
print "Speed of sound in nitrogen = %0.1f m/s " %v1
#speed
gm=1.41 #
vs=330 #m/s
vrms=sqrt(3/gm)*vs #m/s
print "Root mean square velocity of molecules of gas = %0.f m/s " %vrms