Chapter 1 : Compressible Flow-Fundamentals

Example 1.1 page : 18

In [7]:
%matplotlib inline

import math 
from numpy import linspace
from matplotlib.pyplot import plot,legend,suptitle,xlabel,ylabel
				
#Input data
m = 0.75 				#Mass of air in kg 
T1 = 800. 				#Intial Temperature in K
P1 = 400. 				#Initial Pressure in kPa
P2 = 150. 				#Final Pressure in kPa
k = 1.4 				#Adiabatic consmath.tant
R = 0.287 				#Specific Gas consmath.tant in J/kg-K

				
#Calculation
p1 = P2/P1 				#pressure ratio of process
T2 = T1*p1**((k-1)/k) 				#Final temperature in K
W = ((m*R*(T1-T2))/(k-1)) 				#Workdone in kJ

				
#P-V Diagram

V1 = (((m*R*T1)/P1)**(1/k))*10**3 				#Inlet volume in cc
V2 = (((m*R*T2)/P2)**(1/k))*10**3 				#Final volume in cc
V = linspace(V1,V2,101)   				#Representing volume on graph, adiabatic expansion
P  =  P1*V1**k/V**k 				#Representing pressure on graph
plot(V, P) 							#Plotting  
legend('P*V**k = C') 				#Defining curve
suptitle("PV Diagram")
xlabel("V (cc)")
ylabel("P (kPa)") 				#Titles of axes
				
#Output
print 'Workdone is %3.2f kJ'%(W)
Workdone is 105.21 kJ

Example 1.2 page : 18

In [8]:
%matplotlib inline

import math 
from numpy import linspace
from matplotlib.pyplot import plot,legend,suptitle,xlabel,ylabel


#Input data
V1 = 0.35 				#Volume of gas in m**3
P1 = 110. 				#Initial Pressure in kPa
T1 = 300. 				#Intial Temperature in K
P2 = 600. 				#Final Pressure in kPa,mismath.sing data
k = 1.4 				#Adiabatic consmath.tant
Cv = 718. 				#Specific heat at consmath.tant volume in J/kg-K
R = 287. 				#Specific Gas consmath.tant in J/kg-K

				
#Calculation
dQ = 0 				#Heat transfer in J, Since Adiabatic process
m = (P1*10**3*V1)/(R*T1) 				#Mass of air in kg 
p1 = P2/P1 				#Pressure ratio
T2 = T1*p1**((k-1)/k) 				#Final temperature in K
dU = (m*Cv*(T2-T1))*10**-3 				#Change in internal energy in kJ
dW = -dU 				#Workdone in kJ, Since dQ = 0

				
#P-V Diagram

V1cc = V1*10**3 				#Inlet volume in cc
V2cc = V1cc*(T2/T1)**(1/(k-1)) 				#Final volume in cc
V = linspace(V1cc,V2cc,101)   				#Representing volume on graph, adiabatic expansion
P  =  P2*V1cc**k/V**k 				#Representing pressure on graph
plot(V, P) 				#Plotting  
legend('P*V**k = C') 				#Defining curve
suptitle("PV Diagram")
xlabel("V (cc)")
ylabel("P (kPa)") 				#Titles of axes

				
#Output
print 'A)Heat transfer is %3i J \nB)Change in internal energy is %3.3f kJ \nC)Workdone is %3.3f kJ'%(dQ,dU,dW)
A)Heat transfer is   0 J 
B)Change in internal energy is 60.072 kJ 
C)Workdone is -60.072 kJ

Example 1.3 page : 21

In [4]:
import math 
				
#Input data
P1 = 3.2 				#Initial Pressure in bar
P2 = 1. 				#Final Pressure in bar
T1 = 475. 				#Initial temperature in K
Mol = 44. 				#Molecular weight of carbondioxide in kg/mol
Ri = 8314. 				#Ideal gas consmath.tant in J/mol-K
k = 1.3 				#Adiabatic consmath.tant

				
#Calculation
R = Ri/Mol 				#Specific gas consmath.tant in J/kg-K
Cp = (k*R)/(k-1) 				#Specific heat capacity at consmath.tant pressure in J/kg-K
Cv = Cp/k 				#Specific heat capacity at consmath.tant volume in J/kg-K
p1 = P2/P1 				#Pressure ratio
T2 = T1*p1**((k-1)/k) 				#Final Temperature
dh = Cp*(T1-T2)*10**-3 				#Enthalpy drop in kJ/kg
dU = Cv*(T2-T1)*10**-3 				#Change in internal energy in kJ/kg, -ve sign indicates loss

				
#Output
print 'A)Temperature is %3.3f K \nB)Enthalpy drop is %3.3f kJ/kg \
\nC)Change in internal energy is %3.2f kJ/kg i.e. %3.2f kJ/kgloss'%(T2,dh,dU,abs(dU))
A)Temperature is 363.179 K 
B)Enthalpy drop is 91.560 kJ/kg 
C)Change in internal energy is -70.43 kJ/kg i.e. 70.43 kJ/kgloss

Example 1.4 page : 25

In [7]:
import math 

				
#Input data
P1 = 0.5 				#Initial Pressure in bar
T1 = 50.+273 				#Intial Temperature in K
C1 = 240. 				#Inlet velocity in m/s
C2 = 120. 				#Outlet velocity in m/s, mismath.sing data
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K
k = 1.4 				#Adiabatic consmath.tant

				
#Calculation
T2 = T1+((C1**2-C2**2)/(2*Cp)) 				#Final Temperature in K
t1 = T2/T1 				#Temperature ratio
P2 = P1*t1**(k/(k-1)) 				#Final Pressure in bar
ar = (P1*T2*C1)/(P2*T1*C2) 				#Ratio of outlet to inlet area

				
#Output
print 'A)At outlet:    Temperature is %3.2f K    \
\nPressure is %3.4f bar \
\nB)Ratio of outlet to inlet area is %3.4f'%(T2,P2,ar)
A)At outlet:    Temperature is 344.49 K    
Pressure is 0.6265 bar 
B)Ratio of outlet to inlet area is 1.7025

Example 1.5 page : 26

In [9]:
import math 

				
#Input data
m = 25. 				#Mass flow rate of air in kg/s
C2 = 115. 				#Outlet velocity in m/s
P1 = 100. 				#				#Initial Pressure in kPa
T1 = 300. 				#Intial Temperature in K
C1 = 40. 				#Inlet velocity in m/s
R = 0.287 				#Specific gas consmath.tant in kJ/kg-K
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K
k = 1.4 				#Adiabatic consmath.tant

				
#Calculation
T2 = T1+((C1**2-C2**2)/(2*Cp)) 				#Final Temperature in K
t1 = T2/T1 				#Temperature ratio
P2 = P1*t1**(k/(k-1)) 				#Final Pressure in bar
A1 = (m*R*T1)/(P1*C1) 				#Area at inlet in m**2
A2 = (m*R*T2)/(P2*C2) 				#Area at outlet in m**2
F = ((P1*A1)-(P2*A2))+(m*(C1-C2))*10**-3 				#Axial force on mouthpiece resulting from acceleration of air in kN

				
#Output
print 'A)Static pressure at intake face is %3.3f kPa \
\nB)Magnitude of axial force on mouthpiece resulting from acceleration of air is %3.3f kN'%(P2,F)
A)Static pressure at intake face is 93.414 kPa 
B)Magnitude of axial force on mouthpiece resulting from acceleration of air is 33.581 kN

Example 1.6 page : 27

In [10]:
import math 
				
#Input data
P = 200. 				#Pressure in kPa
C = 50. 				#Velocity of air in m/s
d = 2.9 				#Density in kg/m**3
Mol = 32. 				#Molecular weight of oxygen in kg/mol
k = 1.4 				#Adiabatic consmath.tant
Ri = 8314 				#Ideal gas consmath.tant in J/mol-K

#Calculation
R = Ri/Mol 				#Specific gas consmath.tant in J/kg-K
T = P*10**3/(R*d) 				#Temperature in K
a = math.sqrt(k*R*T) 				#Velocity of sound in m/s 
M = C/a 				#Mach number 

				
#Output
print 'Mach number is %3.2f'%(M)
Mach number is 0.16

Example 1.7 page : 32

In [11]:
import math 

				
#Input data
Pa = 1.3 				#Pressure at section-A in bar
Ta = 50.+273 				#Temperature at section-A in K
Pb = 1. 				#Pressure at section-B in bar
Tb = 13.+273 				#Temperature at section-B in K
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
ds = ((Cp*math.log(Tb/Ta))-(R*math.log(Pb/Pa)))*10**-3 				#The change in the entropy is kJ/kg
#+ve sign indicates A to B
#-ve sign indicates B to A

				
#Output
print 'The change in the entropy is %3.4f kJ/kg Since value is -ve, process must takes place from B to A'%(ds)
The change in the entropy is -0.0470 kJ/kg Since value is -ve, process must takes place from B to A

Example 1.8 page : 34

In [12]:
import math 

				
#Input data
V1 = 8. 				#Intial volume in litre
V2 = 7.8 				#Final volume in litre
P1 = 0.7 				#Intial Pressure in MPa
P2 = 2.7 				#Final Pressure in MPa

				
#Calculations
K = (P2-P1)/(math.log(V1/V2)) 				#Bulk modulus of liquid in kPa

				
#Output
print 'Bulk modulus of liquid is %3.3f kPa'%(K)
Bulk modulus of liquid is 78.996 kPa

Example 1.9 page : 35

In [13]:
import math 

				
#Input data
V1 = 0.5 				#Voume of Water required to fill pressure vessel in m**3
P = 3000. 				#Test pressure in bar
dv = 0.6 				#Change of empty volume of container due to pressurisation in percentage 
K = 20000. 				#Bulk modulus of water in MPa

				
#Calculation
m1 = V1*10**3 				#Mass of water required to fill pressure vessel in kg
Vr = (P*V1)/K 				#Reduced volume of water due to compression in m**3
Vi = dv*V1/100 				#Increased volume of container in m**3
V = Vr+Vi 				#Volume of additional water required in m**3
m = V*10**3 				#Mass of additional water required in kg
mt = m1+m 				#Total mass of water required in litre, Since 1kg = 1Lit

				
#Output
print 'Mass of water to be pumped into the vesel to obtain the desired pressure is %3i lit'%(mt)
Mass of water to be pumped into the vesel to obtain the desired pressure is 578 lit

Example 1.10 page : 35

In [15]:
import math 

				
#Input data
SG_oil = 0.8 				#Specific gravity of crude oil 
K_oil = 153036.*10**4 				#Bulk modulus of Oil in N/m**2
K_hg = 2648700.*10**4 				#Bulk modulus of Mercury in N/m**2
d_steel = 7860. 				#Density of steel in kg/m**3
E_steel = 200.*10**9 				#Modulus of elasticity in Pa
d_hg = 13600. 				#Density of mercury in kg/m**3
d_water = 1000. 				#Density of water in kg/m**3

				
#Calculation
d_oil = SG_oil*d_water 				#Density of oil in kg/m**3
a_oil = math.sqrt(K_oil/d_oil) 				#Sonic velocity of crude oil in m/s
a_hg = math.sqrt(K_hg/d_hg) 				#Sonic velocity of mercury in m/s
a_steel = math.sqrt(E_steel/d_steel) 				#Sonic velocity of steel in m/s

				
#Output
print 'A)Sonic velocity of crude oil is %3.2f m/s \
\nB)Sonic velocity of mercury is %3.2f m/s \
\nA)Sonic velocity of steel is %3.1f m/s'%(a_oil,a_hg,a_steel)
A)Sonic velocity of crude oil is 1383.09 m/s 
B)Sonic velocity of mercury is 1395.55 m/s 
A)Sonic velocity of steel is 5044.3 m/s

Example 1.11 page : 36

In [17]:
import math 

				
#Input data
T = 20.+273 				#Temperarture of medium in K
Cp_fr = 678. 				#Specific heat capacity at consmath.tant pressure of freon in J/kg-K
Cv_fr = 543. 				#Specific heat capacity at consmath.tant volime of freon in J/kg-K
T_air = 0.+273 				#Temperature of air in K
Ri = 8314. 				#Ideal gas consmath.tant in J/mol-K
mol_h = 2. 				#Molecular weight of Hydrogen in kg/mol
mol_water = 18. 				#Molecular weight of water in kg/mol
R_air = 287. 				#Specific gas consmath.tant of air in J/kg-K
k = 1.4 				#Adiabatic consmath.tant of hydrogen
k_water = 1.3 				#Adiabatic consmath.tant of water

				
#Calculation
R_h = Ri/mol_h 				#Specific gas consmath.tant of hydrogen in J/kg-K
a_h = math.sqrt(k*R_h*T) 				#Velocity of sound in hydrogen in m/s
R_water = Ri/mol_water 				#Specific gas consmath.tant of water in J/kg-K
a_water = math.sqrt(k_water*R_water*T) 				#Velocity of sound in water vapour in m/s
k_fr = Cp_fr/Cv_fr 				#Adiabatic consmath.tant of feoan
R_fr = Cp_fr-Cv_fr 				#Specific gas consmath.tant of freon in J/kg-K
a_fr = math.sqrt(k_fr*R_fr*T) 				#Velocity of sound in freon in m/s
a_air = math.sqrt(k*R_air*T_air) 				#Sonic Velocity of air at in m/s

				
#Output
print 'A)Velocity of sound in hydrogen is %3.2f m/s \
\nB)Velocity of sound in water vapour is %3.2f m/s \
\nC)Velocity of sound in freon is %3.2f m/s \
\nD)Sonic Velocity of air at %3i K is %3.4f m/s'%(a_h,a_water,a_fr,T_air,a_air)
A)Velocity of sound in hydrogen is 1305.83 m/s 
B)Velocity of sound in water vapour is 419.44 m/s 
C)Velocity of sound in freon is 222.24 m/s 
D)Sonic Velocity of air at 273 K is 331.1969 m/s

Example 1.12 page : 41

In [18]:
import math 

				
#Input data
M = 0.85 				#Mach number
P = 80. 				#Pressure in kPa
k = 1.4 				#Adiabatic Consmath.tant

				
#Calculation
Po = P*(1+(((k-1)/2)*M**2))**(k/(k-1)) 				#Pressure acting on the surface of the body in kPa

				
#Output 
print 'The highest pressure acting on the surface of the body is %3.1f kPa'%(Po)
The highest pressure acting on the surface of the body is 128.3 kPa

Example 1.13 page : 41

In [21]:
import math 
				
#Input data
P = 96. 				#Pressure in kPa
T = 27.+273 				#Temperature in K
dP = 32. 				#Difference between pivot and static pressure
k = 1.4 				#Adiabatic Consmath.tant
R = 287. 				#Specific Gas consmath.tant in J/kg-K

				
#Calculation
d = (P*10**3)/(R*T) 				#Density in kg/m**3
Ci = math.sqrt((2*(dP*10**3))/d) 				#Velocity of incompressible flow in m/s
pr = (dP)/P 				#Pressure ratio
p1 = pr+1 				#Stagnation to static pressure ratio
M = math.sqrt(((p1**((k-1)/k)-1)*2)/(k-1)) 				#Mach number
Cc = M*math.sqrt(k*R*T) 				#Velocity of compressible flow in m/s

#Output
print 'A)Air velocity in incompressible flow is %3.1f m/s \
\nB)Air velocity if flow is compressible is %3.3f m/s'%(Ci,Cc)

# note : rounding off error.
A)Air velocity in incompressible flow is 239.6 m/s 
B)Air velocity if flow is compressible is 227.226 m/s

Example 1.14 page : 42

In [23]:
import math 

				
#Input data
T1 = 200.+273 				#Intial Temperature in K
P1 = 1.7 				#Initial Pressure in bar
P2 = 1. 				#Final Pressure in bar
C1 = 30. 				#Inlet velocity in m/s
m = 1. 				#Mass flow rate in kg/s
D = 0.025 				#Nozzle diameter in m
k = 1.4 				#Adiabatic Consmath.tant
R = 287. 				#Specific Gas consmath.tant in J/kg-K
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K

				
#Calculation
p1 = P2/P1 				#Pressure ratio
T2 = T1*p1**((k-1)/k) 				#Final temperature in K
E1 = T1+(C1**2/(2*Cp)) 				#LHS of Steady flow energy equation
C2 = math.sqrt((E1-T2)*2*Cp) 				#Exit velocity of the air in m/s
d2 = (P2*10**5)/(R*T2) 				#Density at outlet in kg/m**3
A2 = math.pi*D**2/4 				#Area at outlet in m**2
n = ceil(m/(d2*A2*C2)) 				#Number of nozzles to be used

				
#Output
print 'A)Exit velocity of the air is %3.2f m/s \
\nB)Number of nozzles to be used are %1.0f'%(C2,n)
A)Exit velocity of the air is 366.94 m/s 
B)Number of nozzles to be used are 7

Example 1.15 page : 44

In [25]:
import math 
				
#Input data
Po = 300. 				#Pressure in the vessel in kPa
To = 50.+273 				#Temperature in vessel in K
M = 1. 				#Mach number 
k = 1.667 				#Adiabatic consmath.tant
Ri = 8314. 				#Ideal gas consmath.tant in J/mol-K
Mol = 4. 				#Molecular weight of helium in kg/mol

				
#Calculation
R = Ri/Mol 				#Specific gas consmath.tant in J/kg-K
Cp = (k*R)/(k-1) 				#Specific heat capacity at consmath.tant pressure in J/kg-K
p1 = (2/(k+1))**(k/(k-1)) 				#Pressure ratio
Pt = Po*p1 				#Pressure at test condition in kPa
t1 = (2/(k+1)) 				#Temperature ratio 
Tt = To*t1 				#Temperature at test condition in K
at = math.sqrt(k*R*Tt) 				#Velocity of sound in m/s
Ct = at 				#Velocity of gas at test condition in m/s
Cmax = math.sqrt(2*Cp*To) 				#Maximum velocity due to expanding of gases through nozzle system in m/s

				
#Output
print 'A)At test point:    \
\nPressure is %3.2f kPa    \
\nTemperature is %3.2f K    \
\nVelocity is %3.1f m/s \
\nB)Maximum velocity due to expanding of gases through nozzle system is %3.2f m/s'%(Pt,Tt,Ct,Cmax)
A)At test point:    
Pressure is 146.13 kPa    
Temperature is 242.22 K    
Velocity is 916.1 m/s 
B)Maximum velocity due to expanding of gases through nozzle system is 1831.88 m/s

Example 1.16 page :43

In [26]:
import math 

				
#Input data
T = 40+273 				#Temperature in K
p1 = 0.5 				#Static to Stagnation pressure ratio
k = 1.67 				#Adiabatic consmath.tant
Ri = 8314 				#Ideal gas consmath.tant in J/mol-K
Mol = 39.94 				#Molecular weight of argon in kg/mol

				
#Calculation
R = Ri/Mol 				#Specific gas consmath.tant in J/kg-K
p2 = 1/p1 				#Pressure ratio
M = math.sqrt(((p2**((k-1)/k)-1)*2)/(k-1)) 				#Mach number 
C = M*math.sqrt(k*R*T) 				#Velocity in the flow in m/s

				
#Output 
print 'A)Mach number is %3.3f \
\nB)Velocity in the flow is %3.1f m/s'%(M,C)
A)Mach number is 0.978 
B)Velocity in the flow is 322.7 m/s

Example 1.17 page : 46

In [37]:
import math 

				
#Input data
M = 2.5 				#Mach number 
h = 10 				#Height in km

				
#Calculation
alp = math.asin((1/M)) 				#Mach cone angle in degree
d = 10/math.tan((alp)) 				#Distance the jet would cover before a sonic boom is heard on ground in km
				
#Output
print 'Distance the jet would cover before a sonic boom is heard on ground is %3.2f km'%(d)
Distance the jet would cover before a sonic boom is heard on ground is 22.91 km

Example 1.18 page : 46

In [43]:
import math 

				
#Input data
h = 1100 				#Height in m
M1 = 2.5 				#Mach number of aircraft @h
T = 280 				#Temperature @h
M2 = 0.5 				#Mach number of observer
k = 1.4 				#Adiabatic Consmath.tant
R = 287 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
alp = math.sin((1/M1)) 				#Mach cone angle in degree
a = math.sqrt(k*R*T) 				#Velocity of sound in m/s
C1 = M1*a 				#Velocity of aircraft when the observer is stationary in m/s
t1 = h/(C1*(math.tan(alp))) 				#Time elapsed when the observer is stationary in sec
C2 = (M1-M2)*a 				#Velocity of aircraft when the observer is moving in the direction of aircraft in m/s
t2 = h/(C2*(math.tan(alp))) 				#Time elapsed when the observer is moving in the direction of aircraft in sec
C3 = (M1+M2)*a 				#Velocity of aircraft when the observer is moving in the opposite direction in m/s
t3 = h/(C3*(math.tan(alp))) 				#Time elapsed when the observer is moving in the opposite direction in sec

				
#Output
print 'A)Time elapsed when the observer is stationary is %3.3f sec \
\nB)Time elapsed when the observer is moving in the direction of aircraft with M = %3.1f is %3.2f sec \
\nC)Time elapsed when the observer is moving in the opposite direction is %3.2f sec'%(t1,M2,t2,t3)

# note : rounding off error .
A)Time elapsed when the observer is stationary is 3.197 sec 
B)Time elapsed when the observer is moving in the direction of aircraft with M = 0.5 is 4.00 sec 
C)Time elapsed when the observer is moving in the opposite direction is 2.66 sec

Example 1.19 page : 55

In [45]:
import math 

				
#Input data
P = 200. 				#Pressure in kPa
d = 2.9 				#Density in kg/m**3
C = 50. 				#Velocity in m/s
mol = 32. 				#Molecular weight of oxygen in kg/mol
k = 1.4 				#Adiabatic consmath.tant
Ri = 8314. 				#Ideal gas consmath.tant in J/mol-K

				
#Calculation
R = Ri/mol 				#Specific gas Consmath.tant in J/kg-k
T = (P*10**3)/(R*d) 				#Temperature in K
a = math.sqrt(k*R*T) 				#Velocity of sound in m/s 
M = C/a 				#Mach number

				
#Output
print 'Mach number is %3.4f'%(M)
Mach number is 0.1609

Example 1.20 page : 55

In [46]:
import math 

				
#Input data
C = 200 				#Velocity of object in m/s
mol = 4 				#Molecular weight of helium in kg/mol
k = 1.67 				#Adiabatic consmath.tant
Ri = 8314 				#Ideal gas consmath.tant in J/mol-K
T = 288 				#Temperature in K

				
#Calculation
R = Ri/mol 				#Specific gas Consmath.tant in J/kg-k
a = math.sqrt(k*R*T) 				#Velocity of sound in m/s
M = C/a 				#Mach number 

				
#Output
print 'Mach number is %3.1f'%(M)
Mach number is 0.2

Example 1.21 page : 56

In [50]:
import math 

				
#Input data
Z1 = 0. 				#Height from sea level in m
Z2 = 11. 				#Height from sea level in m
T1 = 288. 				#Temperature @Z1 in K, from gas tables
T2 = 216.5 				#Temperature @Z2 in K, from gas tables
C = 1000.*(5./18) 				#Velocity in m/s
k = 1.4 				#Adiabatic Consmath.tant
R = 287. 				#Specific gas consmath.tant in J/kg-k

				
#Calculation
a1 = math.sqrt(k*R*T1) 				#Sound velocity @Z1 in m/s
M1 = C/a1 				#Mach number @Z1
a2 = math.sqrt(k*R*T2) 				#Sound velocity @Z2 in m/s
M2 = C/a2 				#Mach number @Z2

				
#Output
print 'A)Speed of sound at:    \
\nsea level is %3.2f    and altitude of %3i km is %3.2f m/s \
\nB)Mach numbeer at:    sea level is %3.2f    an altitude of %3i km is %3.2f'%(a1,Z2,a2,M1,Z2,M2)
A)Speed of sound at:    
sea level is 340.17    and altitude of  11 km is 294.94 m/s 
B)Mach numbeer at:    sea level is 0.82    an altitude of  11 km is 0.94

Example 1.22 page : 56

In [52]:
import math 

				
#Input data
T = 300+273 				#Static Temperature in K
C = 200 				#Velocity in m/s
Cp = 1005 				#Specific heat capacity at consmath.tant pressure in J/kg-K

				
#Calculation
To = T+(C**2/(2*Cp)) 				#Stagnation Temperature in K
C_max = math.sqrt(2*Cp*To) 				#Maximum possible velocity obtained by air in m/s

				
#Output
print 'Maximum possible velocity obtained by air is %3.f m/s'%(C_max)

# rounding off error.
Maximum possible velocity obtained by air is 1091 m/s

Example 1.23 page : 57

In [53]:
import math 

				
#Input data
dT = 37 				#Temperature difference between air inside the tyre and nozzle exit
Cp = 1005 				#Specific heat capacity at consmath.tant pressure in J/kg-K

				
#Calculation
C = math.sqrt(2*Cp*dT) 				#Exit velocity of air in m/s

				
#Output
print 'Exit velocity of air is %3.1f m/s'%(C)
Exit velocity of air is 272.7 m/s

Example 1.24 page : 57

In [54]:
import math 

				
#Input data
C = 800*(5./18) 				#Velocity in m/s
Po = 105. 				#Stagnation pressure in kPa
To = 35.+273 				#Stagnation temperature in K
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K
k = 1.4 				#Adiabatic Consmath.tant
R = 287. 				#Specific gas consmath.tant in J/kg-k

				
#Calculation
T = To-(C**2/(2*Cp)) 				#Static temperature in K
P = Po*(T/To)**(k/(k-1)) 				#Static pressure in kPa
a = math.sqrt(k*R*T) 				#Sound Velocity in m/s 
M = C/a 				#Mach number

				
#Output
print 'A)Static conditions:    \
\nPressure is %3.2f kPa    \
\nTemperature is %3.2f K    \
\nSound Velocity is %3.2f m/s \
\nB)Mach number is %3.2f'%(P,T,a,M)
A)Static conditions:    
Pressure is 78.49 kPa    
Temperature is 283.43 K    
Sound Velocity is 337.47 m/s 
B)Mach number is 0.66

Example 1.25 page : 57

In [55]:
import math 

				
#Input data
C = 215 				#Velocity in m/s
T = 30+273 				#Static temperature in K
P = 5 				#Static pressure in bar
R = 287 				#Specific gas consmath.tant in J/kg-k
k = 1.4 				#Adiabatic Consmath.tant

				
#Calculations
a = math.sqrt(k*R*T) 				#Sound Velocity in m/s 
M = C/a 				#Mach number
To = T*(1+(((k-1)/2)*M**2)) 				#Stagnation temperature in K
Po = P*(To/T)**(k/(k-1)) 				#Stagnation pressure in kPa

				
#Output
print 'A)Stagnation Pressure is %3.4f bar \
\nB)Mach number is %3.3f'%(Po,M)
A)Stagnation Pressure is 6.4599 bar 
B)Mach number is 0.616

Example 1.26 page : 58

In [57]:
import math 

				
#Input data
T = 400. 				#Static temperature in K
k = 1.4 				#Adiabatic Consmath.tant
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K
R = 287. 				#Specific gas consmath.tant in J/kg-k

				
#Calculation
a = math.sqrt(k*R*T) 				#Sound velocity in m/s
C = a 				#Velocity of jet in m/s, Since jet has sonic velocity
To = T+(C**2/(2*Cp)) 				#Stagnation temperature in K
ao = math.sqrt(k*R*To) 				#Sound velocity at Stagnation condition in m/s 
ho = (Cp*To)*10**-3 				#Stagnation enthalpy in kJ/kg
C_max = math.sqrt(2*Cp*To) 				#Maximum velocity of jet in m/s
cr = C/C_max 				#Crocco number

				
#Output
print 'A)Velocity of sound at %3i K is %3.3f m/s \
\nB)Velocity of sound at stagnation condition is %3.3f m/s \
\nC)Maximum velocity of jet is %3.3f m/s \
\nD)Stagnation enthalpy is %3.3f kJ/kg \
\nE)Crocco number is %3.4f'%(T,C,ao,C_max,ho,cr)

# rounding off error.
A)Velocity of sound at 400 K is 400.899 m/s 
B)Velocity of sound at stagnation condition is 439.145 m/s 
C)Maximum velocity of jet is 982.202 m/s 
D)Stagnation enthalpy is 482.360 kJ/kg 
E)Crocco number is 0.4082

Example 1.27 page : 59

In [58]:
import math 

				
#Input data
C = 250. 				#Velocity of air in m/s 
D = 10. 				#Diameter in duct in cm
T = 5.+273 				#Static temperature in K
P = 40. 				#Static pressure in kPa
k = 1.4 				#Adiabatic consmath.tant
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K
R = 287. 				#Specific gas consmath.tant in J/kg-k

				
#Calculation
To = T+(C**2/(2*Cp)) 				#Stagnation temperature in K
Po = P*(To/T)**(k/(k-1)) 				#Stagnation pressure in kPa
d = (P*10**3)/(R*T) 				#Density in kg/m**3
A = (math.pi*D**2/4)*10**-4 				#Area in m**2
m = d*A*C 				#Mass flow rate in kg/s

				
#Output
print 'A)Stagnation pressure is %3.2f kPa \
\nB)Stagnation temperature is %3.2f K \
\nC)Mass flow rate is %3.4f kg/s'%(Po,To,m)
A)Stagnation pressure is 57.97 kPa 
B)Stagnation temperature is 309.09 K 
C)Mass flow rate is 0.9844 kg/s

Example 1.28 page : 59

In [59]:
import math 

				
#Input data
C = 300. 				#Velocity of air in m/s 
P = 1. 				#Static pressure in kPa
T = 290. 				#Static temperature in K
k = 1.4 				#Adiabatic consmath.tant
R = 287. 				#Specific gas consmath.tant in J/kg-k
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K

				
#Calculation
To = T+(C**2/(2*Cp)) 				#Stagnation temperature in K
Po = P*(To/T)**(k/(k-1)) 				#Stagnation pressure in kPa
a = math.sqrt(k*R*T) 				#Sound velocity in m/s
Co = math.sqrt(k*R*To) 				#Sound velocity at Stagnation condition in m/s 

				
#Output
print 'A)Stagnation pressure and temperature are %3.4f bar and %3.2f K \
\nB)Velocity of sound in the dynamic and stagnation conditions are %3.2f m/s and %3.2f m/s'%(Po,To,a,Co)
A)Stagnation pressure and temperature are 1.6529 bar and 334.78 K 
B)Velocity of sound in the dynamic and stagnation conditions are 341.35 m/s and 366.76 m/s

Example 1.29 page : 60

In [60]:
import math 

				
#Input data 
dP = 490*(1.01325/760) 				#Pressure in pivot tube in bar
P = 0.3546+1.01325 				#Static pressure(absolute) in bar 
To = 25.+273 				#Stagnation temperature in K
k = 1.4 				#Adiabaatic consmath.tant
R = 287. 				#Specific gas consmath.tant in J/kg-k
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K

				
#Calculation
Po = dP+P 				#Stagnation pressure in bar
T = To*(P/Po)**((k-1)/k) 				#Static temperature
C1 = math.sqrt(2*Cp*(To-T)) 				#Flow velocity for Compressible flow in m/s
di = Po/(R*To) 				#Density in kg/m**3
C2 = math.sqrt((2*dP)/di) 				#Flow velocity for incompressible flow in m/s

				
#Output
print 'Flow velocity for: A)Compressible flow is %3.2f m/s \
\nB)Incompressible flow is %3.2f m/s'%(C1,C2)
Flow velocity for: A)Compressible flow is 251.44 m/s 
B)Incompressible flow is 235.13 m/s

Example 1.30 page : 61

In [61]:
import math 

				
#Input data
To = 27.+273 				#Stagnation temperature in K
Po = 8. 				#Stagnation Pressure in bar
P = 5.6 				#Static pressure in bar, taken from diagram given
m = 2. 				#Mass flow rate in kg/s
k = 1.4 				#Adiabaatic consmath.tant
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K
R = 287. 				#Specific gas consmath.tant in J/kg-k

				
#Calculation
T = To*(P/Po)**((k-1)/k) 				#Static temperature in K
a = math.sqrt(k*R*T) 				#Sound velocity in m/s
C = math.sqrt(2*Cp*(To-T)) 				#Velocity in m/s
M = C/a 				#Mach number
A = ((m*R*T)/(P*10**5*C))*10**4 				#Area at a point in the channal in cm**2

				
#Output
print 'A)Mach number is %3.4f \
\nB)Velocity is %3.1f m/s \
\nC)Area at a point in the channal is %3.3f cm**2'%(M,C,A)
A)Mach number is 0.7326 
B)Velocity is 241.7 m/s 
C)Area at a point in the channal is 11.489 cm**2

Example 1.31 page : 61

In [63]:
import math 

				
#Input data
Po = 1.8 				#Stagnation pressure in atm
To = 20+273 				#Stagnation temperature in K
P = 1 				#Surrounding pressure in atm
k = 1.4 				#Adiabatic consmath.tant
R = 287 				#Specific gas consmath.tant in J/kg-k

				
#Calculation
p1 = 0.528 				#Static to Stagnation pressure ratio @Mach number = 1, from gas tables
Pt = p1*Po 				#Critical pressure in atm, Since Pt<P the flow is not chocked 
di = (Po*10**5)/(R*To) 				#Density in kg/m**3 
ao = math.sqrt(k*R*To) 				#Sound velocity at Stagnation condition in m/s
Cp = (k*R)/(k-1) 				#Specific heat capacity at consmath.tant pressure in J/kg-K
C = math.sqrt(2*Cp*To*(1-(P/Po)**((k-1)/k))) 				#Velocity of air flow which will take place from chamber to the outside through a unit area hole in m/s
G = di*ao*math.sqrt(2/(k-1))*(P/Po)**(1/k)*math.sqrt((1-(P/Po)**((k-1)/k))) 				#Mass flow rate per unit area in kg/s-m**2

				
#Output
print 'A)Velocity of air flow which will take place from chamber to the outside through a unit area hole is %3.3f m/s \
\nB)Mass flow rate per unit area is %3.3f kg/s-m**2'%(C,G)

# note : rounding off error.
A)Velocity of air flow which will take place from chamber to the outside through a unit area hole is 301.662 m/s 
B)Mass flow rate per unit area is 424.333 kg/s-m**2

Example 1.32 page: 62

In [65]:
import math 

				
#Input data
A1 = 465.125 				#Cross sectional area at entry in cm**2
T1 = 26.66+273 				#Static temperature at section-1 in K
P1 = 3.4473 				#Static Pressure at section-1 in bar
C1 = 152.5 				#Velocity at section-1 in m/s
P2 = 2.06838 				#Static Pressure at section-2 in bar
T2 = 277.44 				#Static temperature at section-2 in K
C2 = 260.775 				#Velocity at section-2 in m/s
Cp = 1005 				#Specific heat capacity at consmath.tant pressure in J/kg-K
k = 1.4 				#Adiabatic consmath.tant
R = 287 				#Specific gas consmath.tant in J/kg-k

				
#Calculations
To1 = T1+(C1**2/(2*Cp)) 				#Stagnation temperature at entry in K
To2 = T2+(C2**2/(2*Cp)) 				#Stagnation temperature at exit in K
#here To1 = To2 from answers
d1 = (P1*10**5)/(R*T1) 				#Density at section-1
d2 = (P2*10**5)/(R*T2) 				#Density at section-2
ar = (d2*C2)/(d1*C1) 				#Ratio of inlet to outlet area
A2 = A1/ar 				#Cross sectional area at exit in cm**2
C_max = math.sqrt(2*Cp*To1) 				#Maximum velocity at exit in m/s
m = d1*A1*C1*10**-4 				#Mass flow rate in kg/s 
F = ((P1*10**5*A1*10**-4)-(P2*10**5*A2*10**-4))+(m*(C1-C2)) 				#Force acting on the duct wall between two sections in N

				
#Output
print 'A)Maximum velocity and stagnation temperature at exit are %3.2f m/s and %3.2f K \
\nB)Since Stagnation temperature %3i K at entry and %3i K at exit are equal, the flow is adiabatic \
\nC)Cross sectional area at exit is %3.2f cm**2 \
\nD)Force acting on the duct wall between two sections is %3.2f N'%(C_max,To2,To1,To2,A2,F)

# rounding off error.
A)Maximum velocity and stagnation temperature at exit are 790.93 m/s and 311.27 K 
B)Since Stagnation temperature 311 K at entry and 311 K at exit are equal, the flow is adiabatic 
C)Cross sectional area at exit is 419.72 cm**2 
D)Force acting on the duct wall between two sections is 4274.31 N

Example 1.33 page : 63

In [67]:
import math 

				
#Input data
P1 = 250. 				#Static Pressure at section-1 in kPa
T1 = 26.+273 				#Static temperature at section-1 in K
M1 = 1.4 				#Mach number at entry
M2 = 2.5 				#Mach number at exit
k = 1.4 				#Adiabatic consmath.tant
R = 287. 				#Specific gas consmath.tant in J/kg-k

				
#Calculation
C1 = math.sqrt(k*R*T1)*M1 				#Air velocity at entry in m/s 
To = T1*(1+(((k-1)/2)*M1**2)) 				#Stagnation temperature in K
t1 = (1+(((k-1)/2)*M2**2)) 				#Stagnation to exit Temperature ratio
T2 = To/t1 				#Exit temperature in K
C2 = math.sqrt(k*R*T2)*M2 				#Air velocity at exit in m/s 
P2 = P1*(T2/T1)**(k/(k-1)) 				#Exit static pressure in kPa
d2 = (P2*10**3)/(R*T2) 				#Density at section-2 in kg/m**3
G = d2*C2 				#)Mass flow rate through the duct per square metre in kg/s-m**2

				
#Output
print 'A)At second section:    \
\nTemperature is %3.2f K    \
\nPressure is %3.2f kPa    \
\nVelocity is %3.4f m/s \
\nB)Mass flow rate through the duct per square metre is %3.1f kg/s-m**2'%(T2,P2,C2,G)
A)At second section:    
Temperature is 184.98 K    
Pressure is 46.56 kPa    
Velocity is 681.5676 m/s 
B)Mass flow rate through the duct per square metre is 597.8 kg/s-m**2

Example 1.34 page : 64

In [68]:
import math 

				
#Input data
M = 2. 				#Mach number
h = 20. 				#Altitude in km
Tc = -56. 				#Ambient temperature in degree Centigrade
Ta = -56.+273 				#Ambient temperature in K
k = 1.4 				#Adiabatic consmath.tant
R = 287. 				#Specific gas consmath.tant in J/kg-k
Cp = 1005. 				#Specific heat capacity at consmath.tant pressure in J/kg-K

				
#Calculation
a = math.sqrt(k*R*Ta) 				#Sound velocity in m/s
C = M*a 				#Velocity of flight in m/s
To = Tc+(C**2/(2*Cp)) 				#The maximum temperature encountered is %3.1f degree Centigrade

				
#Output
print 'The maximum temperature encountered is %3.1f degree Centigrade'%(To)
The maximum temperature encountered is 117.5 degree Centigrade

Example 1.35 page : 65

In [71]:
import math 

#Input data
W = 20000. 				#Power developed in kW
m = 12. 				#Mass flow rate in kg/s
C1 = 50. 				#Velocity of air entering in m/s
T1 = 700.+273 				#Temperature of air entering in K
T2 = 298. 				#Temperature of air leaving in K
C2 = 125. 				#Velocity of air leaving in m/s
Cp = 1.005 				#Specific heat capacity at consmath.tant pressure in kJ/kg-K

				
#Calculation
dh = Cp*(T2-T1) 				#Change in enthalpy in kJ/kg
Q = ((m*dh)+W-(m*(1./2000)*(C2**2-C1**2))) 				#The rate of heat transfer in kJ/s

				
#Output
print 'The rate of heat transfer is %3.2f kJ/s'%(Q)

# rounding off error. kindly check.
The rate of heat transfer is 11780.75 kJ/s

Example 1.36 page : 65

In [73]:
import math 
				
#Input data
mol = 39.9 				#Molecular weight of gas in kg/mol
k = 1.67 				#Adiabatic consmath.tant
Po = 500. 				#Pressure in chamber in kPa
To = 30.+273 				#Temperature in chamber in K
P1 = 80. 				#Pressure of nozzle at given section in kPa
D = 0.012 				#Cross section diameter of nozzle in m
Ri = 8314. 				#Ideal gas consmath.tant in J/mol-K

				
#Calculation
R = Ri/mol 				#Specific gas consmath.tant in J/kg-K
p1 = Po/P1 				#Stagnation to static pressure ratio
M1 = math.sqrt((((p1**((k-1)/k))-1)*2)/(k-1)) 				#Mach number at section
T1 = To*((1+(((k-1)/2)*M1**2))**(-1)) 				#Temperature at section in K
a = math.sqrt(k*R*T1) 				#Sound Velocity in m/s
C1 = M1*a 				#Gas Velocity at section in m/s
d = (P1*10**3)/(R*T1) 				#Density in kg/m**3
A1 = math.pi*D**2/4 				#Cross-sectional Area 
m = d*A1*C1 				#Mass flow rate through nozzle in kg/s

				
#Output
print 'A)At section:    \
\nMach number is %3.1f    \
\nTemperature is %3.1f K    \
\nVelocity is %3.3f m/s \
\nB)Mass flow rate through nozzle is %3.3f kg/s'%(M1,T1,C1,m)
A)At section:    
Mach number is 1.8    
Temperature is 145.3 K    
Velocity is 404.790 m/s 
B)Mass flow rate through nozzle is 0.121 kg/s

Example 1.37 page : 66

In [75]:
import math 

				
#Input data
mol = 4. 				#Molecular weight of gas in kg/mol
k = 1.3 				#Adiabatic consmath.tant
C1 = 150. 				#Gas Velocity at section-1 in m/s
P1 = 100. 				#Pressure of duct at section-1 in kPa
T1 = 15.+273 				#Temperature at section-1 in K
T2 = -10.+273 				#Temperature at section-2 in K
Ri = 8314. 				#Ideal gas consmath.tant in J/mol-K

				
#Calculation
R = Ri/mol 				#Specific gas consmath.tant in J/kg-K
a1 = math.sqrt(k*R*T1) 				#Sound velocity at section-1 in m/s
M1 = C1/a1 				#Mach number at section-1 
t1 = 0.9955 				#Static to Stagnation temperature ratio at entry from gas tables @M1,k = 1.3 
To = T1/t1 				#Stagantion temperature in K
p1 = 0.9815 				#Static to Stagnation pressure ratio at entry from gas tables @M1,k = 1.3 
Po = P1/p1 				#Stagnation pressure in kPa
t2 = T2/To 				#Static to Stagnation temperature ratio at exit
M2 = 0.82 				#Amch number at section-2 from gas tables @t2,k = 1.3
p2 = 0.659 				#Static to Stagnation pressure ratio at exit from gas tables @M2,k = 1.3 
P2 = Po*p2 				#Pressure at section-2 in kPa
a2 = math.sqrt(k*R*T2) 				#Sound velocity at section-2 in m/s
C2 = M2*a2 				#Gas Velocity at section-2 in m/s

				
#Output
print 'At the second point:    \
\nMach number is %3.2f    \
\nPressure is %3.3f kPa    \
\nVelocity is %3.2f m/s'%(M2,P2,C2)
At the second point:    
Mach number is 0.82    
Pressure is 67.142 kPa    
Velocity is 691.26 m/s

Example 1.38 page : 67

In [76]:
import math 

#Input data
A1 = 10. 				#Inlet area in cm**2
C1 = 80. 				#Inlet Air velocity in m/s
T1 = 28.+273 				#Inlet temperature in K
P1 = 700. 				#Inlet Pressure in kPa
P2 = 250. 				#Exit pressure in kPa
k = 1.4 				#Adiabatic consmath.tant
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
a1 = math.sqrt(k*R*T1) 				#Sound velocity at inlet in m/s
M1 = C1/a1 				#Mach number at inlet
t1 = 0.989 				#Static to Stagnation temperature ratio at entry from gas tables @M1,k = 1.4
To = T1/t1 				#Stagantion temperature in K
p1 = 0.964 				#Static to Stagnation pressure ratio at entry from gas tables @M1,k = 1.4 
Po = P1/p1 				#Stagnation pressure in kPa
p2 = P2/Po 				#Static to Stagnation pressure ratio 
M2 = 1.335 				#Mach number at exit 
t2 = 0.737 				#Static to Stagnation temperature ratio at exit from gas tables @M2,k = 1.4
T2 = To*t2 				#Stagnation temperatur in K
a2 = math.sqrt(k*R*T2) 				#Sound velocity at exit in m/s
C2 = M2*a2 				#Exit Air velocity in m/s
d1 = (P1*10**3)/(R*T1) 				#Density at inlet in kg/m**3
m = d1*A1*C1*10**-4 				#Mass flow rate in kg/s

				
#Output
print 'A)Mass flow rate is %3.3f kg/s \
\nB)Velocity at the exit is %3.2f m/s'%(m,C2)
A)Mass flow rate is 0.648 kg/s 
B)Velocity at the exit is 400.78 m/s

Example 1.39 page : 68

In [78]:
import math 

#Input data
V = 5. 				#Volume of air in m**3
Ae = 10.*10**-4 				#Exit area in cm**2
To = 60.+273 				#Temperature inside in the math.tank in K
Po1 = 40. 				#Intial total pressure in bar 
Po2 = 2. 				#Final total pressure in bar
P = 1. 				#Discharge pressure in bar
R = 287. 				#Specific gas consmath.tant in J/kg-K


#Calculation
#Here pressure ratios P/Po1 and P/Po2 are always less than critical pressure ratio therefore flow is choked i.e. M = 1 at exit
Gp = (0.0404184*Ae)/math.sqrt(To) 				#Mass flow rate by Stagnation pressure i.e. m/Po
#Differentiating m = (P*V)/(R*To) w.r.t. time and intrgrating resulting equation we get following expression.
t = -(V/(R*To*Gp))*math.log(Po2/Po1) 				#The time required for math.tank pressure to decrease from Po1 to Po2 in sec


#Output
print 'The time required for tank pressure to decrease from %i bar to %i bar is %3.2f sec'%(Po1,Po2,t)
The time required for tank pressure to decrease from 40 bar to 2 bar is 70.76 sec