Chapter11-Introduction to Compressible Flow

Ex1-pg594

In [4]:
import math
#calculate the Duct Area,Change in enthalpy of air,Change in entropy
##Temperature of air entering the cold section(in K):
T1=440.;
##Absolute pressure of air entering the cold section(in kPa):
p1=188.;
##Velocity of air entering the cold section(in m/sec):
V1=210.;
##Temperature of air at outlet:(in K)
T2=351.;
##Absolute pressure of air at outlet(in kPa):
p2=213.;
##Rate of heat loss in the section(in kJ/sec):
##Gas Constant(in N-m):
R= 287.;
##Mass flow rate of air(in kg/sec):
m=0.15;
##Specific heat at constant pressue(in kJ/(kg-K)):
cp=1.;
##Specific energy at constant volume(in kJ/(kg-K)):
cv=0.717;
##Change##

##Density of air at entry:
d1=p1*10**3./R/T1
##Area(in m**2):
A=m/d1/V1
##Change in enthalpy of air(in kJ/kg):
dh=cp*(T2-T1)
##Change in internal energy of air(in kJ/kg):
du=cv*(T2-T1)
##Change in entropy(in kJ/(kg-K)):
ds=cp*math.log(T2/T1)-R/1000.*math.log(p2/p1)
print("RESULTS")
print'%s %.4f %s'%("Duct Area: ",A," m^2")
print'%s %.2f %s'%("Change in enthalpy of air: ",dh," kJ/kg")
print'%s %.2f %s'%("Change in internal energy of air:",du," kJ/kg")
print'%s %.2f %s'%("Change in entropy: ",ds," kg-K")
RESULTS
Duct Area:  0.0005  m^2
Change in enthalpy of air:  -89.00  kJ/kg
Change in internal energy of air: -63.81  kJ/kg
Change in entropy:  -0.26  kg-K

Ex3-pg600

In [5]:
##Value of k:
#calculate Variation of sound speed with altitude
import numpy
%matplotlib inline

import warnings
warnings.filterwarnings('ignore')
import math
import matplotlib
from matplotlib import pyplot
k=1.4;
##Gas Constant(in Kj/(kg-K)):
R=287.;
##Speed of sound##
import math
##Values of altitude(in m):
Al=numpy.linspace(0,15000,num=16)
mAl=len(Al);
##Values of temperature at given altitudes(in K):
T=numpy.array([288.2, 281.7, 275.2, 268.7, 262.2, 255.7, 249.2, 242.7, 236.2, 229.7, 223.3 ,216.8, 216.7, 216.7, 216.7, 216.7]); 
mT=len(T);##Values of speed of sound at these altitudes(in m/sec):
c=numpy.zeros(mT)
C1=numpy.zeros(mT)
for j in range (0,mT):
    c[j]=math.sqrt(k*R*T[j]);##Speed of sound at sea level(in m/sec):
    C1[j]=math.sqrt(k*R*T[0]);

print len(c) 
pyplot.plot(c,Al)
pyplot.title('Variation of sound speed with altitude')
16
Out[5]:
<matplotlib.text.Text at 0x72a9b30>

Ex4-pg607

In [2]:
import math
#calculate Stagnation pressure at entry, and exit ,Temperature at exit,Change in entropy
##Pressure at entry(in kPa):
p1=350.;
##Temperature at entry(in K)
T1=333.;
##Velocity at entry(in m/s):
V1=183.;
##Mach no. at exit:
M2=1.3;
##Stagnation pressure at exit(in kPa):
p02=385.;
##Stagnation temperature at exit(in K):
T02=350.;
##Value of k:
k=1.4;
##Gas constant(in N-m/kg-K)
R=287.;
##Specific heat at constant pressure(kJ/(kg-K):
cp=1.;
##pressure and change##

##Mach number at entry:
M1=V1/math.sqrt(k*R*T1)
##Stagnation pressure at entry(in kPa):
p01=p1*(1.+(k-1.)/2.*M1**2.)**(k/(k-1.))
##Stagnation temperature at entry(in K):
T01=T1*(1.+(k-1.)/2.*M1**2.)
##Static pressure at exit(in kPa):
p2=p02/(1.+(k-1.)/2.*M2**2.)**(k/(k-1.))
##Temperature at exit(in K):
T2=T02/(1.+(k-1.)/2*M2**2.)
##Change in entropy(in kJ/kg-K):
ds=cp*math.log(T2/T1)-R/1000.*math.log(p2/p1)
print("RESULTS")
print'%s %.2f %s'%("Stagnation pressure at entry: ",p01," kPa")
print'%s %.2f %s'%("Stagnation temperature at entry: ",T01," K")
print'%s %.2f %s'%("Static pressure at exit: ",p2," kPa")
print'%s %.2f %s'%("Temperature at exit: ",T2," K")
print'%s %.2f %s'%("Change in entropy: ",ds," kJ/kg-K")
RESULTS
Stagnation pressure at entry:  415.26  kPa
Stagnation temperature at entry:  349.67  K
Static pressure at exit:  138.95  kPa
Temperature at exit:  261.58  K
Change in entropy:  0.02  kJ/kg-K