Chapter 5 : Normal and Oblique Shock

Example 5.1 page : 18

In [2]:
import math 

#Input data
Px = 150. 				#Pressure before the shock in kPa
Tx = 25.+273 				#Temperature before the shock in K
Py = 350. 				#Pressure just after the shock in kPa
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculations
p1 = Py/Px 				#Pressure ratio 
Mx = 1.4638 				#Mach number before the shock
My = 0.716 				#Mach number after the shock from gas tables @Mx
t1 = 1.294 				#Temperature ratio after and before the shock from gas tables @p1
Ty = t1*Tx 				#Temperature ratio after the shock in K
ax = math.sqrt(k*R*Tx) 				#Velocity of sound before the shock in m/s
Cx = ax*Mx 				#Velocity of gas before the shock in m/s
ay = math.sqrt(k*R*Ty) 				#Velocity of sound after the shock in m/s
Cy = ay*My 				#Velocity of gas after the shock in m/s
p2 = 0.942 				#Stagnation pressure ratio after and before the shock from gas tables @p1
ds = R*math.log(1/p2) 				#Change in entropy in J/kg-K
p3 = 3.265 				#Stagnation pressure after shock to Static pressure before shock from gas tables @p1
Poy = p3*Px 				#Stagnation pressure after shock in kPa
Pox = Poy/p2 				#Stagnation pressure before shock in kPa
pr_loss = Pox-Poy 				#Loss of stagnation pressure of air in kPa
dd = (1000/R)*((Py/Ty)-(Px/Tx)) 				#Increase in density of air in kg/m**3

				
#Output
print 'A)Mach number before shock is %3.4f \
\nB)After shock:    \
\nMach number is %3.3f    \
\nStatic temperature is %3.3f K    \
\nVelocity is %3.2f m/s \
\nC)Increase in density of air is %3.2f kg/m**3 \
\nD)Loss of stagnation pressure of air is %3.2f kPa \
\nE)Change in entropy is %3.3f J/kg-K'%(Mx,My,Ty,Cy,dd,pr_loss,ds)
A)Mach number before shock is 1.4638 
B)After shock:    
Mach number is 0.716    
Static temperature is 385.612 K    
Velocity is 281.83 m/s 
C)Increase in density of air is 1.41 kg/m**3 
D)Loss of stagnation pressure of air is 30.15 kPa 
E)Change in entropy is 17.148 J/kg-K

Example 5.2 page : 19

In [4]:
import math 
				
#Input data
Tx = 350. 				#Temperature before the shock in K
Px = 137.8 				#Pressure before the shock in kPa
Cx = 750. 				#Velocity before the shock in m/s
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
ax = math.sqrt(k*R*Tx) 				#Velocity of sound before the shock in m/s
Mx = Cx/ax 				#Mach number before the shock
My = 0.577 				#Mach number after the shock from gas tables @Mx
p1 = 4.5 				#Static pressure ratio after and before the shock from gas tables @My
Py = Px*p1 				#Static pressure after shock in kPa
t1 = 1.687 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t1 				#Temperature ratio after the shock in K
p2 = 5.641 				#Stagnation pressure after shock to Static pressure before shock from gas tables @My
Poy = Px*p2 				#Stagnation pressure after shock in kPa
p3 = 0.721 				#Stagnation pressure ratio after and before the shock from gas tables @My
Pox = Poy/p3 				#Stagnation pressure before shock in kPa
ds = R*math.log(1/p3) 				#Change in entropy in J/kg-K
t2 = 0.555 				#Static to Stagnation temperature ratio before shock from isentropic gas tables @Mx,k = 1.4
Tox = Tx/t2  				#Stagnation temperature before shock in K
p4 = 0.128 				#Static to Stagnation pressure ratio from isentropic gas tables @Mx,k = 1.4
Pox = Px/p4 				#Stagnation pressure in kPa
t4 = 0.937 				#Static to Stagnation temperature ratio before shock from normal shock gas tables @Mx,k = 1.4 (Tox = Toy CheckenD)
Toy = Ty/t4 				#Stagnation temperature after shock in K
ay = math.sqrt(k*R*Ty) 				#Velocity of sound after the shock in m/s
Cy = (My*ay) 				#Velocity of gas after the shock in m/s

				
#Output
print 'A)At inlet to shock:    \
\nStagnation pressure is %3.1f kPa    \
\nStagnation temperature is %3.2f K    \
\nMach number is %3.0f \
\nB)After shock:    \
\nStagnation pressure is %3.2f kPa    \
\nStagnation temperature is %3.2f K    \
\nStatic pressure is %3.1f kPa    \
\nStatic temperature is %3.2f K    \
\nMach number is %3.3f    \
\nVelocity is %3.2f m/s \
\nC)Change in entropy across the shock is %3.2f J/kg-K'%(Pox,Tox,Mx,Poy,Toy,Py,Ty,My,Cy,ds)
A)At inlet to shock:    
Stagnation pressure is 1076.6 kPa    
Stagnation temperature is 630.63 K    
Mach number is   2 
B)After shock:    
Stagnation pressure is 777.33 kPa    
Stagnation temperature is 630.15 K    
Static pressure is 620.1 kPa    
Static temperature is 590.45 K    
Mach number is 0.577    
Velocity is 281.04 m/s 
C)Change in entropy across the shock is 93.88 J/kg-K

Example 5.3 page: 20

In [5]:
import math 
				
#Input data
Tx = 0+273 				#Temperature before the shock in K
Px = 60. 				#Pressure before the shock in kPa
Cx = 497. 				#Air Velocity before the shock in m/s
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
ax = math.sqrt(k*R*Tx) 				#Velocity of sound before the shock in m/s
Mx = Cx/ax 				#Mach number before the shock
My = 0.70109 				#Mach number after the shock from gas tables @Mx
p1 = 2.45833 				#Static pressure ratio after and before the shock from gas tables @My
Py =  p1*Px 				#Static pressure after shock in kPa
t1 = 1.32022 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t1 				#Temperature ratio after the shock in K
p2 = 3.41327 				#Stagnation pressure after shock to Static pressure before shock from gas tables @My
Poy = p2*Px 				#Stagnation pressure after shock in kPa
p3 = 0.92979 				#Stagnation pressure ratio after and before the shock from gas tables @My
Pox = Poy/p3 				#Stagnation pressure before shock in kPa
ay = math.sqrt(k*R*Ty) 				#Velocity of sound after the shock in m/s
Cy = ay*My 				#Velocity of air after the shock in m/s

				
#Output
print 'After shock:    A)Mach number is %3.5f    \
\nB)Velocity is %3.3f m/s    \
\nC)Stagnation pressure is %3.3f kPa'%(My,Cy,Poy)
After shock:    A)Mach number is 0.70109    
B)Velocity is 266.798 m/s    
C)Stagnation pressure is 204.796 kPa

Example 5.4 page : 21

In [6]:
import math 

				
#Input data
Px = 30. 				#Pressure before the shock in kPa
Tx = -30+273 				#Temperature before the shock in K
pr = 2.6 				#Pressure ratio across the shock wave
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
Mx = 1.54 				#Mach number before the shock from gas tables @pr
My = 0.687 				#Mach number after the shock from gas tables @Mx
t1 = 1.347 				#Temperature ratio after and before the shock from gas tables @My
Ty = t1*Tx 				#Temperature ratio after the shock in K
p1 = 3.567 				#Stagnation pressure after shock to Static pressure before shock from gas tables @My
Poy = p1*Px 				#Stagnation pressure after shock in kPa
p2 = 0.917 				#Stagnation pressure ratio after and before the shock from gas tables @My
Pox = Poy/p2 				#Stagnation pressure before shock in kPa
dP = Pox-Poy 				#Change in stagnation pressure in kPa
ax = math.sqrt(k*R*Tx) 				#Velocity of sound before the shock in m/s
Cx = (Mx*ax) 				#Air Velocity before the shock in m/s
ay = math.sqrt(k*R*Ty) 				#Velocity of sound after the shock in m/s
Cy = (My*ay) 				#Velocity of air after the shock in m/s

				
#Output
print 'A)Velocities upstream and downstream of shock wave are %3.2f m/s and %3.2f m/s respectively \
\nB)Change in stagnation pressure is %3.3f kPa'%(Cx,Cy,dP)
A)Velocities upstream and downstream of shock wave are 481.20 m/s and 249.14 m/s respectively 
B)Change in stagnation pressure is 9.686 kPa

Example 5.5 page : 22

In [8]:
import math 

				
#Input data
Mol = 39.9 				#Molar mass of a gas in kg/mol
k = 1.67 				#Specific heat ratio 
Mx = 2.5 				#Mach number before the shock 
Px = 40 				#Pressure before the shock in kPa 
Tx = -20+273 				#Temperature before the shock in K

				
#Calculation
My = 0.554 				#Mach number after the shock from gas tables @Mx
p1 = 7.567 				#Static pressure ratio after and before the shock from gas tables @My
Py = p1*Px 				#Static pressure after shock in kPa
t1 = 2.805 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t1 				#Temperature ratio after the shock in K

				
#Output
print 'Downstream the normal shock:    \
\nMach number is %3.3f    \
\nPressure is %3.2f kPa    \
\nTemperature is %3.3f K'%(My,Py,Ty)
Downstream the normal shock:    
Mach number is 0.554    
Pressure is 302.68 kPa    
Temperature is 709.665 K

Example 5.6 page : 22

In [9]:
import math 

				
#Input data
Mx = 2 				#Mach number before the shock 
Px = 50 				#Pressure before the shock in kPa 

				
#Calculation
p1 = 6.335 				#Stagnation pressure after shock to Static pressure before shock from gas tables @Mx
Poy = p1*Px 				#Stagnation pressure after shock in kPa

				
#Output
print 'Pressure acting on the front of the body is %3.2f kPa'%Poy
Pressure acting on the front of the body is 316.75 kPa

Example 5.7 page : 23

In [12]:
import math 

				
#Input data
Po = 800. 				#Pressure in reservoir in kPa
To = 40.+273 				#Temperature in reservoir in K
M2a = 2.5 				#Mach number at exit from diagram
At = 25. 				#Throat Area in cm**2 
Ax = 40. 				#Area just before the shock in cm**2
Ay = 40. 				#Area just after the shock in cm**2
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
t1 = 0.834 				#Ratio of critical temperature and stagnation temperature from gas tables @M = 1
Tt = To*t1 				#Critical temperature in K
p1 = 0.528 				#Ratio of critical pressure and stagnation pressure from gas tables @M = 1
Pt = Po*p1 				#Critical pressure in kPa
dt = Pt*10**3/(R*Tt) 				#Density in kg/m**3, Pt in Pa
at = math.sqrt(k*R*Tt) 				#Velocity of sound at throat in m/s
Ct = at 				#Air Velocity of sound at throat in m/s
m = dt*At*10**-4*Ct 				#Mass flow rate in kg/s
p2 = 0.0585 				#Ratio of exit to stagnation pressure from isentropic gas tables @M2 = 2.5
a1 = 2.637 				#Ratio of exit to critical area from isentropic gas tables @M2 = 2.5
A2 = a1*At 				#Exit area in cm**2
a2 = Ax/At 				#Area ratio
M = 1.94 				#Mach number upstream of shock from gas tables @a2
p3 = 0.140 				#Ratio of upstram of shock to stagnation pressures from isentropic gas tables @M
Px = p3*Po 				#Pressure upstram of shock in kPa
t2 = 0.570 				#Ratio of upstram of shock to stagnation temperature from isentropic gas tables @M
Tx = t2*To 				#Temperature upstram of shock in K
My = 0.588 				#Mach number downstream of shock from normal shock gas tables @M
p4 = 4.225 				#Static pressure ratio after and before the shock from gas tables @My
Py = Px*p4 				#Static pressure after shock in kPa
t3 = 1.639 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t3 				#Temperature ratio after the shock in K
p5 = 2.338 				#Stagnation pressure after shock to Static pressure before shock from gas tables @My
Poy = p5*Px 				#Stagnation pressure after shock in kPa
p6 = 0.749 				#Stagnation pressure ratio after and before the shock from gas tables @My
Pox = Poy/p6 				#Stagnation pressure before shock in kPa 
#Here At2 = Aty, Po2 = Poy, Toy = To2 = To1 = To
p7 = 0.79 				#Static to stagnation pressure ratio after shock from isentropic gas tables @My
Po2 = Py/p7 				#Stagnation pressure at exit in kPa
t4 = 0.935 				#Static to stagnation temperature ratio after shock from isentropic gas tables @My
To2 = Ty/t4 				#Stagnation temperature in K (checkeD)
a3 = 1.2 				#Ratio of areas after shock i.e. (Ay/At2)
At2 = Ay/a3 				#Critical area after shock in cm**2
a4 = A2/At2 				#Ratio of areas 
M2b = 0.31 				#Mach number at exit from gas tables @a4(as per sectionB)
p8 = 0.936 				#Static to stagnation pressure ratio at exit from isentropic gas tables @M2b
P2 = Po2*p8 				#Exit pressure in kPa
t5 = 0.981 				#Static to stagnation temperature ratio after shock from isentropic gas tables @M2b
T2 = To2*t5 				#Exit temperature in K

				
#Output
print 'CASE-I:    A)Mass flow rate is %3.2f kg/s    \
\nB)Exit area is %3.1f cm**2 CASE-II:    \
\nA)Temperature is %3.3f K    \
\nB)Pressure is %3.1f kPa'%(m,A2,T2,P2)

# note : rounding off error.
CASE-I:    A)Mass flow rate is 4.56 kg/s    
B)Exit area is 65.9 cm**2 CASE-II:    
A)Temperature is 306.800 K    
B)Pressure is 560.7 kPa

Example 5.8 page : 24

In [13]:
import math 

#Input data
Px = 1. 				#Pressure before the shock in bar
Tx = 17.+273 				#Temperature before the shock in K
Cx = 500. 				#Air Velocity before the shock in m/s
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
ax = math.sqrt(k*R*Tx) 				#Velocity of sound before the shock in m/s
Mx = Cx/ax 				#Mach number before the shock 
My = 0.715 				#Mach number after the shock from gas tables @Mx
p1 = 2.335 				#Static pressure ratio after and before the shock from gas tables @My
Py = p1*Px 				#Static pressure after shock in bar
t1 = 1.297 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t1 				#Temperature ratio after the shock in K
ay = math.sqrt(k*R*Ty) 				#Velocity of sound after the shock in m/s
Cy = ay*My 				#Velocity of air after the shock in m/s
C_y = Cx-Cy 				#Velocity of air in m/s
M_y = C_y/ay  				#Mach number impared upstream of the wave front
t2 = 0.939 				#Static to stagnation temperature ratio after shock from isentropic gas tables @M_y
T_oy = Ty/t2 				#Stagnation temperature of air in K

				
#Output
print 'A)Pressure is %3.3f bar \
\nB)Temperature is %3.2f K \
\nC)Velocity of air is %3.2f m/s \
\nD)Stagnation temperature is %3.2f K \
\nE)Mach number is %3.3f'%(Py,Ty,C_y,T_oy,M_y)
A)Pressure is 2.335 bar 
B)Temperature is 376.13 K 
C)Velocity of air is 222.04 m/s 
D)Stagnation temperature is 400.56 K 
E)Mach number is 0.571

Example 5.9 page : 25

In [16]:
import math 
				
#Input data
Mx = 3. 				#Mach number before the shock 
Tx = 27.+273 				#Temperature before the shock in K
Px = 1. 				#Pressure before the shock in bar
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K
 
				
#Calculation
My = 0.475 				#Mach number after the shock from gas tables @Mx
p1 = 10.333 				#Static pressure ratio after and before the shock from gas tables @My
Py = p1*Px 				#Static pressure after shock in bar
t1 = 2.679 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t1 				#Temperature ratio after the shock in K
p2 = 12.061 				#Stagnation pressure after shock to Static pressure before shock from gas tables @My
Poy = p2*Px 				#Stagnation pressure after shock in bar
p3 = 0.328 				#Stagnation pressure ratio after and before the shock from gas tables @My
Pox = Poy/p3 				#Stagnation pressure before shock in kPa
ay = math.sqrt(k*R*Ty) 				#Velocity of sound after the shock in m/s
Cy = ay*My 				#Velocity of air after the shock in m/s
ds = R*math.log(1/p3) 				#Change in entropy in J/kg-K
e = (Py-Px)/Px 				#Strength of shock

				
#Output
print 'I)Downstream of the shock:    \
\nA)Pressure is %3.3f bar    \
\nB)Temperature is %3.1f K    \
\nC)Gas velocity is %3.2f m/s    \
\nD)Mach number is %3.3f \nII)Total head pressure ratio is %3.3f \nIII)Entropy change across the shock is %3.3f J/kg-K \
\nIV)Strength of the shock is %3.3f'%(Py,Ty,Cy,My,p3,ds,e) 

# rounding off error.
I)Downstream of the shock:    
A)Pressure is 10.333 bar    
B)Temperature is 803.7 K    
C)Gas velocity is 269.93 m/s    
D)Mach number is 0.475 
II)Total head pressure ratio is 0.328 
III)Entropy change across the shock is 319.931 J/kg-K 
IV)Strength of the shock is 9.333

Example 5.10 page : 26

In [17]:
import math 

				
#Input data
a1 = 0.4 				#Ratio of throat area to exit area 
p1 = 0.8 				#Ratio of static pressure to Stagnation pressure at inlet
At = 1. 				#Throat area in m**2

				
#Calculation
a2 = 1/a1 				#reciprocal of a1 to find in gas tables
				#Pox = Po1 = Po, Poy = Po2
a2p2 = a2*p1 				#Area pressure ratio i.e. (A2*P2)/(At2*Po2)
M2 = 0.28 				#Exit mach number from gas tables @a2p2
a3 = 2.166 				#Ratio of exit area to throat area after shock from gas tables @a2p2 
p2 = 0.947 				#Static to stagnation pressure ratio at exit from gas tables @a2p2
p3 = a2/a3 				#Stagnation pressure ratio after and before shock 
Mx = 1.675 				#Mach number before the shock @p3
My = 0.647 				#Mach number after the shock from gas tables @Mx
a4 = 1.14 				#Ratio of area after shock to throat area after shock from isentropic gas tables @My
a5 = 1.315 				#Ratio of area before shock to throat area before shock from isentropic gas tables @My
Ax = a5*At 				#Area at shock in m**2

				
#Output 
print 'A)Mach number across the shock: Mx = %3.3f My = %3.3f) \
\nB)Area at shock is %3.3f m**2'%(Mx,My,Ax)
A)Mach number across the shock: Mx = 1.675 My = 0.647) 
B)Area at shock is 1.315 m**2

Example 5.11 page : 27

In [19]:
import math 
				
#Input data
a1 = 1./3 				#Ratio of throat area to exit area 
p1 = 0.4 				#Ratio of static pressure to Stagnation pressure at inlet

				
#Calculation
a2 = 1/a1 				#reciprocal of a1 to find in gas tables
				#we know Pox = Po1 = Po, Poy = Po2, At = Atx and Aty = At2
a2p2 = a2*p1 				#Area pressure ratio i.e. (A2*P2)/(At2*Po2)
M2 = 0.472 				#Exit mach number from gas tables @a2p2
a3 = 1.397 				#Ratio of exit area to throat area after shock from gas tables @a2p2 
p2 = 0.858 				#Static to stagnation pressure ratio at exit from gas tables @a2p2
p3 = a3/a2 				#Stagnation pressure ratio after and before shock 
Mx = 2.58 				#Mach number before the shock @p3
My = 0.506 				#Mach number after the shock from gas tables @Mx
p4 = 9.145 				#Stagnation pressure after shock to Static pressure before shock from gas tables @My
a4 = 2.842 				#Ratio of area before shock to throat area 
p5 = 0.051 				#Ratio of Pressure before shock to Stagnation pressure at entry

				
#Output 
print 'At section where shock occurs:    \
\nA)Mach number Mx = %3.2f and My = %3.3f    \
\nB)Static Pressure is %3.3f*Po1 units depend on Po1)    \
\nC)Area of cross section is %3.3f*At units depend on At)'%(Mx,My,p5,a4)
At section where shock occurs:    
A)Mach number Mx = 2.58 and My = 0.506    
B)Static Pressure is 0.051*Po1 units depend on Po1)    
C)Area of cross section is 2.842*At units depend on At)

Example 5.12 page : 28

In [22]:
import math 

				
#Input data
Po = 300. 				#Pressure in reservoir in kPa
To = 500. 				#Temperature in reservoir in K
At = 1. 				#Throat area in m**2
Ax = 2. 				#Area just before the shock in m**2
Ay = 2. 				#Area just after the shock in m**2
A2 = 3. 				#Exit area in m**2

				
#Calculation
a1 = Ax/At 				#Area ratio 
Mx = 2.2 				#Mach number upstream of shock
p1 = 0.0935 				#Ratio of pressure before shock to stagnation pressure before shock from gas tables @Mx
Px = p1*Po 				#pressure before shock in kPa
t1 = 0.50 				#Ratio of temperature before shock to stagnation pressure before shock from gas tables @Mx
Tx = t1*To 				#temperature before shock in K
My = 0.547 				#Mach number downstream of shock 
p2 = 5.480 				#Static pressure ratio after and before the shock from gas tables @My
Py = Px*p2 				#Static pressure after shock in kPa
t2 = 1.857 				#Temperature ratio after and before the shock from gas tables @My
Ty = t2*Tx 				#Temperature ratio after the shock in K
p3 = 6.716 				#Stagnation pressure after shock to Static pressure before shock from gas tables @My
Poy = Px*p3 				#Stagnation pressure after shock in kPa
Po2 = Poy 				#Exit stagnation pressure in kPa, Since total pressure remains same after shock
t3 = 0.943 				#Static to stagnation pressure after shock from isentropic gas tables @My
Toy = Ty/t3 				#Stagnation pressure after shock in K
To2 = Toy 				#Exit stagnation temperature in K, Since temperature remains after shock
a2 = 1.255 				#Ratio of area after shock to throat area after shock from isentropic gas tables @My
Aty = Ay/a2 				#Throat area after shock in m**2
At2 = Aty 				#Throat area at exit in m**2
a3 = A2/At2 				#Areas ratio
M2 = 0.33 				#Exit mach number from gas tables @a3
p4 = 0.927 				#Static to Stagnation pressure at exit from gas isentropic gas tables @a3
P2 = Po2*p4 				#Exit pressure in kPa
t4 = 0.978 				#Static to Stagnation temperature at exit from gas isentropic gas tables @a3
T2 = To2*t4 				#Exit temperature in K

				
#Output
print 'A)Pressure at section x) Px = %3.2f kPa \
\nB)Pressure at section y) Px = %3.3f kPa \
\nC)Stagnation pressure at section y) Poy = %3.2f kPa \
\nD)Throat area of cross section at section y) Aty = %3.4f m**2 \
\nE)Stagnation pressure at exit Po2 = %3.2f kPa \
\nF)Throat area of cross section at exit At2 = %3.4f m**2 \
\nG)Static Pressure at exit P2 = %3.2f kPa \
\nH)Stagantion temperature at exit To2 = %3i K \
\nI)Temperature at exit T2 = %3i k'%(Px,Py,Poy,Aty,Po2,At2,P2,To2,T2)

# rounding off error. 
A)Pressure at section x) Px = 28.05 kPa 
B)Pressure at section y) Px = 153.714 kPa 
C)Stagnation pressure at section y) Poy = 188.38 kPa 
D)Throat area of cross section at section y) Aty = 1.5936 m**2 
E)Stagnation pressure at exit Po2 = 188.38 kPa 
F)Throat area of cross section at exit At2 = 1.5936 m**2 
G)Static Pressure at exit P2 = 174.63 kPa 
H)Stagantion temperature at exit To2 = 492 K 
I)Temperature at exit T2 = 481 k

Example 5.13 page : 29

In [25]:
import math 
			
#Input data
Po1 = 500. 				#Stagnation pressure in kPa
To1 = 600. 				#Stagnation temperature in K
C1 = 100. 				#inlet velocity in m/s
A1 = 0.01 				#Inlet Area in m**2
A2 = 0.01 				#Exit Area in m**2
Mx = 1.2 				#Mach number before the shock
Ax = 37.6 				#Area just before the shock in cm**2
Ay = 37.6 				#Area just after the shock in cm**2
Px = 109.9 				#Pressure before the shock in kPa
Poy = 350. 				#Stagnation pressure after shock in kPa
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K
Cp = 1005. 				#Specific heat capacity at consmath.tant volume in J/kg-K

				
#Calculation
T1 = To1+(C1**2/(2*Cp)) 				#Inlet static temperature in K
ai_1 = math.sqrt(k*R*T1) 				#Velocity of sound at inlet in m/s
M1 = C1/ai_1 				#Inlet Mach number 
p1 = 0.973 				#Static to Stagnation pressure ratio at entry from gas tables @M1 
P1 = Po1*p1 				#Inlet static pressure in kPa
d1 = P1*10**3/(R*T1) 				#Density at inlet in kg/m**3, P1 in Pa
m = d1*A1*C1 				#Mass flow rate at inlet in kg/s
p2 = 0.528 				#Ratio of critical pressure to stagnation pressure from gas tables @M = 1
Pt = Po1*p2 				#Critical pressure in kPa
t1 = 0.834 				#Ratio of critical temperature to stagnation temperature from gas tables @M = 1
Tt = t1*To1 				#critical temperature in K
ai_t = math.sqrt(k*R*Tt) 				#Velocity of sound at critical state in m/s
Ct = ai_t 				#Velocity of air at critical state in m/s
a1 = 2.964 				#Ratio of inlet area to critical area from gas tables @M = 1
At = A1/a1 				#critical area in m**2
dt = Pt/(R*Tt) 				#Density at critical state in kg/m**3
mt = dt*At*Ct 				#Mass flow rate at critical satate in kg/s
				#Sub-division (a)
a2 = 1.030 				#Ratio of area after shock to critical area from gas tables @Mx
Ay_a = At*a2 				#Area after shock in cm**2
p3 = 0.412 				#Ratio of upstram of shock to stagnation pressures from isentropic gas tables @Mx
Px_a = Po1*p3 				#Pressure upstram of shock in kPa
t2 = 0.776 				#Ratio of upstram of shock to stagnation temperature from isentropic gas tables @Mx
Tx_a = To1*t2 				#Temperature upstram of shock in K
My_a = 0.84 				#Mach number downstream of shock from normal shock gas tables @Mx
p4 = 1.497 				#Static pressure ratio after and before the shock from gas tables @My
Py_a = Px_a*p4 				#Static pressure after shock in kPa
t3 = 1.099 				#Temperature ratio after and before the shock from gas tables @My
Ty_a = Tx_a*t3 				#Temperature ratio after the shock in K
p5 = 2.407 				#Stagnation pressure after shock to Static pressure before shock from gas tables @My
Poy_a = Px_a*p5 				#Stagnation pressure after shock in kPa
a3 = 1.204 				#Ratio of area after shock to throat area after shock from isentropic gas tables @My
At2_a = (Ay_a/a3)*10**4 				#Throat area at exit in m**2, calculation mistake in textbook
a4 = A2/At2_a 				#Ratio of areas to find gas tables 
M2_a = 0.2 				#Exit mach number at section-A from gas tables @a4
p5 = 0.973 				#ratio of exit pressure to stagnation pressure after shock from gas tables
P2_a = p5*Poy_a 				#exit pressure in kPa
#Sub-division (B)
a5 = Ax/At 				#Ratio of area before shock to critical area
Mx_b = 1.4 				#Mach number at section-B from gas tables @a5
p6 = 0.314 				#Ratio of upstram of shock to stagnation pressures from isentropic gas tables @Mx_b
Px_b = Po1*p6 				#Pressure upstram of shock in kPa
t4 = 0.718 				#Ratio of upstram of shock to stagnation temperature from isentropic gas tables @Mx_b
Tx_b = To1*t4 				#Temperature upstram of shock in K
p20 = 3.049 				#Stagnation pressure ratio after shock to Static pressure before shock from gas tables 
Poy_b = Px_b*p20 				#Stagnation pressure after shock in kPa
My_b = 0.735 				#Mach number downstream of shock from normal shock gas tables @Mx_b
p7 = 2.085 				#Static pressure ratio after and before the shock from gas tables @My_b
Py_b = Px_b*p7 				#Static pressure after shock in kPa
t5 = 1.260 				#Temperature ratio after and before the shock from gas tables @My_b
Ty_b = Tx_b*t5 				#Temperature after the shock in K
a6 = 1.071 				#Ratio of area after shock to throat area after shock from isentropic gas tables My_b = 0.735
At2_b = Ay/a6 				#Throat area at exit in m**2
a7 = A2/At2_b 				#Ratio of areas
M2_b = 0.21 				#Exit mach number at section-B from gas tables @a7
p8 = 0.9697 				#ratio of exit pressure to stagnation pressure after shock from gas tables
P2_b = p8*Poy_b 				#exit pressure in kPa
				#Sub-division (C)
p9 = Px/Po1 				#Ratio of upstram of shock to stagnation pressures 
Mx_c = 1.65 				#Mach number at section-B from gas tables @p9
a8 = 1.292 				#Ratio of area before shock to critical area from gas tables @p9
Ax_c = At*a8*10**4 				#Area before shock in cm**2
t6 = 0.647 				#Ratio of upstram of shock to stagnation temperature from isentropic gas tables @p9
Tx_c = To1*t6 				#Temperature upstram of shock in K
My_c = 0.654  				#Mach number downstream of shock from normal shock gas tables @Mx_c
p10 = 3.0095 				#Static pressure ratio after and before the shock from gas tables @My_c
Py_c = Px*p10 				#Pressure downstram of shock in kPa
t7 = 1.423 				#Temperature ratio after and before the shock from gas tables @My_c
Ty_c = Tx_c*t7 				#Temperature after the shock in K
p12 = 4 				#Stagnation pressure after shock to Static pressure before shock from gas tables @Mx_c
Poy_c = Px*p12 				#Stagnation pressure after shock in kPa
a9 = 1.136 				#Ratio of area after shock to throat area after shock from gas tables My_c = 0.654
At2_c = Ax_c/a9 				#Throat area at exit in m**2
a8 = A2/At2_c 				#Ratio of areas
M2_c = 0.23 				#Exit mach number at section-B from gas tables @a8
p11 = 0.964 				#ratio of exit pressure to stagnation pressure after shock from gas tables
P2_c = p11*Poy_c 				#exit pressure in kPa
				#Sub-division (D)
p13 = Poy/Po1 				#Pressure ratio, Since Pox = Po1
Mx_d = 2.04 				#Mach number upstream of shock from gas tables @p13
My_d = 0.571 				#Mach number downstream of shock from gas tables @p13
p14 = 4.688 				#Static pressure ratio after and before the shock from gas tables @My_d
t8 = 1.72 				#Temperature ratio after and before the shock from gas tables @My_d
p15 = 5.847 				#Stagnation pressure after shock to Static pressure before shock from gas tables @Mx_d
p16 = 0.120 				#Ratio of upstram of shock to stagnation pressures from isentropic tables @Mx_d
Px_d = Po1*p16 				#Pressure upstram of shock in kPa
t9 = 0.546 				#Ratio of upstram of shock to stagnation temperature from isentropic gas tables @Mx_d
Tx_d = To1*t9 				#Temperature upstram of shock in K
p21 = 4.688 				#Static pressure ratio after and before the shock from gas tables 
Py_d = Px_d*p21 				#Pressure downstram of shock in kPa
t12 = 1.72 				#Ratio of upstram of shock to stagnation temperature from isentropic gas tables 
Ty_d = Tx_d*t12 				#Temperature after the shock in K
a9 = 1.745 				#Ratio of area before shock to throat area from isentropic gas tables 
Ax_d = At*a9*10**4 				#Area before shock in cm**2
a10 = 1.226 				#Ratio of area after shock to throat area after shock from isentropic tables @My_d
At2_d = (Ax_d/a10) 				#Throat area at exit in cm**2
a11 = A2/At2_d 				#Ratio of areas
M2_d = 0.29 				#Exit mach number at section-B from gas tables @a11
p17 = 0.943 				#ratio of exit pressure to stagnation pressure after shock from gas tables
P2_d = p17*Poy 				#exit pressure in kPa
#Sub-division (E)
a12 = Ax/At 				#Ratio of areas
Mx_e = 2.62 				#Mach number upstream of shock from gas tables @a12
t10 = 0.421 				#Ratio of upstram of shock to stagnation temperature from isentropic gas tables 
Tx_e = To1*t10 				#Temperature upstram of shock in K
p18 = 0.0486 				#Ratio of upstram of shock to stagnation pressures from isentropic tables @Mx_e
Px_e = p18*Po1 				#Pressure upstram of shock in kPa
My_e = 0.502 				#Mach number downstream of shock from gas tables @Mx_e
p19 = 7.842 				#Static pressure ratio after and before the shock from gas tables @My_e
Py_e = Px_e*p19 				#Pressure downstram of shock in kPa
P2_e = Py_e 				#Exit pressure in kPa
t11 = 2.259 				#Temperature ratio after and before the shock from gas tables @My_d
Ty_e = Tx_e*t11 				#Temperaure downstram of shock in K
T2_e = Ty_e 				#Exit temperature in K

				
#Output 
print 'At throat:    \
\nMass flow rate is %3.2f kg/s    \
\nArea at throat is %3.5f m**2    \
\nPressure is %3i kPa    \
\nTemperature is %3.1f K    \
\nVelocity is %3.1f m/s \
\na)At section \
\nA):    Pressure upstream is %3i kPa    \
\nTemperature upstream is %3.1f K    \
\nMack number downstream is %3.2f    \
\nPressure downstream is %3.3f kPa    \
\nTemperature downstream is %3.3f K    \
\nStagnation pressure downstream is %3.1f kPa    \
\nArea is %3.3f cm**2  \
\nAt exit:    Mach number is %3.1f    \
\nPressure is %3.1f kPa \
\nB)At section \
\nB):    Pressure upstream is %3i kPa    \
\nTemperature upstream is %3.1f K    \
\nMack number upstream is %3.1f    \
\nMack number downstream is %3.3f    \
\nPressure downstream is %3.2f kPa    \
\nTemperature downstream is %3.2f K    \
\nStagnation pressure downstream is %3.1f kPa    \
\nArea is %3.3f cm**2  At exit:    \
\nMach number is %3.2f    Pressure is %3.1f kPa \
\nC)At section \
\nC):    Area upstream is %3.2f cm**2    \
\nTemperature upstream is %3.1f K    \
\nMack number upstream is %3.2f    \
\nMack number downstream is %3.3f    \
\nPressure downstream is %3.2f kPa    \
\nTemperature downstream is %3.2f K    \
\nStagnation pressure downstream is %3i kPa    \
\nArea is %3.4f cm**2  At exit:    \
\nMach number is %3.2f    \
\nPressure is %3.1f kPa \
\nD)At section \
\nD):    Pressure upstream is %3i kPa    \
\nTemperature upstream is %3.1f K    \
\nArea upstream is %3.3f cm**2    \
\nMack number upstream is %3.2f    \
\nMack number downstream is %3.2f    \
\nPressure downstream is %3.2f kPa    \
\nTemperature downstream is %3.2f K    \
\nArea is %3.3f cm**2  \
\nAt exit:    Mach number is %3.2f    \
\nPressure is %3.2f kPa \
\nE)At section \
\nE):    Pressure upstream is %3.1f kPa    \
\nTemperature upstream is %3.1f K    \
\nMack number upstream is %3.2f    \
\nMack number downstream is %3.3f    \
\nPressure downstream is %3.1f kPa    \
\nTemperature downstream is %3.2f K  \
\nAt exit:    Temperature is %3.2f K    \
\nPressure is %3.1f kPa'%(m,At,Pt,Tt,Ct,Px_a,Tx_a,My_a,Py_a,Ty_a,Poy_a,At2_a,M2_a,P2_a,Px_b,Tx_b,Mx_b,My_b,Py_b,Ty_b,Poy_b,At2_b,M2_b,P2_b,Ax_c,Tx_c,Mx_c,My_c,Py_c,Ty_c,Poy_c,At2_c,M2_c,P2_c,Px_d,Tx_d,Ax_d,Mx_d,My_d,Py_d,Ty_d,At2_d,M2_d,P2_d,Px_e,Tx_e,Mx_e,My_e,Py_e,Ty_e,T2_e,P2_e)

# note : rounding off error. kindly check using calculator.
At throat:    
Mass flow rate is 2.80 kg/s    
Area at throat is 0.00337 m**2    
Pressure is 264 kPa    
Temperature is 500.4 K    
Velocity is 448.4 m/s 
a)At section 
A):    Pressure upstream is 206 kPa    
Temperature upstream is 465.6 K    
Mack number downstream is 0.84    
Pressure downstream is 308.382 kPa    
Temperature downstream is 511.694 K    
Stagnation pressure downstream is 495.8 kPa    
Area is 28.862 cm**2  
At exit:    Mach number is 0.2    
Pressure is 482.5 kPa 
B)At section 
B):    Pressure upstream is 157 kPa    
Temperature upstream is 430.8 K    
Mack number upstream is 1.4    
Mack number downstream is 0.735    
Pressure downstream is 327.34 kPa    
Temperature downstream is 542.81 K    
Stagnation pressure downstream is 478.7 kPa    
Area is 35.107 cm**2  At exit:    
Mach number is 0.21    Pressure is 464.2 kPa 
C)At section 
C):    Area upstream is 43.59 cm**2    
Temperature upstream is 388.2 K    
Mack number upstream is 1.65    
Mack number downstream is 0.654    
Pressure downstream is 330.74 kPa    
Temperature downstream is 552.41 K    
Stagnation pressure downstream is 439 kPa    
Area is 38.3713 cm**2  At exit:    
Mach number is 0.23    
Pressure is 423.8 kPa 
D)At section 
D):    Pressure upstream is  60 kPa    
Temperature upstream is 327.6 K    
Area upstream is 58.873 cm**2    
Mack number upstream is 2.04    
Mack number downstream is 0.57    
Pressure downstream is 281.28 kPa    
Temperature downstream is 563.47 K    
Area is 48.021 cm**2  
At exit:    Mach number is 0.29    
Pressure is 330.05 kPa 
E)At section 
E):    Pressure upstream is 24.3 kPa    
Temperature upstream is 252.6 K    
Mack number upstream is 2.62    
Mack number downstream is 0.502    
Pressure downstream is 190.6 kPa    
Temperature downstream is 570.62 K  
At exit:    Temperature is 570.62 K    
Pressure is 190.6 kPa

Example 5.14 page : 33

In [28]:
import math 

				
#Input data
T = 300. 				#Temperature in K
P = 1.01325*10**5 				#Absolute pressure in Pa
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K
C_1 = 60. 				#Velocity of air in m/s
C_2 = 200. 				#Velocity of air in m/s
C_3 = 500. 				#Velocity of air in m/s
d_hg = 13600. 				#Density of mercury in kg/m**3
g = 9.81 				#Acceleration due to gravity in m/s**2

				
#Calculation
a = math.sqrt(k*R*T) 				#Sound velocity in m/s
M_1 = C_1/a 				#Mach number 
dP1 = (P*C_1**2)/(2*R*T) 				#Difference in mercury levels in Pa
dP1_hg = (dP1/(d_hg*g))*1000 				#Difference in mercury levels in mm of Hg
M_2 = C_2/a 				#Mach number 
p1 = (1+((k-1)/2)*M_2**2)**(k/(k-1)) 				#Stagnation to static pressure ratio 
Po = p1*P 				#Stagnation pressure in Pa
dP2 = abs(Po-P) 				#Difference in mercury levels in Pa
dP2_hg = (dP2/(d_hg*g))*1000 				#Difference in mercury levels in mm of Hg
M_3 = C_3/a 				#Mach number & M_3 = Mach number just before shock
My = 0.723 				#Mach number just after shock
p1 = 2.2530 				#Ratio of pressure after shock to before shock from gas tables @My
Py = p1*P 				#Pressure after shock in Pa
p2 = 0.706 				#Ratio of pressure after shock to Stagnation pressure from gas tables @My
Po = Py/p2 				#Stagnation pressure in Pa
dP3 = Po-Py 				#Difference in mercury levels in Pa
dP3_hg = (dP3/(d_hg*g))*1000 				#Difference in mercury levels in mm of Hg

				
#Output
print 'Difference in mercury levels at velocity equal to:    \
\nA)%2i m/s is %3.3f mm of Hg    \
\nB)%3i m/s is %3.1f mm of Hg    \
\nC)%3i m/s is %3i mm of Hg'%(C_1,dP1_hg,C_2,dP2_hg,C_3,dP3_hg)

# note : rounding off error.
Difference in mercury levels at velocity equal to:    
A)60 m/s is 15.877 mm of Hg    
B)200 m/s is 191.5 mm of Hg    
C)500 m/s is 712 mm of Hg

Example 5.15 page : 35

In [30]:
import math 

				
#Input data
Px = 16. 				#Pressure before the shock in kPa
Poy = 70. 				#Stagnation pressure after shock in kPa
To = 300.+273 				#Stagnation temperature in K
k = 1.4 				#Adiabatic consmath.tant 

				
#Calculation
p1 = Poy/Px 				#Pressure ratio 
Mx = 1.735 				#Mach number upstream of shock 
My = 0.631 				#Mach number downstream of shock 
p2 = 0.84 				#Ratio of stagnation pressures after and before shock from gas tables
t1 = 1.483 				#Temperature ratio after and before shock from gas tables
Tx = To/(1+((k-1)/2)*Mx**2) 				#Temperature upstream of shock in K
Ty = Tx*t1 				#Temperature downstream of shock in K
Pox = Poy/p2 				#Stagnation pressure before shock in kPa

				
#Output
print 'A)Mach number of the tunnal is Mx = %3.3f My = %3.3f) \
\nB)Upstream of the tube:    \
\nStatic temperature is %3i K    \
\nTotal pressure is %3.1f kPa \
\nC)Downstream of the tube:    \
\nStatic temperature is %3i K    \
\nTotal pressure is %3i kPa'%(Mx,My,Tx,Pox,Ty,Poy)
A)Mach number of the tunnal is Mx = 1.735 My = 0.631) 
B)Upstream of the tube:    
Static temperature is 357 K    
Total pressure is 83.3 kPa 
C)Downstream of the tube:    
Static temperature is 530 K    
Total pressure is  70 kPa

Example 5.16 page : 35

In [31]:
import math 

				
#Input data
Py = 455. 				#Pressure downstream of shock in kPa
Ty = 65.+273 				#Temperature downstream of shock in K
dP = 65. 				#Difference between dynamic and static pressure in kPa
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
Poy = dP+Py 				#Stagnation pressure after shock in kPa
p1 = Py/Poy 				#Pressure ratio 
My = 0.44 				#Mach number downstream of shock from isentropic gas tables @p1
Mx = 3.8 				#Mach number upstream of shock from normal shock gas tables @My
t1 = 3.743 				#Temperature ratio after and before the shock from gas tables @My
Tx = Ty/t1 				#Temperature before the shock in K
ax = math.sqrt(k*R*Tx) 				#Velocity of sound before the shock in m/s
Cx = Mx*ax 				#Air Velocity before the shock in m/s

				
#Output 
print 'A)Mach number is Mx = %3.1f My = %3.2f) \
\nB)Velocity is %3.2f m/s'%(Mx,My,Cx)
A)Mach number is Mx = 3.8 My = 0.44) 
B)Velocity is 723.83 m/s

Example 5.17 page : 36

In [32]:
import math 

				
#Input data
k = 1.4 				#Adiabatic consmath.tant 
Px = 1.01325 				#Pressure before the shock in bar
Tx = 15+273 				#Temperature before the shock in K
Py = 13.789 				#Pressure just after the shock in bar
R = 287 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
p1 = Py/Px 				#Pressure ratio 
Mx = 3.47 				#Mach number upstream of shock from normal shock gas tables @p1
My = 0.454 				#Mach number downstream of shock from isentropic gas tables @p1
t1 = 3.213 				#Temperature ratio after and before the shock from gas tables @Mx
Ty = Tx*t1 				#Temperature downstream of shock in K
p2 = 15.574 				#Stagnation pressure after shock to Static pressure before shock from gas tables @Mx
Poy = Px*p2 				#Stagnation pressure after shock in bar
ax = math.sqrt(k*R*Tx) 				#Velocity of sound before the shock in m/s
Cx = Mx*ax  				#Velocity of air before the shock in m/s 
Csh = Cx 				#Since Csh = Cx, see dig.
ay = math.sqrt(k*R*Ty) 				#Velocity of sound after the shock in m/s
Cy = My*ay 				#Velocity of air after the shock in m/s
C_y = Cx-Cy 				#Air velocity just inside the shock in m/s
P_y = Py 				#Pressure of air in bar, Since a powerful explosion creates a brief but intense blast wind as it passes
a_y = math.sqrt(k*R*Ty) 				#				#Velocity of sound after the shock in m/s
M_y = C_y/a_y 				#Mach number

				
#Output
print 'A)Shock speed is %3.2f m/s \
\nB)Air velocity just inside the shock is %3.2f m/s'%(Cx,C_y)
A)Shock speed is 1180.40 m/s 
B)Air velocity just inside the shock is 903.57 m/s

Example 5.18 page : 37

In [35]:
import math 

				
#Input data
T = 300. 				#Temperature in K
P = 1.5 				#Pressure in bar
C_y = 150. 				#Air velocity just inside the shock in m/s
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K
  
				
#Calculation
ax = math.sqrt(k*R*T) 				#Velocity of sound before the shock in m/s
Mx = math.sqrt(((C_y*(k+1))/(2*ax))+1) 				#Mach number before the shock
My = 0.79 				#				#Mach number after the shock from normal shock gas tables 
Cx = Mx*ax 				#Velocity of gas before the shock in m/s
p1 = 1.775 				#Stagnation pressure ratio after and before the shock from gas tables @My
Py = P*p1 				#Pressure just after the shock in bar
t1 = 1.1845 				#Temperature ratio after and before the shock from gas tables @My
Ty = T*t1 				#Temperature ratio after the shock in K
ay = math.sqrt(k*R*Ty) 				#Velocity of sound after the shock in m/s
Csh = My*ay 				#Speed of the wave in m/s

				
#Output 
print 'A)Speed of the wave is %3.1f m/s \
\nB)At rest condition:    \
\nPressure is %3.4f bar    \
\nTemperature is %3.2f K'%(Csh,Py,Ty)

# note : rounding off error.
A)Speed of the wave is 298.5 m/s 
B)At rest condition:    
Pressure is 2.6625 bar    
Temperature is 355.35 K

Example 5.19 page : 38

In [37]:
import math 

				
#Input data
Mx = 2. 				#Mach number before the shock
a1 = 3. 				#Diffuser area ratio
Pox = 0.1 				#Stagnation pressure before shock in bar
Tx = 300. 				#Temperature before the shock in K
k = 1.4 				#Adiabatic consmath.tant 

				
#Calculation
t1 = 0.555 				#Static to stagnation temperature ratio before shock from isentropic gas tables @Mx,k = 1.4
Tox = Tx/t1 				#Stagnation temperature before shock in K
p1 = 0.128 				#Static to stagnation pressure ratio before shock from isentropic gas tables @Mx,k = 1.4
Px = Pox*p1 				#Pressure before the shock in bar
My = 0.577 				#Mach number after the shock
p2 = 4.5 				#Pressure ratio after and before the shock from gas tables @Mx
Py = Px*p2 				#Pressure just after the shock in bar
t2 = 1.687 				#Temperature ratio after and before the shock from gas tables @Mx
Ty = Tx*t2 				#Temperature ratio after the shock in K
p3 = 0.721 				#Stagnation pressure ratio after and before shock from gas tables @Mx
Poy = Pox*p3 				#Stagnation pressure after shock in kPa
a2 = 1.2195 				#Ratio of area after shock to throat area after shock from gas tables @My
a3 = a2*a1 				#Ratio of exit area to throat area at exit 
M2 = 0.16 				#Exit mach number from gas tables @a3
t3 = 0.9946 				#Static to stagnation temperature ratio at exit from isentropic gas tables @Mx
T2 = Tox*t3 				#Exit Temperature in K, Since Tox = Toy = T02 in case of diffuser
p4 = 0.982 				#Static to stagnation pressure ratio at exit from isentropic gas tables @Mx
P2 = Poy*p4 				#Exit pressure in bar, Calculation mistake in textbook
eff = ((((Tox/Tx)*(Poy/Pox)**((k-1)/k))-1)/(((k-1)/2)*Mx**2))*100 				#Diffuser efficiency including shock in percent

				
#Output 
print 'A)At the diffuser exit:    \
\nMach number is %3.2f    \
\nPressure is %3.3f bar    \
\nTemperature is %3.2f K \
\nB)Diffuser efficiency including shock is %3.3f percent'%(M2,P2,T2,eff)
A)At the diffuser exit:    
Mach number is 0.16    
Pressure is 0.071 bar    
Temperature is 537.62 K 
B)Diffuser efficiency including shock is 80.129 percent

Example 5.20 page : 39

In [39]:
import math 

				
#Input data
k = 1.3 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K
P1 = 1. 				#Inlet pressure in bar
T1 = 400. 				#Inlet temperature in K
D = 0.3 				#Duct diameter in m
M1 = 2. 				#Mach number at entry
Mx = 1.5 				#Mach number upstream of shock 
M2 = 1. 				#Mach number at outlet
f = 0.003 				#Friction factor

				
#Calculation
d1 = P1*10**5/(R*T1) 				#Density at inlet in kg/m**3
a1 = math.sqrt(k*R*T1) 				#Velocity of sound at inlet in m/s 
C1 = M1*a1 				#Gas velocity at inlet in m/s
A1 = math.pi*D**2/4 				#Inlet Area of the duct in m**2
m = d1*C1*A1 				#Mass flow rate in kg/s
p1 = 0.131 				#Static to Stagnation pressure ratio at entry from gas tables (M1,k = 1.4,isentropiC)
Po1 = P1/p1 				#Stagantion pressure at inlet in bar
t1 = 0.625 				#Static to Stagnation temperature ratio at entry from gas tables (M1,k = 1.4,isentropiC)
To1 = T1/t1 				#Stagnation temperature at inlet in K
p2 = 0.424 				#Static to Critical pressure ratio at inlet from gas tables,fanno flow tables @M1,k = 1.4
Pt1 = P1/p2 				#Critical pressure in bar
p3 = 1.773 				#Stagnation pressure ratio at entry to critical state from gas tables,fanno flow tables @M1,k = 1.4
Pto1 = Po1/p3 				#Stagnation pressure at critical state in bar 
t2 = 0.719 				#Static to Critical temperature ratio at inlet from gas tables,fanno flow tables @M1,k = 1.4
Tt1 = T1/t2 				#Critical temperature in K
X1 = 0.357 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @M1,k = 1.4
p4 = 0.618 				#Ratio of Static pressure before shock to critical pressure at entry from gas tables (fanno flow,Mx,k = 1.4) 
Px = Pt1*p4 				#pressure before shock in bar
t3 = 0.860 				#Ratio of Static temperature before shock to critical temperature at entry from gas tables (fanno flow,Mx,k = 1.4) 
Tx = Tt1*t3 				#Temperature before shock in K
p5 = 1.189 				#Ratio of Stagnation pressure before shock to Stagnation pressure at critical state at entry from gas tables (fanno flow,Mx,k = 1.4) 
Pox = Pto1*p5 				#Stagnation pressure at critical state in bar
Xx = 0.156 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @Mx,k = 1.4
X3 = X1-Xx 				#Overall frictional consmath.tant fanno parameter upstream of duct
L1 = (X3*D)/(4*f) 				#Length upstream of duct in m
My = 0.7 				#Mach number downstream of shock from gas tables @Mx
p6 = 2.413 				#Static pressure ratio after and before the shock from gas tables @My
Py = Px*p6 				#Pressure after shock in bar
t4 = 1.247 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t4 				#temperature after shock in K
p7 = 0.926 				#Stagnation pressure ratio after and before the shock from gas tables @My
Poy = Pox*p7 				#Stagnation pressure after shock in bar
p8 = 1.479 				#Ratio of pressure after shock to pressure at critical state from gas tables @My
Pt = Py/p8 				#Critical pressure in bar
p9 = 1.097 				#Ratio of Stagnation pressure after shock to Stagnation pressure at critical state from gas tables @My
Pot = Poy/p9 				#Stagnation pressure at critical state in bar
t5 = 1.071 				#Ratio of temperature after shock to temperature at critical state from gas tables @My
Tt = Ty/t5 				#Critical temperature in K
Xy = 0.231 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @My,k = 1.4
X2 = 0 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @M = 1,k = 1.4
X4 = Xy-X2 				#Overall frictional consmath.tant fanno parameter downstream of duct
L2 = (X4*D)/(4*f) 				#Length downstream of duct in m
ds1 = R*math.log(Po1/Pox) 				#Change of entropy upstream of the shock in J/kg-K
ds2 = R*math.log(Pox/Poy) 				#Change of entropy across the shock in J/kg-K
ds3 = R*math.log(Poy/Pot) 				#Change of entropy downstream of the shock in J/kg-K

				
#Output
print 'A)Length of the duct upstream and downstream of the duct is %3.3f m and %3.3f m respectively \
\nB)Mass flow rate of the gas is %3.3f kg/s \
\nC)Change of entropy:    \
\nUpstream of the shock is %3.2f J/kg-K    \
\nAcross the shock is %3.3f J/kg-K    \
\nDownstream of the shock is %3.4f J/kg-K'%(L1,L2,m,ds1,ds2,ds3)
A)Length of the duct upstream and downstream of the duct is 5.025 m and 5.775 m respectively 
B)Mass flow rate of the gas is 47.573 kg/s 
C)Change of entropy:    
Upstream of the shock is 114.67 J/kg-K    
Across the shock is 22.065 J/kg-K    
Downstream of the shock is 26.5702 J/kg-K

Example 5.21 page : 41

In [40]:
import math 

				
#Input data
P1 = 0.685 				#Inlet pressure in bar
T1 = 310. 				#Inlet temperature in K
D = 0.6 				#Duct diameter in m
M1 = 3. 				#Mach number at entry
Mx = 2.5 				#Mach number upstream of shock 
M2 = 0.8 				#Mach number at outlet
f = 0.005 				#Friction factor
k = 1.4 				#Adiabatic consmath.tant 
R = 287. 				#Specific gas consmath.tant in J/kg-K

				
#Calculation
d1 = P1*10**5/(R*T1) 				#Density at inlet in kg/m**3
a1 = math.sqrt(k*R*T1) 				#Velocity of sound at inlet in m/s 
C1 = M1*a1 				#Air velocity at inlet in m/s
A1 = math.pi*D**2/4 				#Inlet Area of the duct in m**2
m = d1*C1*A1 				#Mass flow rate in kg/s
p1 = 0.218 				#Static to Critical pressure ratio at inlet from gas tables,fanno flow tables @M1,k = 1.4
Pt1 = P1/p1 				#Critical pressure in bar 
t1 = 0.428 				#Static to Critical temperature ratio at inlet from gas tables,fanno flow tables @M1,k = 1.4
Tt1 = T1/t1 				#Critical temperature in K
X1 = 0.522 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @M1,k = 1.4
p2 = 0.292 				#Ratio of Static pressure before shock to critical pressure at entry from gas tables (fanno flow,Mx,k = 1.4)
Px = Pt1*p2 				#pressure before shock in bar
t2 = 0.533 				#Ratio of Static temperature before shock to critical temperature at entry from gas tables (fanno flow,Mx,k = 1.4) 
Tx = Tt1*t2 				#Temperature before shock in K
Xx = 0.432 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @Mx,k = 1.4
X3 = X1-Xx 				#Overall frictional consmath.tant fanno parameter upstream of duct
L1 = (X3*D)/(4*f) 				#Length upstream of duct in m
My = 0.513 				#Mach number downstream of shock from gas tables @Mx
p3 = 7.125 				#Static pressure ratio after and before the shock from gas tables @My
Py = Px*p3 				#Pressure after shock in bar
t3 = 2.138 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t3 				#temperature after shock in K
p4 = 2.138 				#Ratio of pressure after shock to pressure at critical state from gas tables @My
Pt = Py/p4 				#Critical pressure in bar
t4 = 1.143 				#Ratio of temperature after shock to temperature at critical state from gas tables @My
Tt = Ty/t4 				#Critical temperature in K
p5 = 1.289 				#Ratio of pressure at exit to pressure at critical state from gas tables @M2
P2 = Pt*p5 				#Exit pressure in bar 
t5 = 1.064 				#Ratio of temperature at exit to temperature at critical state from gas tables @M2 
T2 = Tt*t5 				#Exit temperature in K
Xy = 1.069 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @My,k = 1.4
X2 = 0.073 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @M2,k = 1.4
X4 = Xy-X2 				#Overall frictional consmath.tant fanno parameter downstream of duct
L2 = (X4*D)/(4*f) 				#Length downstream of duct in m

				
#Output
print 'A)Length L1 and L2 are %3.1f m and %3.2f m respectively \
\nB)State of air at exit:    Pressure is %3.3f bar    Temperature is %3.1f K \
\nC)Mass flow rate through the duct is %3.2f kg/s'%(L1,L2,P2,T2,m)
A)Length L1 and L2 are 2.7 m and 29.88 m respectively 
B)State of air at exit:    Pressure is 3.941 bar    Temperature is 768.3 K 
C)Mass flow rate through the duct is 230.49 kg/s

Example 5.22 page : 42

In [42]:
import math 

				
#Input data
At = 24. 				#Throat area in cm**2
A2 = 50. 				#Exit area in cm**2
Po = 700. 				#Stagnation pressure in kPa
To = 100.+273 				#Stagnation temperature in K
Ax = 34. 				#Area before the shock in cm**2
Ay = 34. 				#Area after the shock in cm**2

				
#Calculation
a1 = Ax/At 				#Ratio of areas
Mx = 1.78 				#Mach number upstream of shock from gas tables @a1
t1 = 0.61212 				#Ratio of temperature before shock to critical state from isentropic gas tables @Mx
Tx = To*t1  				#temperature before shock in K
p1 = 0.179 				#Ratio of pressure before shock to critical state from isentropic gas tables @Mx
Px = Po*p1 				#pressure before shock in kPa
My = 0.621 				#Mach number downstream of shock from gas tables @Mx
p2 = 3.5298 				#Static pressure ratio after and before the shock from gas tables @My
Py = Px*p2 				#Pressure after shock in kPa
t2 = 1.51669 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t2 				#temperature after shock in K
p3 = 4.578 				#Ratio of Stagnation pressure after the shock to static pressure before shock from gas tables @My
Po2 = Px*p3 				#Stagnation pressure at exit in bar
a2 = 1.16565 				#Ratio of area after shock to critical area across shock from isentropic gas tables @My
At2 = Ay/a2 				#critical area at exit in cm**2
a3 = A2/At2 				#Ratio of areas 
M2 = 0.36 				#Exit mach number from gas tables (a3,k = 1.4,isentropiC)
p4 = 0.914 				#Static to Stagnation pressure ratio at exit from gas tables (a3,k = 1.4,isentropiC) 
P2 = Po2*p4 				#Stagnation pressure ratio at exit in kPa
t3 = 0.975 				#Static to Stagnation temperature ratio at exit from gas tables (a3,k = 1.4,isentropiC)
T2 = To*t3 				#Stagnation temperature at exit in K

				
#Output
print 'A)Properties of fluid just after shock:    \
\nMach number My = %3.3f    \
\nTemperature is %3.2f K    \
\nPressure is %3.2f kPa \
\nB)Exit mach number is %3.2f \
\nC)Properties of fluid at exit:    \
\nPressure is %3i kPa    \
\nTemperature is %3.3f K'%(My,Ty,Py,M2,P2,T2)
A)Properties of fluid just after shock:    
Mach number My = 0.621    
Temperature is 346.29 K    
Pressure is 442.28 kPa 
B)Exit mach number is 0.36 
C)Properties of fluid at exit:    
Pressure is 524 kPa    
Temperature is 363.675 K

Example 5.23 page : 44

In [43]:
import math 

				
#Input data
D = 0.4 				#Duct diameter in m
Po = 12. 				#Stagnation pressure in kPa
To = 600. 				#Stagnation temperature in K
f = 0.0025 				#Friction factor
M1 = 1.8 				#Mach number at entry
M2 = 1. 				#Mach number at outlet
Mx = 1.22 				#Mach number upstream of shock 

				
#Calculations
A2 = math.pi*D**2/4 				#Exit area in cm**2
p1 = 0.174 				#Static to Stagnation pressure ratio at entry from gas tables (M1,k = 1.4,isentropiC)
P1 = Po*p1 				#Inlet pressure in bar
t1 = 0.607 				#Static to Stagnation temperature ratio at entry from gas tables (M1,k = 1.4,isentropiC)
T1 = To*t1 				#Inlet temperature in K
a1 = 1.094 				#Ratio of area at exit to critical area across shock from isentropic gas tables @M1,k = 1.4
Ax = A2/a1 				#Area before the shock in cm**2
Dt = math.sqrt((Ax*4)/(math.pi))*10**2 				#Duct diameter at throat in cm
p2 = 0.474 				#Static to Critical pressure ratio at inlet from gas tables,fanno flow tables @M1,k = 1.4
Pt = P1/p2 				#Critical pressure in bar 
t2 = 0.728 				#Static to Critical temperature ratio at inlet from gas tables,fanno flow tables @M1,k = 1.4
Tt = T1/t2 				#Critical temperature in K
X1 = 0.242 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @M1,k = 1.4
p3 = 0.788 				#Ratio of Static pressure before shock to critical pressure at entry from gas tables (fanno flow,Mx,k = 1.4)
Px = Pt*p3 				#pressure before shock in bar
t3 = 0.925 				#Ratio of Static temperature before shock to critical temperature at entry from gas tables (fanno flow,Mx,k = 1.4)
Tx = Tt*t3 				#Temperature before shock in K
Xx = 0.039 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @Mx,k = 1.4
X3 = X1-Xx 				#Overall frictional consmath.tant fanno parameter upstream of duct
L1 = (X3*D)/(4*f) 				#Length upstream of duct in m
My = 0.83 				#Mach number downstream of shock from gas tables @Mx
p4 = 1.57 				#Static pressure ratio after and before the shock from gas tables @My
Py = Px*p4 				#Pressure after shock in bar
t4 = 1.141 				#Temperature ratio after and before the shock from gas tables @My
Ty = Tx*t4 				#temperature after shock in K
p5 = 1.2375 				#Ratio of pressure after shock to pressure at critical state from gas tables @My
Pt = Py/p5 				#Critical pressure in bar
t5 = 1.055 				#Ratio of temperature after shock to temperature at critical state from gas tables @My
Tt = Ty/t5 				#Critical temperature in K
Xy = 0.049 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @My,k = 1.4
X2 = 0 				#frictional consmath.tant fanno parameter from gas tables,fanno flow tables @M = 1,k = 1.4
X4 = Xy-X2 				#Overall frictional consmath.tant fanno parameter downstream of duct
L2 = (X4*D)/(4*f) 				#Length downstream of duct in m
L = L1+L2 				#Length of duct in m

				
#Output
print 'A)Length of the pipe is %3.2f m \
\nB)Diameter of the nozzle throat is %3.3f cm \
\nC)At the pipe exit:    \
\nPressure is %3.3f bar    \
\nTemperature is %3.2f K'%(L,Dt,Pt,Tt)
A)Length of the pipe is 10.08 m 
B)Diameter of the nozzle throat is 38.243 cm 
C)At the pipe exit:    
Pressure is 4.404 bar    
Temperature is 500.48 K

Example 5.24 page : 45

In [45]:
import math 

				
#Input data
Po = 700. 				#Stagnation pressure in kPa
To = 500.+273 				#Stagnation temperature in K
a1 = 3.5 				#Ratio of exit area to throat area
m = 5.5 				#Mass flow rate in kg/s
Cp = 1.005 				#Specific heat capacity at consmath.tant pressure in kJ/kg-K
k = 1.4 				#Adiabatic consmath.tant

				
#Calculation
My = 1/math.sqrt(k) 				#Mach number downstream of shock
M2 = 2.8 				#Mach number at outlet from gas tables @a1 
t1 = 0.389 				#Static to Stagnation temperature ratio at exit from gas tables (M1,k = 1.4,isentropiC)
T2 = To*t1 				#Exit temperature in K
p1 = 0.0369 				#Static to Stagnation pressure ratio at exit from gas tables (M1,k = 1.4,isentropiC)
P2 = Po*p1 				#exit pressure in kPa
p2 = 0.2  				#Ratio of pressure at exit to pressure at critical state at exit from Rayleigh flow gas tables @M2
Pt2 = P2/p2 				#Exit pressure at critical state in kPa
t2 = 0.315 				#Ratio of temperature at exit to temperature at critical state at exit from Rayleigh flow gas tables @M2
Tt2 = T2/t2 				#Exit temperature at critical state in K
t3 = 0.674 				#Ratio of Stagnation temperature at exit to stagnation temperature at critical state at exit from Rayleigh flow gas tables @M2
Tto2 = To/t3 				#Exit stagnation temperature at critical state in K
Mx = 1.2 				#Mach number upstream of shock from gas tables @My
p3 = 0.796 				#Ratio of Static pressure before shock to critical pressure at exit from gas tables (Rayleigh flow,Mx,k = 1.4)
Px = Pt2*p3 				#Static pressure before shock in kPa
t4 = 0.912 				#Ratio of Static temperature before shock to critical temperature at exit from gas tables (Rayleigh flow,Mx,k = 1.4)
Tx = Tt2*t4 				#Static temperature before shock in K
t5 = 0.978 				#Ratio of Stagnation temperature before shock to critical Stagnation temperature at exit from gas tables (Rayleigh flow,Mx,k = 1.4)
Tox = Tto2*t5 				#Stagnation temperature before shock in K
p4 = 1.513 				#Static pressure ratio after and before the shock from gas tables @Mx 
Py = Px*p4 				#Pressure after shock in kPa
t6 = 1.128 				#Temperature ratio after and before the shock from gas tables @Mx
Ty = Tx*t6 				#temperature after shock in K
t7 = 0.875 				#Ratio of Temperature after the shock to Stagnation temperature after shock from gas tables @Mx 
Toy = Ty/t7 				#Stagnation temperature after shock in K,
p5 = 1.207 				#Ratio of pressure after shock to pressure at critical state from gas tables @My
Pt = Py/p5 				#Critical pressure in kPa
t8 = 1.028 				#Ratio of temperature after shock to temperature at critical state from gas tables @My
Tt = Ty/t8 				#Critical temperature in K
t9 = 0.978 				#Ratio of Stagnation temperature after shock to Stagnation temperature at critical state from gas tables @My
Tot = Toy/t9 				#Stagnation temperature at critical state in K, calculation mistake in textbbok 
q1 = Cp*(Tox-To) 				#Amount of heat added in upstream of shock in kJ/s
q2 = Cp*(Tot-Toy) 				#Amount of heat added in downstream of shock in kJ/s
Q = m*(q1+q2) 				#Amount of heat added in two pipe section in kJ/s

				
#Output
print 'A)Amount of heat added in two pipe section is %3.2f kJ/s \
\nB)Properties: Upstream of shock:    \
\nPressure is %3.1f kPa    \
\nTemperature is %3.3f K    \
\nStagnation temperature is %3.2f K    \
\nMach number is %3.1f \
\nDownstream of shock:    Pressure is %3.3f kPa    \
\nTemperature is %3.3f K    \
\nStagnation temperature is %3.1f K    \
\nMach number is %3.3f \
\nAt the throat:    Pressure is %3.2f kPa    \
\nTemperature is %3.3f K    \
\nStagnation temperature is %3.2f K \
\nAt the exit:    Pressure is %3.2f kPa    \
\nTemperature is %3.2f K    \
\nMach number is %3.2f'%(Q,Px,Tx,Tox,Mx,Py,Ty,Toy,My,Pt,Tt,Tot,P2,T2,M2)
A)Amount of heat added in two pipe section is 2066.73 kJ/s 
B)Properties: Upstream of shock:    
Pressure is 102.8 kPa    
Temperature is 870.589 K    
Stagnation temperature is 1121.65 K    
Mach number is 1.2 
Downstream of shock:    Pressure is 155.542 kPa    
Temperature is 982.025 K    
Stagnation temperature is 1122.3 K    
Mach number is 0.845 
At the throat:    Pressure is 128.87 kPa    
Temperature is 955.277 K    
Stagnation temperature is 1147.56 K 
At the exit:    Pressure is 25.83 kPa    
Temperature is 300.70 K    
Mach number is 2.80

Example 5.25 page : 47

In [46]:
import math 

				
#Input data
M1 = 2.8 				#Inlet mach number 
sig = 42. 				#Shock wave angle in degree
Px = 1. 				#Pressure upstream of shock in bar(Assuming)
k = 1.4 				#Adiabatic consmath.tant 

				
#Calculations
Mx = M1*math.sin(math.radians(sig)) 				#Mach number before the shock
My = 0.601 				#Mach number after the shock from gas tables @Mx
p1 = 3.98 				#Static pressure ratio after and before the shock from gas tables @Mx 
Py = Px*p1 				#Pressure after shock in bar
p2 = 4.994 				#Stagnation pressure after shock to Static pressure before shock from gas tables @Mx
Poy = Px*p2 				#Stagnation pressure after shock in bar
p3 = 0.788 				#Stagnation pressure ratio after and before the shock from gas tables @Mx
Pox = Poy/p3 				#Stagnation pressure before shock in kPa
dPl = Pox-Poy 				#Total pressure loss in bar
#disp(((M1^2*sind(2*sig))-(2/tand(sig)))/(2+(M1^2*(k+cosd(2*sig)))))
#def=atand(((M1^2*sind(2*sig))-(2/tand(sig)))/(2+(M1^2*(k+cosd(2*sig))))) //Deflection angle in degree
def1 = (M1**2*math.sin(math.radians(2*sig)) - (2/math.tan(math.radians(sig))))/(2 + M1**2*(k+math.cos(math.radians(2*sig))))
def1 = math.degrees(math.atan(def1))
M2 = My/(math.sin(math.radians(sig-def1))) 				#Downstream mach number

				
#Output 
print 'A)Deflection angle is %3i degree \
\nB)Downstream mach number is %3.3f \
\nC)Static pressure is %3.3f bar \
\nD)Total pressure loss is %3.3f bar'%(def1,M2,Py,dPl)
A)Deflection angle is  22 degree 
B)Downstream mach number is 1.758 
C)Static pressure is 3.980 bar 
D)Total pressure loss is 1.344 bar

Example 5.26 page : 47

In [47]:
import math 

				
#Input data
M1 = 2. 				#Inlet mach number 
sig = 40. 				#Shock wave angle in degree
Px = 0.5 				#Pressure upstream of shock in bar
Tx = 273. 				#Temperature upstream of shock in K
k = 1.4 				#Adiabatic consmath.tant 

				
#Calculation
Mx = M1*math.sin(math.radians(sig)) 				#Mach number before the shock
My = 0.796 				#Mach number after the shock from gas tables @Mx
p1 = 1.745 				#Static pressure ratio after and before the shock from gas tables @Mx 
Py = p1*Px 				#Pressure after shock in bar
t1 = 1.178 				#Static temperature ratio after and before the shock from gas tables @Mx 
Ty = Tx*t1 				#Temperature after shock in K
Ws = math.degrees(math.atan(((M1**2*math.sin(math.radians(2*sig))) - (2/math.tan(math.radians(sig)))) / (2+ (M1**2*(k+math.cos(math.radians(2*sig)))))))
W = 2*Ws 				#Wedge angle in degree

				
#Output
print 'A)Static pressure is %3.4f bar \
\nB)Temperature behind the wave is %3.2f K \
\nC)Mach number of flow pasmath.sing over wedge is %3.3f \
\nD)Wedge angle is %3.2f degree'%(Py,Ty,Mx,W)
A)Static pressure is 0.8725 bar 
B)Temperature behind the wave is 321.59 K 
C)Mach number of flow pasmath.sing over wedge is 1.286 
D)Wedge angle is 21.25 degree

Example 5.27 page : 48

In [1]:
import math 
from numpy import roots

				
#Input data
def1 = 15.
M1 = 2
k = 1.4

				
#Calculation
#Umath.sing relation def = math.radians(math.tan((((M1**2*math.sin(math.radians(2*sig))-(2/math.radians(math.tan((sig)))/(2+(M1**2*(k+math.cos(math.radians(2*sig))))) and converting into 6th degree polynomial of math.sin(math.radians(sig) = x
#C=((2*tand(def))+((M1^2)*k*tand(def))+((M1^2)*tand(def))) 
C = ((2*math.tan(math.radians(def1))) + ((M1**2)*k*math.tan(math.radians(def1))) + ((M1**2)*math.tan(math.radians(def1))))
#C = ((2*math.radians(math.tan((def1))+((M1**2)*k*math.radians(math.tan((def1))+((M1**2)*math.radians(math.tan((def1))) 				#Consmath.tant value for convenience
D = (2*M1**2*math.tan(math.radians(def1))) 				#Consmath.tant value for convenience
a = 4 				#Value of consmath.tant in polynomial  
b = 0 				#Coefficient of power 1 i.e. x**1
c = (4+C**2+(8*M1**2)) 				#Coefficient of power 2 i.e. x**2
d = 0 				#Coefficient of power 3 i.e. x**3
e = (4*(M1**4))+(2*C*D)+(8*M1**2) 				#Coefficient of power 4 i.e. x**4
f = 0 				#Coefficient of power 5 i.e. x**5
g = (4*M1**4)+D**2 				#Coefficient of power 6 i.e. x**6
#p4 = poly([a b -c -d e f -g],'x','c') 				#Expression for solving 6th degree polynomial
print ('Values for sine of wave angle are:')
print (roots([-g,f,e,-d,-c,b,a]))
sig1 = math.degrees(math.asin(0.9842)) 				#Strong shock wave angle in degree, nearer to 90 degree
sig2 = math.degrees(math.asin(0.7113)) 				#Weak shock wave angle in degree, nearer to 45 degree

#(a)Strong Shock Wave
Mx_1 = M1*math.sin(math.radians(sig1)) 				#Mach number before the shock of stong shock wave
My_1 = 0.584 				#Mach number after the shock from gas tables @Mx_1
p1 = 4.315 				#Static pressure ratio after and before the shock from gas tables @Mx_1
t1 = 1.656 				#Static temperature ratio after and before the shock from gas tables @Mx_1
d1 = p1/t1 				#Density ratio after and before the shock of stong shock wave
M2_1 = My_1/(math.sin(math.radians(sig1-def1))) 				#Exit mach number of stong shock wave
Mx_2 = M1*math.sin(math.radians(sig2)) 				#Mach number before the shock of weak shock wave
My_2 = 0.731 				#Mach number after the shock from gas tables @Mx_2
p2 = 2.186 				#Static pressure ratio after and before the shock from gas tables @Mx_2
t2 = 1.267 				#Static temperature ratio after and before the shock from gas tables @Mx_2
d2 = p2/t2 				#Density ratio after and before the shock of weak shock wave
M2_2 = My_2/(math.sin(math.radians(sig2-def1))) 				#Exit mach number of weak shock wave

				
#Output 
print 'Strong Shock Wave:    A)Wave angle is %3.1f degree    \
\nB)Pressure ratio is %3.3f    \
\nC)Density ratio is %3.3f    \
\nD)Temperature ratio is %3.3f    \
\nE)Downstream Mach number is %3.3f \
\nWeak Shock Wave:    A)Wave angle is %3.1f degree    \
\nB)Pressure ratio is %3.3f    \
\nC)Density ratio is %3.3f    \
\nD)Temperature ratio is %3.3f    \
\nE)Downstream Mach number is %3.3f'%(sig1,p1,d1,t1,M2_1,sig2,p2,d2,t2,M2_2)
Values for sine of wave angle are:
[ 0.98429339 -0.98429339  0.71133473 -0.71133473 -0.34489365  0.34489365]
Strong Shock Wave:    A)Wave angle is 79.8 degree    
B)Pressure ratio is 4.315    
C)Density ratio is 2.606    
D)Temperature ratio is 1.656    
E)Downstream Mach number is 0.645 
Weak Shock Wave:    A)Wave angle is 45.3 degree    
B)Pressure ratio is 2.186    
C)Density ratio is 1.725    
D)Temperature ratio is 1.267    
E)Downstream Mach number is 1.447

Example 5.28 page : 49

In [49]:
import math 
				
#Input data
k = 1.3 				#Adiabatic consmath.tant 
P1 = 0.345 				#Inlet pressure in bar
T1 = 350. 				#Inlet temperature in K
M1 = 1.5 				#Inlet mach number 
P2 = 0.138 				#Exit pressure in bar

				
#Calculation
p1 = 0.284 				#Pressure ratio at entry from gas tables @M1,k = 1.3
Po = P1/p1 				#Stagnation Pressure in bar
t1 = 0.748 				#Temperature ratio at entry from gas tables @M1,k = 1.3
To = T1/t1 				#Stagnation temperature in K
p2 = P2/Po 				#Pressure ratio
M2 = 2.08 				#Final Mach number from isentropic gas tables @p2
t2 = 0.606 				#Temperature ratio at exit from gas tables @M2,k = 1.3
T2 = To*t2 				#The temperature of the gas in K
w1 = 12.693 				#Prandtl Merger function at M1 
w2 = 31.12 				#Prandtl Merger function at M2
def1 = w2-w1 				#Deflection Angle in degree

				
#Output
print 'A)Deflection Angle is %3.3f degree \
\nB)Final Mach number is %3.2f \
\nC)The temperature of the gas is %3.3f K'%(def1,M2,T2)
A)Deflection Angle is 18.427 degree 
B)Final Mach number is 2.08 
C)The temperature of the gas is 283.556 K