Chapter 12:Compressible Flow

Example 12.12-1, Page No:638

In [1]:
import math

#Variable Decleration
V_1=250 #Velocity in m/s
c_p=1.005 #Constant Pressure specific heat in kJ/kg.K
k=1.4 #Specific heat ratio 
T1=255.7 #
C=10**-3 #COnversion factor
P1=54.05 #Atmospheric Pressure in kPa
SPR=8 #Stagnation pressure ratio 

#Calculations
#Part(a)
T_01=T1+((V_1**2/(2*c_p))*C) #Stagnation temperature in K

P_01=P1*((T_01/T1)**(k/(k-1))) #Stagnation Pressure in kPa

#Part(b)
T_02=T_01*((SPR)**((k-1)/k)) #Stagnation Temperature at compressor exit in K

Win=c_p*(T_02-T_01) #Work per unit mass of air in kJ/kg

#Result
print "The stagnation pressure is",round(P_01,2),"kPa"
print "The required compressor work per unit mass is",round(Win,1),"kJ/kg"
The stagnation pressure is 80.77 kPa
The required compressor work per unit mass is 233.9 kJ/kg

Example 12.12-2, Page No:639

In [29]:
import math

#Variable Decleration
cp=0.846 #Specific Heat in kJ/kg.K
k=1.289 #Specific heat ratio
R=0.1889 #gas constant for Carbon dioxide in kJ/kg.K
T_0=473 #Temperature in K
P0=1.4*10**3 #Pressure in kPa
P=1.2*10**3 #Pressure in kPa
m_dot=3 #Mass flow rate in kg/s

#Calcualtions
x=((k-1)/k)
b=float(P/P0)
T=T_0*((b)**x) #Temperature where pressure is P in K
V=(2*cp*(T0-T)*10**3)**0.5 #Velocity in m/s

#Using The Ideal Gas relation
rho=P/(R*T) #Density of the fluid in kg/m^3

#Using the mass flow rate relation
A=m_dot/(rho*V) #Area in m^2

c=(k*R*T*10**3)**0.5 #speed of sound in m/s

#Mach Number
Ma=V/c #Mach's Number

#Result
print "Similarly we can compute data for other pressures as well"
print "The denisty of air is",round(rho,5),"kg/m^3"
print "The area is",A,"m^2"
print "The speed of sound is",round(c,2),"m/s"
print "The Mach Number is",round(Ma,3)
Similarly we can compute data for other pressures as well
The denisty of air is 13.90266 kg/m^3
The area is 0.00130869674184 m^2
The speed of sound is 333.56 m/s
The Mach NUmber is 0.494

Example 12.12-3,Page No:645

In [30]:
import math

#Variable Decleration
k=1.289 #Specific Heat Ratio
To=473 #Stagnation temperature in K
Po=1400 #Stagnation pressure in kPa

#Calculations
#Notation has been changed for simplicity of computation
T_ratio=2/(k+1) #ratio of T star to To
P_ratio=(2/(k+1))**(k/(k-1)) #Ratio of P star to Po

T_star=T_ratio*To #Critical Temperature in K
P_star=P_ratio*Po #Critical Pressure in kPa

#Result
print "the critical temperature and pressrue are",round(T_star),"K and",round(P_star),"kPa"
the critical temperature and pressrue are 413.0 K and 767.0 kPa

Example 12.12-4, Page No:648

In [53]:
import math

#Variable decleration
Vi=150 #Velocity at the inlet in m/s
cp=1.005 #Specific heat in kJ/Kg.K
k=1.4 #Specific heat ratio
Ti=873 #Temperature at the inlet in K
Pi=1 #Pressure at the inlet in Mpa
Pb1=0.7 #Back pressure in part a in Mpa
Pb2=0.4 #Back pressure in part b in Mpa
R=0.287 #Gas Constant in kPa.m^3/kg.K
At=50*10**-4 #Area in m^2

#Values taken from the table
P_ratio=0.67 #Presure ratio
T_ratio=0.892 #Temperature ratio
Mat=0.778 #Mach Number 

#Calculations
Toi=Ti+((Vi**2/(2*cp))*10**-3) #Stagnation Temperature in K

Poi=Pi*((Toi/Ti)**(k/(k-1))) #Stagnation Presure in mPa

#Stagnation pressure and temperature values remain constant throughout

#Part(A)
#Notation will be changed to avoid computational complexicity
BPR1=Pb1/Poi #Back Pressure ratio

Tt=T_ratio*Toi #Temperature in K
rhot=(Pb1*10**3)/(R*Tt) #Density in kg/m^3
Vt=Mat*((k*R*Tt*10**3)**0.5) #Velocity in m/s
m_dot1=rhot*At*Vt #Mass flow rate in kg/s

#Part(B)
#Notation will be changed
BPR2=Pb2/Poi #Back pressure ratio

m_dot2=(At*Poi*10**3)*((k/(Toi*R))**0.5)*((2/(k+1))**((k+1)/(2*(k-1))))*1000**0.5 #mass flow rate in kg/s

#Result
print "The mass flow rate at the nozzle is",round(m_dot1,2),"kg/s"
print "The mass flow rate through the nozzleis calculated to be",round(m_dot2,2),"kg/s"
The mass flow rate at the nozzle is 6.77 kg/s
The mass flow rate through the nozzleis calculated to be 7.11 kg/s

Example 12.12-5, Page No:650

In [63]:
import math

#Variable Decleration
Pgauge=220 #Gauge Pressure in the tire in kPa
Patm=94 #Atmospheric Pressure in kPa
R=0.287 #Gas Constant in kPa.m^3/kg.K
k=1.4 #Specific heat ratio
T=298 #Temperature in K
D=0.004 #Diamter in m

#Calculations
P=Pgauge+Patm #Absolute Pressure in the tre in kPa

#Critical Presure in the tire from table
Pstar=round(0.5283*P) #Critical Presure in kPa

#Flow is choked
rho0=P/(R*T) #Denisty of the fluid in kg/m^3
rho_star=rho0*((2/(k+1))**(1/(k-1))) #Critical Density in kg/m^3
T_star=(2/(k+1))*T #Critical Temperature in K

V=(k*R*T_star*1000)**0.5 #Velocity in m/s
m_dot=rho_star*((pi*D**2)/4)*V #mass flow rate in kg/s

#Result
print "The initial mass flow rate is",round(m_dot,5),"kg/s"
The initial mass flow rate is 0.00924 kg/s

Example 12.12-6, Page No:653

In [69]:
import math

#Variable Decleration
k=1.4 #Specific Heat ratio
R=0.287 #Gas Constant in kJ/kg.K
Ma=2 #Mach Number
A=20*10**-4 #Throat Area in m^2
P0=1000 #Pressure in kPa
T0=800 #Temperature in K

#Calculations
rho0=P0/(R*T0) #Density of the fluid in kg/m^3

#Part(a) When Ma=1
#Notation has been changed
#Taking values from the table
P_ratio=0.5283 #Pressure ratio
T_ratio=0.8333 #Temperature Ratio
rho_ratio=0.6339 #Density Ratio

#Thus
P_star=P_ratio*P0 #Critical Pressure in kPa
T_star=T_ratio*T0 #Critical Temperature in K
rho_star=rho_ratio*rho0 #Critical Denisty in kg/m^3

V_star=(k*R*T_star*1000)**0.5 #Critical Velocity in m/s

#Part(b) When Ma=2
P_ratio2=0.1278 #Pressure ratio in part b
T_ratio2=0.5556 #Temperature ratio in part b
rho_ratio2=0.23 #Density ratio in part b
Ma_star=1.633 #Critical Mach Number
A_ratio=1.6875 #Area ratio in part b

#Thus
Pe=P_ratio2*P0 #Pressure at the exit plane in kPa
Te=T_ratio2*T0 #Temperature at the exit plane in K
rho_e=rho_ratio2*rho0 #Density at the exit plane in kg/m^3
Ae=A_ratio*A #Area at the exit plane in m^2
Ve=Ma_star*V_star #Velocity at the exit plane in m/s

#Part(c)
m_dot=rho_star*A*V_star #Mass flow rate in kg/s


#Result
print "The throat conditions are as follows"
print "P*=",round(P_star),"kPa","T*=",round(T_star,1),"K","rho*=",round(rho_star,3),"kg/m^3"
print "The exit plane conditions are as follows"
print "Pe=",round(Pe),"kPa","Te=",round(Te,1),"K","rho_e=",round(rho_e,3),"kg/m^3"
print "Ae=",Ae,"m^2"
print "The mass flow rate is",round(m_dot,2),"kg/s"
The throat conditions are as follows
P*= 528.0 kPa T*= 666.6 K rho*= 2.761 kg/m^3
The exit plane conditions are as follows
Pe= 128.0 kPa Te= 444.5 K rho_e= 1.002 kg/m^3
Ae= 0.003375 m^2
The mass flow rate is 2.86 kg/s

Example 12.12-8, Page No:659

In [77]:
import math

#NOTE:The variable names have been changed

#Variable Decleration
k=1.4 #Specific Heat ratio
R=0.287 #gas Constant in kJ/kg.K
cp=1.005 #Specfic heat at constant pressure in kJ/kg.K
#Table Values
P01=1 #pressure in MPa
P1=0.1278 #Pressure in MPa
T1=444.5 #Temperature in K
rho1=1.002 #Denisty in kg/m^3
Ma1=2 #Mach Number 
Ma2=0.5774 #Mach Number 
Po_ratio=0.7209 #Presure ratio
P_ratio=4.5 #Pressure ratio
T_ratio=1.6875 #Temperature Ratio
rho_ratio=2.6667 #Density Ratio
A=20*10**-4 #Area in m^2

#Calculations
#Part(a)

P02=Po_ratio*P01 #Stagnation Pressure after the shockwave in MPa
P2=P1*P_ratio #Static Pressure after the shockwave in MPa
T2=T_ratio*T1 #Temperature after the shockwave in K
rho2=rho_ratio*rho1 #Denisty after the shockwave in kg/m^3

#Part(b)
e_change=cp*(np.log(T2/T1))-(R*np.log(P2/P1)) #Entropy change across the shock in kJ/kg.K

#Part(c)
V2=Ma2*(k*R*T2*1000)**0.5 #Velocity in m/s

#Part(d)
#Same as example 12-6 above
m_dot=2.86 #Mass Flow rate in kg/s

#Result
print "The Following are the values"
print "Stagnation Pressure",round(P02,3),"MPa"
print "Static Pressure",round(P2,3),"MPa"
print "Static Temperature",round(T2,1),"K"
print "Static Denisty",round(rho2,2),"kg/m^3"
print "The entropy change is",round(e_change,5),"kJ/kg.K"
print "The exit velocity is",round(V2),"m/s"
print "The mass flow rate is",round(m_dot,3),"kg/s"
The Following are the values
Stagnation Pressure 0.721 MPa
Static Pressure 0.575 MPa
Static Temperature 750.1 K
Static Denisty 2.67 kg/m^3
The entropy change is 0.09419 kJ/kg.K
The exit velocity is 317.0 m/s
The mass flow rate is 2.86 kg/s

Example 12.12-9, Page No:667

In [81]:
import math

#Variable Decleration
u=19 #angle of Mach lines in Degrees

#Calculations
Ma1=1/(sin((u*pi)/180)) #Mach Number 

#Result
print "The Mach Number is",round(Ma1,2)
The Mach Number is 3.07

Example 12.12-10, Page No:667

In [85]:
import math

#NOTE:Some Variable names have been changed

#Variable Decleration
Ma1=2 #Mach Number
k=1.4 #Specific heat ratio
theta=10 #Deflection in degrees
beta_weak=39.3 #Oblique shock angle in degrees
beta_strong=83.7 #Oblique shock angle in degrees
P1=75 #Pressure in kPa
Ma2_n_w=0.8032 #Mach Number on Downstream side
Ma2_n_s=0.5794 #Mach Number on Downstream Side 

#Calculations

#Weak shock
Ma1_n_w=Ma1*sin((beta_weak*pi)/180) #Mach Number

#Strong Shock
Ma1_n_s=Ma1*sin((beta_strong*pi)/180) #Mach Number

#Pressure Calculations

#Weak Shock
P2_w=((2*k*(Ma1_n_w**2)-k+1)/(k+1))*P1 #Pressure in kPa

#Strong Shock
P2_s=((2*k*(Ma1_n_s**2)-k+1)/(k+1))*P1 #Pressure in kPa

Ma2_w=Ma2_n_w/sin(((beta_weak-theta)*pi)/180) #Mach NUmber on the downstream side

Ma2_s=Ma2_n_s/sin(((beta_strong-theta)*pi)/180) #Mach NUmber on the downstream side

#Result
print "The Mach number on the downstream side of the oblique shock are"
print "Ma in weak shock",round(Ma2_w,3),"Ma in strong shock",round(Ma2_s,3)
The Mach number on the downstream side of the oblique shock are
Ma in weak shock 1.641 Ma in strong shock 0.604

Example 12.12-11, Page no:668

In [128]:
import math

#Variable Decleration
Ma1=2 #Mach Number 
P1=230 #Pressure in kPa
k=1.4 #Specific Heat ratio
theta=10 #Degrees
Ma2=2.38 #Mach Number 

#Calculations
#Simplfying the calculation
a=((k+1)/(k-1))**0.5
b=((Ma1**2)-1)**0.5
c=((k-1)/(k+1))**0.5
d=arctan(b)*180*pi**-1
e=arctan(c*b)*180*pi**-1

vMa1=a*e-d #Upstream Prandtl-Meyer Function in degrees
vMa2=theta+vMa1 #Degrees

#Pressure Calculations
#Simplifying Calculations
a1=(k-1)*0.5
b1=k/(k-1)
f=(1+a1*Ma2**2)**(-b1)
g=(1+a1*Ma1**2)**(-b1)
P2=P1*(f/g) #Pressure in kPa

#Result
print "The Mach Number on the Downstream Side is",round(Ma2,2)
print "The Pressure at the downstream side is",round(P2),"kPa"
#The answer in the textbook has not been rounded and hence differes 
The Mach Number on the Downstream Side is 2.38
The Pressure at the downstream side is 127.0 kPa

Example 12.12-14, Page No:677

In [3]:
import math

#Variable Decleration
k=1.4 #Specific Heat Ratio
cp=1.005 #Specific Heat in kJ/kg.K
R=0.287 #Gas COnstant in kJ/kg.K
P1=480 #Pressure in kPa
T1=550 #Temperature in K
D=0.15 #Diameter in m
AF=40 #Air-Fuel mass ratio
HV=42000 #Heating Value in kJ/kg
V=80 #Velocity in m/s

#Values from Tables
T_ratio=0.1291 #Temperature ratio
T_ratio1=0.1541 #Temperature Ratio
P_ratio1=2.3065 #Pressure ratio
V_ratio1=0.0668 #Velocity Ratio
T_ratio2=0.4389 #Temperature Ratio
P_ratio2=2.1086 #Pressure Ratio
V_ratio2=0.2082 #Velocity ratio

#Calculations
rho1=P1/(R*T1) #Density in kg/m^3
A1=(pi*D**2)/4 #Area in m^2
m_dot_air=rho1*A1*V #Mass flow rate of air in kg/s
m_dot_fuel=m_dot_air/AF #Mass flow rate of the fuel in kg/s
Q_dot=m_dot_fuel*HV #Heat in kW
q=Q_dot/m_dot_air #HEat Transfer rate in kJ/kg

#Stagnation Temperature and Mach Number at INLET
T01=T1+(V**2/(2*cp))*10**-3 #Stagnation Temperature in K
c1=(k*R*T1*1000)**0.5 #Speed in m/s
Ma1=V/c1 #Mach Number

#EXIT stagnation Temperature and Mach Number
T02=T01+(q/cp) #Stagnation Temperature in K

T0_star=T01/T_ratio #Critical Temperature in K

#Value for Ma2 is taken form the table corresponding to the Temperature ratio given below
T_rat=T02/T0_star #Temperature Ratio
Ma2=0.314 #Mach Number

#Exit Values
T2=T1*(T_ratio2/T_ratio1) #Temperature in K
P2=P1*(P_ratio2/P_ratio1) #Pressure in kPa
V2=V*(V_ratio2/V_ratio1) #Velocity in m/s

#Result
print "The Temperature at the exit is",round(T2),"K"
print "The pressure at the exit is",round(P2),"kPa"
print "The velocity at the exit is",round(V2),"m/s"
#The answer for temperature in tetbook is incorrect
The Temperature at the exit is 1566.0 K
The pressure at the exit is 439.0 kPa
The velocity at the exit is 249.0 m/s

Example 12.12-15, Page No:685

In [5]:
import math

#Varialble Decleration
k=1.4 #Specific Heat ratio
cp=1.005 #Specific Heat in kJ/kg.K
R=0.287 #Gas Constant in kJ/kg.K
v=1.58*10**-5 #Kinematic Viscosity in m^2/s
P1=150 #Pressure in kPa
T1=300 #Temperature in K
Ma1=0.4 #Mach Number
D=0.03 #Diameter in m
f=0.0148 #Friction factor
#Values from tables
P_ratio1=1.5901 
T_ratio1=1.1628
P_ratio2=2.6958
V_ratio=0.4313
fL1_D=2.3085

#Calculations
c1=(k*R*T1*1000)**0.5 #Inlet Velocity in m/s
V1=Ma1*c1 #Velocity in m/s
Re1=(V1*D)/v #Reynolds Number

L1_star=(fL1_D*D)/f #Duct Length in m
T_star=T1/T_ratio1 #Temperature in K
P_star=P1/P_ratio2 #Pressure in kPa
V_star=V1/V_ratio #Velocity in m/s

fraction=1-(1/P_ratio1) #Fraction of the inlet stagnation pressure lost 

#Result
print "The duct length is",round(L1_star,2),"m"
print "The Temperature is",round(T_star),"K"
print "The Pressure is",round(P_star,1),"kPa"
print "The Velocity is",round(V_star),"m/s"
print round(fraction,3),"Fraction of the total stagnation pressure is lost in the duct"
The duct length is 4.68 m
The Temperature is 258.0 K
The Pressure is 55.6 kPa
The Velocity is 322.0 m/s
0.371 Fraction of the total stagnation pressure is lost in the duct

Example 12.12-16,Page No:686

In [16]:
import math

#Variable Decleration
k=1.4 #Specific Heat ratio
cp=1.005 #Specific Heat in kJ/kg.K
R=0.287 #Gas Constant in kJ/kg.K
V1=85 #Velocity in m/s
P1=220 #Pressure in kPa
T1=450 #Temperature in K
f=0.023 #Friction factor 
L=27 #Length in m
D=0.05 #Diameter in m

#Value from table
fl_D=14.5333

#Calculations
c1=(k*R*T1*1000)**0.5 #Velocity in m/s
Ma1=V1/c1 #Mach Number

#Notation has been changed
fL_D1=(f*L)/D #Function
fL_D2=fl_D-fL_D1 #Function

#Mach NUmber corresponding to this value is 0.42
Ma2=0.420 #Mach Number

rho1=P1/(R*T1) #Density of the fluid in kg/m^3
A1=(pi*D**2)/4 #Area in m^2
m_air=rho1*V1*A1 #Mass flow rate in kg/s

#Discussion Calculations
L_max1=(fl_D*D)/f #MAx Duct length in m
L_max2=(fL_D2*D)/f #Max Duct length in m

#Result
print "The Mach Number is",round(Ma2,3)
print "The mass flow rate is",round(m_air,3),"kg/s"
print "The max length at  inlet is",round(L_max1,1),"m"
print "The max length at exit  is",round(L_max2,1),"m"
The Mach Number is 0.42
The mass flow rate is 0.284 kg/s
The max length at  inlet is 31.6 m
The max length at exit  is 4.6 m