Chapter 6: The Ideal Gas

Example 6.1, page no. 101

In [1]:
import scipy.integrate

#intialization of variables
T1 = 40+460.0                        #temperature(R)
T2 = 340+460.0                       #temperature(R)

#calculation
def Cv(T):
	cv = 0.162+0.00046*T
	return cv
	
du = scipy.integrate.quadrature(Cv, T1, T2)[0]

#result
print "Change in specific internal energy = %.1f B/lbm" %du
Change in specific internal energy = 138.3 B/lbm

Example 6.2, page no. 103

In [2]:
#initialization

cp = 0.24                   #B/lbm F
R = 53.3                    #ft-lb/lbm F

#calculation
cv = cp-R/778.0

#result
print "Specific heat at constant volume = %.3f B/lbm F" %cv
Specific heat at constant volume = 0.171 B/lbm F

Example 6.3, page no. 104

In [3]:
import scipy.integrate

#initialization
T1 = 1400+460.0                         #temperature(R)
T2 = 1200+460.0                         #temperature(R)

#calculation
def Cp(T):
	cp = 0.317- 1.2*100/T + 4*10**4/T**2
	return cp

dh = scipy.integrate.quadrature(Cp, T1, T2)[0]

#result
print "Change in stagnation enthalpy = %.1f B/lbm" %dh
Change in stagnation enthalpy = -52.3 B/lbm

Example 6.4, page no. 106

In [4]:
import scipy.integrate

#initialization
T1 = 100+460.0                       #temperature(R)
T2 = 300+460.0                       #temperature(R)
P1 = 15.0                            #pressure(lb/in^2)
P2 = 30.0                            #pressure(lb/in^2)
Cp = 0.3                             #constant pressure(B/lbm F)
R = 40.0                             #gas constant(ft-lb/lbm R)

#calculation
def fun(f):
	s=Cp/f
	return s
def fun1(f):
	s2=R/(f*778)
	return s2

ds1 = scipy.integrate.quadrature(fun, T1, T2)[0]
ds2 = scipy.integrate.quadrature(fun1, P1, P2)[0]
ds = ds1 - ds2

#result
print "Change in entropy = %.4f B/lbm R" %ds
Change in entropy = 0.0560 B/lbm R

Example 6.5, page no. 108

In [7]:
#initialization

T1 = 40+460.0                          #temperature(R)
T2 = 340+460.0                         #temperature(R)
P1 = 15.0                              #pressure(lb/in^2)
cp = 0.24
cv = 0.171

#calculation
gamma=cp/cv
P2=P1 *((T2/T1)**(gamma/(gamma-1)))

#result
print "Final pressure = %.1f lb/in^2" %P2
Final pressure = 76.9 lb/in^2

Example 6.6, page no. 110

In [7]:
import math

#initialization
P1 = 16.0                   #lb/in^2
P2 = 14.0                   #lb/in^2
Tt = 83+460.0               #R
gamma = 1.4
cp = 0.24                   #B/lbm F

#calculation
T = Tt *(P2/P1)**((gamma-1)/gamma)
dh = cp*(Tt-T)
V = math.sqrt(2*32.2*778*dh)

#result
print "Actual temperature in the flow = %d R" %T
print "Flow velocity = %d ft/sec" %V

#difference in answeres is due to internal rounding off in Python
Actual temperature in the flow = 522 R
Flow velocity = 494 ft/sec

Example 6.7, page no. 111

In [9]:
import math
import scipy.integrate

#initialization
T1 = 400.0+460.0                      #R
P1 = 100.0                          #lb/in^2
P2 = 20.0                           #lb/in^2
T2 = 140.0+460.0                      #R
Cp = 50.0

#calculation
Pratio = P1/P2
Tratio = T1/T2
C = math.log(Tratio)/math.log(Pratio)
n=1/(1-C)
v1=Cp*T1/(144*P1)
v2=Cp*T2/(144*P2)
w=144*P1*v1**n
def fun(v):
	p=w/v**n
	return p

Work = scipy.integrate.quadrature(fun, v1, v2)[0]

#result
print "Work done = %f ft-lb/lbm" %Work
Work done = 45118.149895 ft-lb/lbm

Example 6.8, page no. 113

In [10]:
import math

#initialization
P1 = 15.0                     #lb/in^2
P2 = 20.0                     #lb/in^2
T1 = 40+460                   #R
T2 = 540+460                  #R

#calculation
#From table 6 at the two temperatures"
phi1 = 0.58233
phi2 = 0.75042
ds = phi2-phi1-53.3*math.log(P2/P1)/778.0

#result
print "Entropy change = %.5f B/lbm R" %ds
Entropy change = 0.14838 B/lbm R

Example 6.9, page no. 115

In [1]:
#part a

P2 = 1460.0                #pressure 2
P1 = 1900.0                #pressure 1
V2 = 1900.0                #volume 1
V1 = 1460.0                #volume 2

pratio = (P2/P1)**3.5
vratio = (V2/V1)**2.5

print "Pressure ratio is ", round(pratio,2)
print "Volume ratio is ", round(vratio,2)

#part b
#from table 6
Pr2 = 50.34                #pressure 2
Pr1 = 141.51                #pressure 1
Vr2 = 10.743                #volume 1
Vr1 = 4.974                #volume 2

pratio = (Pr2/Pr1)
vratio = (Vr2/Vr1)

print "Pressure ratio is ", round(pratio,2)
print "Volume ratio is ", round(vratio,2)
Pressure ratio is  0.4
Volume ratio is  1.93
Pressure ratio is  0.36
Volume ratio is  2.16