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)
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)
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
k = 1.4 #Adiabatic consmath.tant
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 \
\nC)Heat added is %3.2f kJ/kg'%(ma,Tt,q)
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
k = 1.4 #Adiabatic consmath.tant
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)
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)
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
k = 1.3 #Adiabatic consmath.tant
#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)
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
k = 1.4 #Adiabatic consmath.tant
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)
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)
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
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
k = 1.4 #Adiabatic consmath.tant
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)
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)
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)
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)
import math
#Input data
k = 1.3 #Adiabatic consmath.tant
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.