#Example 1.2
#Given
m=36 #kg, mass
acc=7.0 #ft/sq sec acceleration
W=m*9.81
#F=W+m*acc
#1 ft= 0.3048 m
F=W+(m*acc*0.3048)
#Result
print "Required Force is=",round(F,1),"N (downward on floor)"
%matplotlib inline
#Example 1.3
#Given
V=0.84 #ft**3, air volume
p=50 #psi, pressure
T=70 #degree farenheit, temprature
atmp=14.7 #psi, pressure
#the air density d=P/(RT)
#1ft**2=144 inches**2
#calculation
d=((p+atmp)*144)/((1716)*(T+460))
print "density of air",round(d,3),"slugs/ft**3"
#slugs/ft**3
#weight of air
W=d*32.2*V
#1lb=1 slug.ft/sq sec
#result
print "Weight =",round(W,2),"lb"
#plot
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
p=[-12,50,100]
f=[0,0.276,0.5]
xlabel("p (psi)")
ylabel("f (lb)")
plt.xlim((-20,100))
plt.ylim((0,0.5))
a=plot(p,f)
ax.plot([50], [0.276], 'o')
ax.annotate('(50psi,0.276lb)', xy=(50,0.25))
show(a)
#Example 1.4
#Given
vis=0.38 #Ns/m**2, viscosity
sg=0.91 #specific gravity of Newtonian fluid
dia=25 #mm, diameter
vel=2.6 #m/s, velocity
#calculating in SI units
#fluid density d=sg*(density of water @ 277K)
d=sg*1000 #kg/m**3
#Reynolds number Re=d*vel*dia/vis
Re=(d*vel*dia*10**-3)/(vis) #(kgm/sec**2)/N
print "Re in SI units=",round(Re,1)
#calculating in BG units
d1=d*1.94*10**-3 #slugs/ft**3
vel1=vel*3.281 #ft/s
dia1=(dia*10**-3)*3.281 #ft
vis1=vis*(2.089*10**-2) #lb*s/ft**2
Re1=(d1*vel1*dia1)/vis1 #(slugs.ft/sec**2)/lb
#result
print "Re in Bg units=",round(Re1,1)
#Example 1.5
#Given
vis=0.04 #lb*sec/ft**2 , viscosity
vel=2 #ft/sec, velocity
h=0.2 #inches, height
#given
#u=(3*vel/2)*(1-(y/h)**2)
#shearing stress t=vis*(du/dy)
#(du/dy)=-(3*vel*y/h)
#along the bottom of the wall y=-h
#(du/dy)=(3*vel/h)
#Calculation
t=vis*(3*vel/(h/12)) #lb/ft**2
print "shaering stress t on bottom wall=",round(t,3),"lb/ft**2"
#along the midplane y=0
#(du/dy)=0
t1=0 #lb/ft**2
#result
print "shearing stress t on midplane=",round(t1,3),"lb/ft**2"
#Example 1.6
#Given
p1=14.7 #psi(abs), pressure at inlet
V1=1 #ft**3, velocity at inlet
V2=0.5 #ft**3, outlet velocityx
#for isentropic compression, (p1(d1**k))=(p2/(d2**k))
#volume*density=constant(mass)
ratd=V1/V2
#Calculation
p2=((ratd)**1.66)*p1 #psi(abs)
#Result
print "final pressure p2=",round(p2,3),"psi(abs)"
#plot
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
v=[0.1,0.2,0.5,1]
p=[900,200,46.5,10]
xlabel("Vf/Vi")
ylabel("p (psi)")
plt.xlim((0,1))
plt.ylim((0,1000))
a=plot(v,p)
ax.plot([0.5], [46.5], 'o')
ax.annotate('(0.5,46.5 psi)', xy=(0.5,50))
show(a)
#Example 1.7
#Given
s=550 #(mph),
h=35000 #ft
T=-66 #degrees farenheit, temprature
k=1.40 #W/mK, thermal conductivity
#calculation
#speed of sound c=(kRT)**0.5
c=((k*1716*(T+460)))**0.5 #ft/s
#result
print "speed of sound c=",round(c,3),"ft/s"
#speed of sound V=(s m/hour)*(5280 ft/m)/(3600 s/hour)
V=s*5280/3600 #ft/s
print("ft/s",V,"air speed =")
ratio=V/c #Mach number
print "ratio of V/c = Mach Number=",round(ratio,2)
#Example 1.8
T=20 #degree celcius, Temprature
h=1 #mm, height
#calculation
import math
#h=(2*st*math.cos(x)/(sw*R))
#where st= nsurface tension, x= angle of contact, sw= specific weight of liquid, R= tube radius
st= 0.0728 #N/m
sw=9.789 #kN/m**3
x=0
R=(2*st*math.cos(x))/(sw*1000*h/1000) #m
D=2*R*1000 #mm
print "minimum required tube diameter= ",round(D,1),"mm"
#Plot
h=[0.3,0.5,1,2]
D=[100,50,29.8,18]
xlabel("h (mm)")
ylabel("D (mm)")
plt.xlim((0,2))
plt.ylim((0,100))
a=plot(h,D)
show(a)