from __future__ import division
print "Example 8.1 page no 75\n\n"
# heat is transferred from a gas
Cp=1090#average heat capacity of gas
M_dot=9#mass flow rate
T1=650#gas inlet temperature
#kinetic and potential enargy effects are neglected,there is no shaft work
Q=5.5e+6#heat transferred
delta_H=Q#since there are no kinetic,potential,and shaft work effects
print "\n heat capacity Cp=%0.3f J/kg.deg c\n mass flow rate M_dot=%0.3f kg/s\n gas inlet temperature T1=%0.3f deg c\n heat transferred Q=%0.3f W"%(Cp,M_dot,T1,Q)#
T2=round(-Q/(M_dot*Cp)) + T1
print "\n temperature T2=%0.f deg c "%(T2)#
from __future__ import division
print "Example 8.2 page no 77 fig 8.2 \n\n\n"
#fluid flow in a device
#fluid flow with in the control volume is steady
q1=8#flow rate at section 1,direction in
q2=6#flow rate at section 2, direction in
q3=14#flow rate at section 3,direction out
h1=250#enthalpy at section 1
h2=150#enthalpy at section 2
h3=200#enthalpy at section 3
rho=800#density of fluid
print "\n flow rate q1=%0.3f m**3/s\n flow rate q2=%0.3f m**3/s\n flow rate q3=%0.3f m**3/s\n enthalpy h1=%0.3f j/kg\n enthalpy h2=%0.3f j/kg\n enthalpy h3=%0.3f j/kg\n density of fluid rho=%0.3f kg/m**3"%(q1,q2,q3,h1,h2,h3,rho)#
#applying total energy balance
hp=746#1 hp=746 kw
H=rho*(q1*h1+q2*h2-q3*h3)/hp
print "\n enthalpy H=%0.3f hp"%(H)#
#for adiabatic steady operation, Q_dot=0
W_dot=H#W_dot is work
print "\n work W_dot=%0.3f hp"%(W_dot)#
#since work is positive ,the surroundings must be doing work on the system through some device
from __future__ import division
from math import sqrt
print " Example 8.5 page no 81 fig 8.3\n\n\n"
#a cylindrical tank filled with water
#applying bernoulli equation
z1=9#elevation head at section 1
h2=1#height at section 2
D1=3#diameter of cylindrical tank
D2=.3#diameter of outlet hole of tank
g=9.807#gravitational acceleration
print "\n elevation head at section 1 z1=%0.3f m\n height at section h2=%0.3f m\n diameter of cylindrical tank D1=%0.3f m\n diameter of outlet hole of tank D2=%0.3f m\n gravitational acc. g=%0.3f m/s**2"%(z1,h2,D1,D2,g)#
t=2*((sqrt(z1)-sqrt(h2))/((sqrt(2*g))*(D2/D1)**2))
print "\n time t=%0.3f sec"%(t)#
x=-(D2/D1)**2#ratio of a/g
print "\n x=%0.3f"%(x)#
#for this example the maximum acceleration is 1% of g,therefore saftey use Bernoulli equation