# Chapter 4 : Flow through constant area ducts rayleigh flow¶

## Example 4.1 page : 9¶

In :
import math

#Input data
Pa = 1*10**5 				#Pressure of dry air in Pa
To1 = 288 				#Total stagnation temperature at inlet in K
M1 = 1 				#Mach number at inlet of pipe
M2 = 0.8 				#Mach number at exit o pipe
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K

#Calculation
t1 = 0.834 				#Temperature ratio at entry, i.e.entry static temperature to total temperature from gas tables at isentropic,M1 = 1 & adiabatic consmath.tant = 1.4
T1 = t1*To1 				#Static temperature at entry in Kelvin
t2 = 0.964 				#Temperature ratio at critical state, i.e. exit stagnation temperature to critical state temperature from gas tables at Rayleigh, M2 = 0.8 & adiabatic consmath.tant = 1.4
To2 = t2*To1 				#Total stagnation temperature at exit in K
t3 = 1.025 				#Temperature ratio at exit, i.e. exit static temperature to total temperature from gas tables at isentropic,M1 = 1 & adiabatic consmath.tant = 1.4
T2 = t3*T1 				#Static temperature at exit in Kelvin
q = Cp*(To1-To2) 				#The heat transferred per unit mass flow in kJ/kg
dT = To1-T2 				#Change in temperature in K

#Output
print 'A)The heat transferred per unit mass flow is %3.3f kJ/kg rejected \
\nB)Change in temperature is %3.3f K'%(q,dT)

A)The heat transferred per unit mass flow is 10.420 kJ/kg rejected
B)Change in temperature is 41.803 K


## Example 4.2 page : 10¶

In :
import math

#Input data
M1 = 3. 				#Mach number at entry
P1 = 1. 				#Static Pressure at entry in atm
T1 = 300. 				#Static Temperature at entry in K
q = 300. 				#The heat transferred per unit mass flow in kJ/kg
R = 287. 				#Gas consmath.tant in J/kg-K
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K

#Calculation
t1 = 2.8 				#Temperature ratio at entry from gas tables (M = 3,k = 1.4,isentropinC)
To1 = t1*T1 				#Total stagnation temperature at inlet in K
p1 = 0.0272 				#Pressure ratio  at entry from gas tables (M = 3,k = 1.4,isentropiC)
Po1 = P1/p1 				#Stagnation Pressure at entry in atm
p2 = 0.176 				#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.4,M = 3)
Pt = P1/p2 				#Static critical pressure in atm
p3 = 3.424 				#Stagnation Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)
Pot = Po1/p3 				#Stagnation critical pressure in atm
t2 = 0.281 				#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)
Tt = T1/t2 				#Static critical temperature in K
t3 = 0.654 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)
Tot = To1/t3 				#Stagnation critical temperature in K
To2 = (q/Cp)+To1 				#Stagnation exit temperation in K
t4 = (To2/Tot) 				#Stagnation Temperature ratio at exit
M2 = 1.6 				#Mack number at exit from gas tables (Rayleigh,t4)
p4 = 0.524 				#Static Pressure ratio  at exit from gas tables (Rayleigh,t4 = 0.866,M = 1.6)
P2 = p4*Pt 				#Static Pressure at exit in atm
p5 = 1.176 				#Stagnation Pressure ratio at exit from gas tables (Rayleigh,t4 = 0.866,M = 1.6)
Po2 = p5*Pot 				#Stagnation Pressure at exit in atm
t5 = 0.702 				#Static temperature ratio at exit from gas tables (Rayleigh,t4 = 0.866,M = 1.6)
T2 = t5*Tt 				#Static exit temperature in K
d2 = P2*101325/(R*T2) 				#density of air at exit in kg/m**3, P2 in N/m**2

#outpur
print 'A)The Mach numer at exit is %3.1f \
\nB)Static Pressure at exit is %3.3f atm \
\nC)Static exit temperature is %3.2f K \
\nD)density of air at exit is %3.4f kg/m**3 \
\nE)Stagnation exit temperation is %3.2f K \
\nF)Stagnation Pressure at exit is %3.2f atm'%(M2,P2,T2,d2,To2,Po2)

A)The Mach numer at exit is 1.6
B)Static Pressure at exit is 2.977 atm
C)Static exit temperature is 749.47 K
D)density of air at exit is 1.4025 kg/m**3
E)Stagnation exit temperation is 1138.51 K
F)Stagnation Pressure at exit is 12.63 atm


## Example 4.3 page : 11¶

In :
import math

#Input data
M1 = 2 				#Mach number at entry
P1 = 1.4 				#Static Pressure at entry in bar
T1 = 323 				#Static Temperature at entry in K
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K
R = 287 				#Gas consmath.tant in J/kg-K

#Calculation
t1 = 0.555 				#Temperature ratio at entry from gas tables (M = 2,k = 1.4,isentropiC)
To1 = T1/t1 				#Total stagnation temperature at inlet in K
p1 = 0.364 				#Pressure ratio  at entry from gas tables (M = 2,k = 1.4,isentropiC)
Po1 = P1/p1 				#Stagnation Pressure at entry in bar
t2 = 0.529 				#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)
Tt = T1/t2 				#Static critical temperature in K
t3 = 0.793 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)
Tot = To1/t3 				#Stagnation critical temperature in K
To2 = Tot 				#Stagnation exit temperation in K
q = Cp*(To2-To1) 				#The heat transferred per unit mass flow in kJ/kg
a1 = math.sqrt(k*R*T1) 				#Sound velocity in m/s
C1 = M1*a1 				#Air velocity in m/s
d1 = (P1*10**5)/(R*T1) 				#density of air in kg/m**3
ma = d1*C1 				#Mass flow rate per unit area in kg/s-m**3

#Output
print 'A)Mass flow rate per unit area is %3.2f kg/s-m**2 \
\nB)Final temperarure is %3.3f K \

A)Mass flow rate per unit area is 1088.13 kg/s-m**2
B)Final temperarure is 610.586 K


## Example 4.4 page : 11¶

In :
import math

#Input data
C1 = 100. 				#Air velocity into combustion chamber in m/s
P1 = 3. 				#Static Pressure at entry in bar
T1 = 318. 				#Static Temperature at entry in K
q = 630. 				#The heat transferred per unit mass flow in kJ/kg
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K
R = 287. 				#Gas consmath.tant in J/kg-K

#Calculation
a1 = math.sqrt(k*R*T1) 				#Sound velocity in m/s
M1 = C1/a1 				#Mach number at entry
t1 = 0.985 				#Temperature ratio at entry from gas tables (M1,k = 1.4,isentropiC)
To1 = T1/t1 				#Total stagnation temperature at inlet in K
p1 = 0.947 				#Pressure ratio  at entry from gas tables (M1,k = 1.4,isentropiC)
Po1 = P1/p1 				#Stagnation Pressure at entry in bar
To2 = (q/Cp)+To1 				#Stagnation exit temperation in K
p2 = 2.163 				#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.4,M = 0.28)
Pt = P1/p2 				#Static critical pressure in bar
p3 = 2.206 				#Stagnation Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.28)
Pot = Po1/p3 				#Stagnation critical pressure in bar
t2 = 0.310 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.28)
Tot = To1/t2 				#Stagnation critical temperature in K
t3 = (To2/Tot) 				#Stagnation Temperature ratio at exit
M2 = 0.7 				#Mack number at exit from gas tables (Rayleigh,t3)
p4 = 1.423 				#Static Pressure ratio  at exit from gas tables (Rayleigh,t3,M2)
P2 = p4*Pt 				#Static Pressure at exit in bar

#Output
print 'A)Pressure after combustion is %3.3f bar \
\nB)Mach number after combustion is %3.1f'%(P2,M2)

A)Pressure after combustion is 1.974 bar
B)Mach number after combustion is 0.7


## Example 4.5 page : 12¶

In :
import math

#Input data
M1 = 3. 				#Mach number at entry
To1 = 295. 				#Total stagnation temperature at inlet in K
P1 = 0.5 				#Static Pressure at entry in bar
M2 = 1.5 				#Mack number at exit
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K
R = 287. 				#Gas consmath.tant in J/kg-K

#Calculation
p1 = 0.0272 				#Pressure ratio  at entry from gas tables (M = 3,k = 1.4,isentropiC)
Po1 = P1/p1 				#Stagnation Pressure at entry in bar
t1 = 0.357 				#Temperature ratio at entry from gas tables (M = 3,k = 1.4,isentropiC)
T1 = t1*To1 				#Static temperature at entry in Kelvin
p2 = 0.176 				#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.4,M = 3)
Pt = P1/p2 				#Static critical pressure in bar
p3 = 3.424 				#Stagnation Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)
Pot = Po1/p3 				#Stagnation critical pressure in bar
t2 = 0.654 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)
Tot = To1/t2 				#Stagnation critical temperature in K
t3 = 0.280 				#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)
Tt = T1/t3 				#Static critical temperature in K
p4 = 0.578 				#				#Static Pressure ratio  at exit from gas tables (Rayleigh,M = 1.5)
P2 = p4*Pt 				#Static Pressure at exit in bar
p5 = 1.122 				#Stagnation Pressure ratio at exit from gas tables (Rayleigh,M = 1.5)
Po2 = p5*Pot 				#Stagnation Pressure at exit in bar
t4 = 0.753 				#				#Static temperature ratio at exit from gas tables (Rayleigh,M = 1.5)
T2 = t4*Tt 				#Static exit temperature in K
t5 = 0.909 				#Stagnation temperature ratio at exit from gas tables (Rayleigh,M = 1.5)
To2 = t5*Tot 				#Total stagnation temperature at exit in K
q = Cp*(To1-To2) 				#The heat transferred per unit mass flow in kJ/kg
SPC = Po1-Po2 				#Change in stagnation pressure in bar
n = math.log(Po1/Po2)/(math.log(Po1/Po2)-math.log(To1/To2)) 				#Exponent of polytropic equation
qmax = Cp*(Tot-To1) 				#Maximum possible heat transfer in kJ/kg
ds = Cp*math.log(T2/T1)-(R*math.log(P2/P1)) 				#Change in entropy in kJ/kg-K

#Output
print 'A)Total temperature at exit is %3.2f K \
\nB)Static pressure at exit is %3.3f bar  \
\nC)Change in stagnation pressure is %3.2f bar \
\nD)Exponent of polytropic equation is %3.2f'%(To2,P2,SPC,n)

A)Total temperature at exit is 410.02 K
B)Static pressure at exit is 1.642 bar
C)Change in stagnation pressure is 12.36 bar
D)Exponent of polytropic equation is 0.77


## Example 4.6 page : 14¶

In :
import math

#Input data
M2 = 0.9 				#Mack number at exit
P2 = 2.5 				#Static Pressure at exit in bar
T2 = 1273. 				#Static exit temperature in K
t1 = 3.74 				#ratio of stagnation temperatures at and exit entry
Cp = 1.218 				#Specific heat of dry air in kJ/kg-K

#Calculation
t2 = 0.892 				#Temperauture ratio at exit from gas tables (isentropic,k = 1.3,M = 0.9)
To2 = T2/t2 				#Total stagnation temperature at exit in K
To1 = To2/t1 				#Total stagnation temperature at inlet in K
p1 = 1.12 				#Static pressure ratio at critical state from gas tables (Rayleigh,k = 1.3,M = 1.5)
Pt = P2/p1 				#Static critical pressure in bar
t3 = 1.017 				#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.3,M = 1.5)
Tt = T2/t3 				#Static critical temperature in K
t4 = 0.991 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.3,M = 1.5)
Tot = To2/t4 				#Stagnation critical temperature in K
t5 = To1/Tot 				#Ratio of stagnation temperature at entry and critical state
M1 = 0.26 				#Mach number at entry from gas tables (Rayleigh,t5,k = 1.3)
p2 = 2.114 				#Static Pressure ratio  at entry from gas tables (Rayleigh,t5,k = 1.3)
P1 = Pt*p2 				#Static Pressure at entry in bar
t6 = 0.302 				#Static temperature ratio  at entry from gas tables (Rayleigh,t5,k = 1.3)
T1 = Tt*t6 				#Static temperature at entry in Kelvin
q = Cp*(To2-To1) 				#The heat transferred per unit mass flow in kJ/kg
qmax = Cp*(Tot-To1) 				#Maximum possible heat transfer in kJ/kg

#Output
print 'A)Mach number at entry is %3.2f \
\nB)Pressure at entry is %3.3f bar  \
\nC)Temperature of gas is %3i K \
\nD)Amount of heat added is %3.2f kJ/kg \
\nE)Maximum heat that can be heated is %3.3f kJ/kg'%(M1,P1,T1,q,qmax)

A)Mach number at entry is 0.26
B)Pressure at entry is 4.719 bar
C)Temperature of gas is 378 K
D)Amount of heat added is 1273.47 kJ/kg
E)Maximum heat that can be heated is 1289.259 kJ/kg


## Example 4.7 page : 15¶

In :
import math

#input
P1 = 0.343 				#Static Pressure at entry in bar
T1 = 310. 				#Static temperature at entry in Kelvin
C1 = 60. 				#Velocity at entrance in m/s
q = 1172.5 				#The heat transferred per unit mass flow in kJ/kg
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K
R = 287. 				#Gas consmath.tant in J/kg-K

#Calculation
a1 = math.sqrt(k*R*T1) 				#Sound velocity in m/s
M1 = C1/a1 				#Mach number at entry
t1 = 0.9943 				#Temperature ratio at entry from gas tables (M = 0.17,k = 1.4,isentropic)
To1 = T1/t1 				#Total stagnation temperature at inlet in K
p1 = 2.306 				#Static Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.17)
Pt = P1/p1 				#Static critical pressure in bar
t2 = 0.154 				#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.17)
Tt = T1/t2 				#Static critical temperature in K
t3 = 0.129 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.17)
Tot = To1/t3 				#Stagnation critical temperature in K
c1 = 0.0665 				#Velocity ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.17)
Ct = C1/c1 				#Critical velocity in m/s
To2 = (q/Cp)+To1 				#Stagnation exit temperation in K
t4 = To2/Tot 				#Ratio of stagnation temperature at exit and critical state
M2 = 0.45 				#Mach number at exit from gas tables (Rayleigh,t4,k = 1.4)
p2 = 1.87 				#Static Pressure ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)
P2 = p2*Pt 				#Static Pressure at exit in bar
t5 = 0.7075 				#Static temperature ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)
T2 = t5*Tt 				#Static exit temperature in K
c2 = 0.378 				#Velocity ratio at critical state from gas tables (Rayleigh,k = 1.4,t4)
C2 = Ct*c2 				#exit velocity in m/s

#Output
print 'At exit conditions : A)Mach number is %3.2f \
\nB)Pressure is %3.3f bar \
\nC)Temperature is %3.2f K \
\nD)Exit velocity is %3.2f m/s'%(M2,P2,T2,C2)

At exit conditions : A)Mach number is 0.45
B)Pressure is 0.278 bar
C)Temperature is 1424.19 K
D)Exit velocity is 341.05 m/s


## Example 4.8 page : 16¶

In :
import math

#Input data
M1 = 2. 				#Mach number at entry
To1 = 523. 				#Total stagnation temperature at inlet in K
Po1 = 6. 				#Stagnation Pressure at entry in bar
To2 = 423. 				#Stagnation exit temperation in K

#Calculation
t1 = 0.555 				#Temperature ratio at entry from gas tables (M = 2,k = 1.4,isentropiC)
T1 = t1*To1 				#Static temperature at entry in Kelvin
p1 = 0.128 				#Pressure ratio  at entry from gas tables (M = 2,k = 1.4,isentropiC)
P1 = Po1*p1 				#Static Pressure at entry in bar
p2 = 0.364 				#Static pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)
p3 = 1.503 				#				#Stagnation pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2), printing mistake in textbook
t2 = 0.529 				#Static Temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)
t3 = 0.793 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)
t4 = (To2/To1)*t3 				#Ratio of stagnation temperature at exit and critical state
M2 = 3.15 				#Mach number at exit from gas tables (Rayleigh,t4,k = 1.4)
p4 = 0.161 				#Static Pressure ratio  at exit from gas tables (Rayleigh,t4,k = 1.4), printing mistake in textbook
t5 = 0.258 				#Static temperature ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)
P2 = (p4/p2)*P1 				#Static Pressure at exit in bar
T2 = (t5/t2)*T1 				#Static exit temperature in K

#Output
print 'After Cooling : A)Mach number is %3.2f \
\nB)Pressure is %3.4f bar \
\nC)Temperature is %3.2f K'%(M2,P2,T2)

After Cooling : A)Mach number is 3.15
B)Pressure is 0.3397 bar
C)Temperature is 141.57 K


## Example 4.9 page : 17¶

In :
import math

#Input data
M2 = 0.8 				#Mack number at exit
t1 = 4. 				#Ratio of stagnation temperature at exit and entry
T1 = 288. 				#Atmospheric temperature in K
P1 = 1. 				#Atmospheric Pressure in atm
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K

#Calculation
t2 = 0.964 				#Ratio of stagnation temperature at exit and critical state from gas tables
t3 = t2/t1 				#Ratio of stagnation temperature at entry and critical state
M1 = 0.24 				#				#Mach number at entry from gas tables (Rayleigh,t3,k = 1.4)
t5 = 0.988 				#Temperature ratio at entry from gas tables (M1,k = 1.4,isentropiC)
To1 = T1/t5 				#Total stagnation temperature at inlet in K
To2 = t1*To1 				#Stagnation exit temperation in K
Tot = To1/t3 				#Stagnation critical temperature in K
q = Cp*(To2-To1) 				#The heat transferred per unit mass flow in kJ/kg
qmax = Cp*(Tot-To1) 				#Maximum possible heat transfer in kJ/kg
t6 = 0.9775 				#Ratio of stagnation temperature for maximum static temperature (M = 1/math.sqrt(k),Rayleigh)
To3 = Tot*t6 				#maximum stagnation temperature in K
q_req = Cp*(To3-To1) 				#Heat transfer required to get maximum static temperature in kJ/kg

#Output
print 'A)Heat added per kg of air flow is %3.2f kJ/kg \
\nB)Maximum possible heat transfer is %3.2f kJ/kg \
\nC)Heat transfer required to get maximum static temperature is %3.1f kJ/kg'%(q,qmax,q_req)

# note : rounding off error

A)Heat added per kg of air flow is 878.87 kJ/kg
B)Maximum possible heat transfer is 922.63 kJ/kg
C)Heat transfer required to get maximum static temperature is 895.3 kJ/kg


## Example 4.10 page : 17¶

In :
import math

#Input data
T1 = 560. 				#Static Temperature at entry in K
P1 = 0.6 				#Static Pressure at entry in bar
C1 = 75. 				#Air velocity into combustion chamber in m/s
mp = 30. 				#air fuel ratio
CV = 92000. 				#Calorific value of fuel in kJ/kg
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K
R = 287. 				#Gas consmath.tant in J/kg-K

#Calculation
a1 = math.sqrt(k*R*T1) 				#Sound velocity in m/s
M1 = C1/a1 				#Mach number at entry
t1 = 0.9949 				#Temperature ratio at entry from gas tables (M1,k = 1.4,isentropiC)
To1 = T1/t1 				#Total stagnation temperature at inlet in K
p1 = 0.982 				#Pressure ratio  at entry from gas tables (M1,k = 1.4,isentropiC)
Po1 = P1/p1 				#Stagnation Pressure at entry in bar
q = CV/(mp+1) 				#The heat transferred per unit mass flow in kJ/kg of gas, mp+1 = total amount of fuel = mf+ma
p2 = 2.317 				#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.4,M1)
Pt = P1/p2 				#Static critical pressure in bar
p3 = 1.246 				#Stagnation Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)
Pot = Po1/p3 				#Stagnation critical pressure in bar
t2 = 0.137 				#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)
Tt = T1/t2 				#Static critical temperature in K
t3 = 0.115 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)
Tot = To1/t3 				#Stagnation critical temperature in K
To2 = (q/Cp)+To1 				#Stagnation exit temperation in K
t4 = To2/Tot 				#Ratio of stagnation temperature at exit and critical state
M2 = 0.33 				#Mach number at exit from gas tables (Rayleigh,t4,k = 1.4)
p4 = 2.0825 				#Static Pressure ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)
P2 = p4*Pt 				#Static Pressure at exit in bar, miscalculation in textbook
p5 = 1.186 				#Stagnation Pressure ratio at exit from gas tables (Rayleigh,t4,k = 1.4)
Po2 = Pot*p5 				#Stagnation Pressure at exit in bar
t5 = 0.472 				#Static temperature ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)
T2 = t5*Tt 				#Static exit temperature in K
C2 = M2*math.sqrt(k*R*T2) 				#exit velocity in m/s
SPL = ((Po1-Po2)/Po1)*100 				#Percentage of pressure loss in combustion chamber in %

#Output
print 'A)At exit:    \
\nPressure is %3.5f bar     \
\nTemperature is %3i K     \
\nVelocity is %3.2f m/s     \
\nMach number is %3.2f  \
\nB)Maximum stagnation temperature available is %3.2f K \
\nC)Percentage of pressure loss in combustion chamber is %3.1f percent \
\nD)Intial Mach number is %3.2f '%(P2,T2,C2,M2,Tot,SPL,M1)

A)At exit:
Pressure is 0.53927 bar
Temperature is 1929 K
Velocity is 290.55 m/s
Mach number is 0.33
B)Maximum stagnation temperature available is 4894.53 K
C)Percentage of pressure loss in combustion chamber is 4.8 percent
D)Intial Mach number is 0.16


## Example 4.11 page : 19¶

In :
import math

#Input data
To1 = 473. 				#Total stagnation temperature at inlet in K
To2 = 673. 				#Stagnation exit temperation in K
M1 = 0.5 				#Mach number at entry

#Calculation
t1 = 0.6914 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)
p1 = 1.7778 				#Static pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)
t2 = (To2/To1)*t1 				#Stagnation temperature ratio at exit
M2 = 0.867 				#Mach number at exit from gas tables (Rayleigh,t2,k = 1.4)
p2 = 1.16 				#Static pressure ratio at exit from gas tables (Rayleigh,k = 1.4,M2)
p = p2/p1 				#ratio of static pressures at oulet and inlet
PL = (1-p)*100 				#pressure loss in %

#Output
print 'A)Mach number is %3.3f \
\nB)Percentage drop in pressure is %3.1f percent'%(M2,PL)

A)Mach number is 0.867
B)Percentage drop in pressure is 34.8 percent


## Example 4.12 page : 19¶

In :
import math

#Input data
t1 = 3. 				#Stagnation temperature ratio
M2 = 0.8 				#Mach number at exit

#Calculation
t2 = 0.964 				#Ratio of stagnation temperature at exit and critical state (Rayleigh,M2,k = 1.4)
p1 = 1.266 				#Static Pressure ratio  at exit from gas tables (Rayleigh,M2,k = 1.4)
t3 = t2/t1 				#Stagnation temperature ratio at critical state
M1 = 0.29 				#Mach number at entry from gas tables (Rayleigh,t3,k = 1.4)
p2 = 2.147 				#Static pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)
p = p1/p2 				#ratio of static pressures at exit and entry
PL = (1-p)*100 				#Percentage loss in static pressure in %

#Output
print 'A)Mach number at entry is %3.2f \
\nB)Percentage loss in static pressure is %3i percent'%(M1,PL)

A)Mach number at entry is 0.29
B)Percentage loss in static pressure is  41 percent


## Example 4.13 page : 20¶

In :
import math

#Input data
To1 = 300. 				#Total stagnation temperature at inlet in K
To2 = 310. 				#Stagnation exit temperation in K
G = 1300. 				#Mass velocity in kg/m**2-s
P1 = 105.*10**3 				#Static Pressure at entry in Pa
Cp = 1.005 				#Specific heat of dry air in kJ/kg-K
R = 287. 				#Gas consmath.tant in J/kg-K

#Calculation
T1 = (((-2*P1**2*Cp)+math.sqrt(((-2*P1**2*Cp)**2)+(8*G**2*R**2*P1**2*Cp*To1)))/(2*G**2*R**2)) 				#Static temperature in K
t1 = T1/To1 				#Temperature ratio at entry
M1 = 1.4 				#Mach number at entry from gas tables (isentropic,t1,k = 1.4)
t2 = 0.934 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)
Tot = To1/t2 				#Stagnation critical temperature in K
t3 = To2/Tot 				#Stagnation temperature ratio at exit from gas tables (Rayleigh,k = 1.4,M1)
M2 = 1.26 				#Mach number at exit from gas tables (Rayleigh,t3,k = 1.4)

#Output
print 'A)The inlet mach number is %3.2f  \
\nB)The exit mach number is %3.2f'%(M1,M2)

A)The inlet mach number is 1.40
B)The exit mach number is 1.26


## Example 4.14 page : 21¶

In :
import math

#Input data
R = 466. 				#Gas consmath.tant in J/kg-K
P1 = 0.345 				#Static Pressure at entry in Pa
T1 = 312. 				#Static Temperature at entry in K
C1 = 65.5 				#Entry velocity in m/s
q = 4592. 				#The heat transferred per unit mass flow in kJ/kg

#Calculation
a1 = math.sqrt(k*R*T1) 				#Sound velocity in m/s
M1 = C1/a1 				#Mach number at entry
t1 = 0.9965 				#Temperature ratio at entry from gas tables (M1,k = 1.3,isentropiC)
To1 = T1/t1 				#Total stagnation temperature at inlet in K
p1 = 2.235 				#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.3,M1)
Pt = P1/p1 				#Static critical pressure in bar
c1 = 0.051 				#Velocity ratio at critical state from gas tables (Rayleigh,k = 1.3,M1)
Ct = C1/c1 				#Critical velocity in m/s
t2 = 0.112 				#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.3,M1)
Tt = T1/t2 				#Static critical temperature in K
t3 = 0.098 				#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.3,M1)
Tot = To1/t3 				#Stagnation critical temperature in K
Cp = (k*R)/(k-1) 				#Specific heat of dry air in kJ/kg-K
To2 = (q/Cp)+To1 				#Stagnation exit temperation in K
t4 = (To2/Tot) 				#Stagnation Temperature ratio at exit
M2 = 0.60 				#Mack number at exit from gas tables (Rayleigh,t4)
p2 = 1.567 				#Static Pressure ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)
P2 = p2*Pt 				#Static Pressure at exit in bar
t5 = 0.884 				#Static temperature ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)
T2 = t5*Tt 				#Static exit temperature in K
c2 = 0.564 				#Velocity ratio at critical state from gas tables (Rayleigh,k = 1.4,t4)
C2 = Ct*c2 				#exit velocity in m/s
qmax = Cp*(Tot-To1)/10**3 				#Maximum possible heat transfer in kJ/kg

#Output
print 'A)Heat required to accelerate the gas from the inlet condition to sonic condition is %3.2f kJ/kg \
\nB)The pressure and temperature at sonic condition are %3.3f bar and %3.2f K respectively \
\nC)The properties at exit are:    \
\nPressure is %3.3f bar    \
\nTemperature is %3.2f K    \
\nVelocity is %3i m/s'%(qmax,Pt,Tt,P2,T2,C2)

# note : rounding off error.

A)Heat required to accelerate the gas from the inlet condition to sonic condition is 5819.23 kJ/kg
B)The pressure and temperature at sonic condition are 0.154 bar and 2785.71 K respectively
C)The properties at exit are:
Pressure is 0.242 bar
Temperature is 2462.57 K
Velocity is 724 m/s