In [1]:

```
# Given:-
T1 = 300.00 # The temperature at the beginning of the compression process in kelvin
p1 = 1.00 # the pressure at the beginning of the compression process in bar
r = 8.00 # compression ratio
V1 = 560.00 # the volume at the beginning of the compression process in cm^3
T3 = 2000.00 # maximum temperature during the cycle in kelvin
# Part(a)
# At T1 = 300k,table A-22 gives
u1 = 214.07 # in kj/kg
vr1 = 621.2
# Interpolating with vr2 in Table A-22, we get
T2 = 673.00 # in kelvin
u2 = 491.2 # in kj/kg
# At T3 = 2000 K, Table A-22 gives
u3 = 1678.7 # in kj/kg
vr3 = 2.776
# Interpolating in Table A-22 with vr4 gives
T4 = 1043 # in kelvin
u4 = 795.8 # in kj/kg
# Calculations
# For the isentropic compression Process 1–2
vr2 = vr1/r
# With the ideal gas equation of state
p2 = p1*(T2/T1)*(r) # in bars
# Since Process 2–3 occurs at constant volume, the ideal gas equation of state gives
p3 = p2*(T3/T2) # in bars
# For the isentropic expansion process 3–4
vr4 = vr3*(r)
# The ideal gas equation of state applied at states 1 and 4 gives
p4 = p1*(T4/T1) # in bars
# Results
print '-> At state1, the pressure is:',p1,'bar.'
print '-> At state1, the temperature is ',T1,'kelvin.'
print '-> At state2, the pressure is:',round(p2,3),'bar.'
print '-> At state2, the temperature is',T2,'kelvin.'
print '-> At state3, the pressure is:',round(p3,3),'bar.'
print '-> At state3, the temperature is',T3,'kelvin.'
print '-> At state4, the pressure is:',round(p4,4),'bar.'
print '-> At state4, the temperature is',T4,'kelvin.'
# Part(b)
eta = 1-(u4-u1)/(u3-u2) # thermal efficiency
# Result
print '-> The thermal efficiency is:',round(eta,2)
# Part(c)
R = 8.314 # universal gas constant, in SI units
M = 28.97 # molar mass of air in grams
# Calculations
m = ((p1*V1)/((R/M)*T1))*10**-6*10**5*10**-3 # mass of the air in kg
Wcycle = m*((u3-u4)-(u2-u1)) # the net work per cycle in KJ
mep = (Wcycle/(V1*(1-1/r)))*10**6*10**3*10**-5 # in bars
# Result
print '-> The mean effective pressure, is:',round(mep,4),'atm..'
```

In [2]:

```
# Given :-
r = 18.00 # compression ratio
T1 = 300.00 # temperature at the beginning of the compression process in kelvin
p1 = 0.1 # pressure at the beginning of the compression process in MPa
rc = 2.00 # cutoff ratio
# Part(a)
# With T1 = 300 K, Table A-22 gives
u1 = 214.07 # in kj/kg
vr1 = 621.2
# Interpolating in Table A-22, we get
T2 = 898.3 # in kelvin
h2 = 930.98 # in kj/kg
# From Table A-22,
h3 = 1999.1 # in kj/kg
vr3 = 3.97
# Interpolating in Table A-22 with vr4, we get
u4 = 664.3 # in kj/kg
T4 = 887.7 # in kelvin
# Calculations
# Since Process 2–3 occurs at constant pressure, the ideal gas equation of state gives
T3 = rc*T2 # in kelvin
# With the ideal gas equation of state
p2 = p1*(T2/T1)*(r) # in MPa
p3 = p2
# For the isentropic compression process 1–2
vr2 = vr1/r
# For the isentropic expansion process 3–4
vr4 = (r/rc)*vr3
# The ideal gas equation of state applied at states 1 and 4 gives
p4 = p1*(T4/T1) # in MPa
# Results
print '-> At state1, the pressure is:',round(p1,2),'bar.'
print '-> At state1, the temperature is',round(T1,2),'kelvin.'
print '-> At state2, the pressure in bar is:',round(p2,2),'bar.'
print '-> At state2, the temperature is ',round(T2,2),'kelvin.'
print '-> At state3, the pressure in bar is:',round(p3,2),'bar.'
print '-> At state3, the temperature is',round(T3,2),'kelvin.'
print '-> At state4, the pressure is:',round(p4,2),'bar.'
print '-> At state4, the temperature is',round(T4,2),'kelvin.'
# Part(b)
eta = 1- (u4-u1)/(h3-h2)
print '-> The thermal efficiency is:',round(eta,2)
# Part(c)
R = 8.314 # universal gas constant, in SI units
M = 28.97 # molar mass of air in grams
# Calculations
wcycle = (h3-h2)-(u4-u1) # The net work of the cycle in kj/kg
v1 = ((R/M)*T1/p1)/10**3 # The specific volume at state 1 in m^3/kg
mep = (wcycle/(v1*(1-1/r)))*10**3*10**-6 # in MPa
# Results
print '-> The mean effective pressure, is:',round(mep,2),'MPa.'
```

In [3]:

```
# Given :-
T1 = 300.00 # beginning temperature in kelvin
p1 = 0.1 # beginning pressure in MPa
r = 18.00 # compression ratio
pr = 1.5 # The pressure ratio for the constant volume part of the heating process
vr = 1.2 # The volume ratio for the constant pressure part of the heating process
# Analysis
# States 1 and 2 are the same as in Example 9.2, so
u1 = 214.07 # in kj/kg
T2 = 898.3 # in kelvin
u2 = 673.2 # in kj/kg
# Interpolating in Table A-22, we get
h3 = 1452.6 # in kj/kg
u3 = 1065.8 # in kj/kg
# From Table A-22,
h4 = 1778.3 # in kj/kg
vr4 = 5.609
# Interpolating in Table A-22, we get
u5 = 475.96 # in kj/kg
# Calculations
# Since Process 2–3 occurs at constant volume, the ideal gas equation of state reduces to give
T3 = pr*T2 # in kelvin
# Since Process 3–4 occurs at constant pressure, the ideal gas equation of state reduces to give
T4 = vr*T3 # in kelvin
# Process 4–5 is an isentropic expansion, so
vr5 = vr4*r/vr
# Part(a)
eta = 1-(u5-u1)/((u3-u2)+(h4-h3))
# Result
print '-> The thermal efficiency is:',round(eta,2)
# Part(b)
# The specific volume at state 1 is evaluated in Example 9.2 as
v1 = 0.861 # in m^3/kg
mep = (((u3-u2)+(h4-h3)-(u5-u1))/(v1*(1-1/r)))*10**3*10**-6 # in MPa
# Result
print '-> The mean effective pressure, is:',round(mep,2),'MPa.'
```

In [4]:

```
# Given:-
T1 = 300.00 # in kelvin
AV = 5.00 # volumetric flow rate in m^3/s
p1 = 100.00 # in kpa
pr = 10.00 # compressor pressure ratio
T3 = 1400.00 # turbine inlet temperature in kelvin
# Analysis
# At state 1, the temperature is 300 K. From Table A-22,
h1 = 300.19 # in kj/kg
pr1 = 1.386
# Interpolating in Table A-22,
h2 = 579.9 # in kj/kg
# From Table A-22
h3 = 1515.4 # in kj/kg
pr3 = 450.5
# Interpolating in Table A-22, we get
h4 = 808.5 # in kj/kg
# calculations
pr2 = pr*pr1
pr4 = pr3*1/pr
# Part(a)
eta = ((h3-h4)-(h2-h1))/(h3-h2) # thermal efficiency
# Result
print '-> The thermal efficiency is:',round(eta,4)
# Part(b)
bwr = (h2-h1)/(h3-h4) # back work ratio
# Result
print '-> The back work ratio is:',round(bwr,4)
# Part(c)
R = 8.314 # universal gas constant, in SI units
M = 28.97 # molar mass of air in grams
# Calculations
mdot = AV*p1/((R/M)*T1) # mass flow rate in kg/s
Wcycledot = mdot*((h3-h4)-(h2-h1)) # The net power developed
# Result
print '-> The net power developed, is:',round(Wcycledot,2),'kW .'
```

In [5]:

```
# Given:-
etat = 0.8 # turbine efficiency
etac = 0.8 # compressor efficiency
# Part(a)
wtdots = 706.9 # The value of wtdots is determined in the solution to Example 9.4 as 706.9 kJ/kg
wcdots = 279.7 # The value of wcdots is determined in the solution to Example 9.4 as 279.7 kJ/kg
h1 = 300.19 # h1 is from the solution to Example 9.4, in kj/kg
h3 = 1515.4 # h3 is from the solution to Example 9.4, in kj/kg
# Calculations
# The turbine work per unit of mass is
wtdot = etat*wtdots # in kj/kg
# For the compressor, the work per unit of mass is
wcdot = wcdots/etac # in kj/kg
h2 = h1 + wcdot # in kj/kg
qindot = h3-h2 # The heat transfer to the working fluid per unit of mass flow in kj/kg
eta = (wtdot-wcdot)/qindot # thermal efficiency
# Results
print '-> The thermal efficiency is:',round(eta,2)
# Part(b)
bwr = wcdot/wtdot # back work ratio
# Result
print '-> The back work ratio is:',round(bwr,2)
# Part(c)
mdot = 5.807 # in kg/s, from example 9.4
Wcycledot = mdot*(wtdot-wcdot) # The net power developed by the cycle in kw
# Result
print '-> The net power developed, is: ',round(Wcycledot,2),'kW.'
```

In [6]:

```
%matplotlib inline
```

In [7]:

```
# Given:-
# Part(a)
etareg = 0.8 # regenerator effectiveness of 80%.
# From example 9.4
h1 = 300.19 # in kj/kg
h2 = 579.9 # in kj/kg
h3 = 1515.4 # in kj/kg
h4 = 808.5 # in kj/kg
# Calculations
hx = etareg*(h4-h2)+h2 # in kj/kg
eta = ((h3-h4)- (h2-h1))/(h3-hx) # thermal efficiency
# Result
print '-> The thermal efficiency is: '
print round(eta,2)
# Part(b)
etareg = []
x = []
eta = []
from numpy import linspace
from pylab import plot, show , xlabel, ylabel
etareg = linspace(0,0.8,50)
for i in range (0,50):
x.append(i)
eta.append(i)
x[i] = (etareg[i]*(h4-h2))+h2
eta[i] = ((h3-h4)- (h2-h1))/(h3-x[i])
plot(etareg,eta)
xlabel('Regenerator effectiveness')
ylabel('Thermal efficiency')
show()
```

In [8]:

```
# Given:-
# Analysis
# States 1, 2, and 3 are the same as in Example 9.4:
h1 = 300.19 # in kj/kg
h2 = 579.9 # in kj/kg
h3 = 1515.4 # in kj/kg
# The temperature at state b is the same as at state 3, so
hb = h3
pa = 300.00 # in kpa
p3 = 1000.00 # in kpa
# From table A-22
pr3 = 450.5
# Interpolating in Table A-22, we get
ha = 1095.9 # in kj/kg
p4 = 100.00 # in kpa
pb = 300.00 # in kpa
# Interpolating in Table A-22, we obtain
h4 = 1127.6 # in kj/kg
# Calculions
pra = pr3*(pa/p3)
prb = pra
pr4 = prb*(p4/pb)
# Since the regenerator effectiveness is 100%,
hx = h4
eta = ((h3-ha)+(hb-h4)-(h2-h1))/((h3-hx)+(hb-ha)) # thermal efficiency
# Result
print '-> The thermal efficiency is:'
print round(eta,2)
```

In [9]:

```
# Given:-
T1 = 300.00 # in kelvin
p1 = 100.00 # in kpa
p2 = 1000.00 # in kpa
p3 = p2
pc = 300.00 # in kpa
pd = 300.00 # in kpa
Td = 300.00 # in kelvin
# Part(a)
# From table A-22
prd = 1.386
# Interpolating in Table A-22, we get
T2 = 422 # in kelvin
h2 = 423.8 # in kj/kg
# Calculations
pr2 = prd*(p2/pd)
# Result
print '-> The temperature at the exit of the second compressor stage is:',round(T2,2),'kelvin.'
# Part(b)
# From Table A-22 at T1 = 300
h1 = 300.19 # in kj/kg
# Since Td = T1,
hd = 300.19 # in kj/kg
# with pr data from Table A-22 together
pr1 = 1.386
# Interpolating in Table A-22, we obtain
hc = 411.3 # in kj/kg
# Calculations
prc = pr1*(pc/p1)
wcdot = (hc-h1)+(h2-hd) # The total compressor work per unit of mass in kj/kg
# Result
print '-> The total compressor work input per unit of mass flow is: ',round(wcdot,2),'kJ/kg'
# Part(c)
# Interpolating in Table A-22, we get
T3 = 574 # in kelvin
h3 = 579.9 # in kj/kg
# Calculations
pr3 = pr1*(p3/p1)
wcdot = h3-h1 # The work input for a single stage of compression in kj/kg
# Results
print '-> For a single stage of compression, the temperature at the exit state is: ',round(T3,2),'kelvin'
print '-> For a single stage of compression, the work input is: ',round(wcdot,2),'kJ.'
```

In [10]:

```
# Given:-
T1 = 300.00 # in kelvin
p1 = 100.00 # in kpa
mdot = 5.807 # in kg/s
p2 = 300.00 # in kpa
p3 = p2
p4 = 1000.00 # in kpa
p5 = p4
p6 = p4
T6 = 1400.00 # in kelvin
T8 = T6
p7 = 300.00 # in kpa
p8 = p7
etac = 0.8 # isentropic efficiency of compressor
etat = 0.8 # isentropic efficiency of turbine
etareg = 0.8 # regenerator effectiveness
# Analysis
# From example 9.9
h1 = 300.19 # in kj/kg
h3 = h1 # in kj/kg
h2s = 411.3 # in kj/kg
h4s = 423.8 # in kj/kg
# From example 9.8
h6 = 1515.4 # in kj/kg
h8 = h6
h7s = 1095.9 # in kj/kg
h9s = 1127.6 # in kj/kg
# Calculations
h4 = h3 + (h4s-h3)/etac # in kj/kg
h2 = h1 + (h2s-h1)/etac # in kj/kg
h9 = h8-etat*(h8-h9s) # in kj/kg
h7 = h6-etat*(h6-h7s) # in kj/kg
h5 = h4+etareg*(h9-h4) # in kj/kg
# Part(a)
# Calculations
wtdot = (h6-h7)+(h8-h9) # The total turbine work per unit of mass flow in kj/kg
wcdot = (h2-h1)+(h4-h3) # The total compressor work input per unit of mass flow in kj/kg
qindot = (h6-h5)+(h8-h7) # The total heat added per unit of mass flow in kj/kg
eta = (wtdot-wcdot)/qindot # thermal efficiency
# Result
print '-> The thermal efficiency is: '
print round(eta,2)
# Part(b)
bwr = wcdot/wtdot # back work ratio
# Result
print '-> The back work ratio is:'
print round(bwr,2)
# Part(c)
Wcycledot = mdot*(wtdot-wcdot) # net power developed in kw
# Result
print '-> The net power developed, is: ',round(Wcycledot,2),'kW.'
```

In [11]:

```
# Given:-
Ta = 240.00 # in kelvin
pa = 0.8 # in bar
Va = 278.00 # in m/s
PR = 8.00 # pressure ratio across the compressor
T3 = 1200.00 # in kelvin
p5 = 0.8 # in bar
# From table A-22
ha = 240.02 # in kj/kg
h1 = ha + ((Va**2)/2)*10**-3 # in kj/kg
# Interpolating in Table A-22 gives
pr1 = 1.070
pra = .6355
# Interpolating in Table A-22, we get
h2 = 505.5 # in kj/kg
# At state 3 the temperature is given as T3 = 1200 K. From Table A-22
h3 = 1277.79 # in kj/kg
# Interpolating in Table A-22 with h4, gives
pr4 = 116.8
# pr data from table A-22 gives
pr4 = 116.00
pr3 = 238.00
# From table A-22
h5 = 621.3 # in kj/kg
# The expansion through the nozzle is isentropic to
p5 = .8 # in bars
# Calculations
p1 = (pr1/pra)*pa # in bars
# With the help of assumption, 'The turbine work output equals the work required to drive the compressor.',
h4 = h3+h1-h2 # in kj/kg
p2 = PR*p1 # in bars
# Using assumption 'There is no pressure drop for flow through the combustor',
p3 = p2
p4 = p3*(pr4/pr3) # in bars
pr5 = pr4*(p5/p4)
V5 = ((2*(h4-h5)*10**3))**(0.5) # the velocity at the nozzle exit in m/s
# Results
print '-> The velocity at the nozzle exit in m/s is:'
print round(V5,2)
print '-> pa in bars = '
print round(pa,2)
print '-> p1 in bars = '
print round(p1,2)
print '-> p2 in bars = '
print round(p2,2)
print '-> p3 in bars = '
print round(p3,2)
print '-> p4 in bars = '
print round(p4,2)
print '-> p5 in bars = '
print round(p5,2)
```

In [12]:

```
# Given:-
Wnetdot = 45.00 # in MW
T1 = 300.00 # in kelvin
p1 = 100.00 # in kpa
etac = 0.84 # The isentropic efficiency of the compressor
T3 = 1400.00 # in kelvin
p2 = 1200.00 # in kpa
p3 = p2
etat = 0.88 # isentropic efficiency of the turbine
T5 = 400.00 # in kelvin
p4 = 100.00 # in kpa
p5 = p4
T7 = 400.00 # in degree celcius
p7 = 8.00 # in MPa
etatw =0.9 # isentropic efficiency of turbine of the vapor cycle
p8 = 8.00 # in kpa
p9 = p8
etap = 0.8 # isentropic efficiency of pump of the vapor cycle
T0 = 300.00 # in kelvin
p0 = 100.00 # -in kpa
# Analysis
# With procedure similar to that used in the examples of chapters 8 and 9,we can determine following property data
h1 = 300.19 # in kj/kg
h2 = 669.79 # in kj/kg
h3 = 1515.42 # in kj/kg
h4 = 858.02 # in kj/kg
h5 = 400.98 # in kj/kg
h6 = 183.96 # in kj/kg
h7 = 3138.30 # in kj/kg
h8 = 2104.74 # in kj/kg
h9 = 173.88 # in kj/kg
s1 = 1.7020 # in kj/kg.k
s2 = 2.5088 # in kj/kg.k
s3 = 3.3620 # in kj/kg.k
s4 = 2.7620 # in kj/kg.k
s5 = 1.9919 # in kj/kg.k
s6 = 0.5975 # in kj/kg.k
s7 = 6.3634 # in kj/kg.k
s8 = 6.7282 # in kj/kg.k
s9 = 0.5926 # in kj/kg.k
# Part(a)
# By applying mass and energy rate balances
# Calculations
mvdotbymgdot = (h4-h5)/(h7-h6) # ratio of mass flow rates of vapor and air
mgdot = (Wnetdot*10**3)/(((h3-h4)-(h2-h1)) + mvdotbymgdot*((h7-h8)-(h6-h9))) # mass flow rate of air in kg/s
mvdot = mvdotbymgdot*mgdot # mass flow rate of vapor in kg/s
Wgasdot = mgdot*((h3-h4)-(h2-h1))*10**-3 # net power developed by gas turbine in MW
Wvapdot = mvdot*((h7-h8)-(h6-h9))*10**-3 # net power developed by vapor cycle in MW
# Results
print '-> Mass flow rate of air is: ',round(mgdot,2),'kg/s.'
print '-> Mass flow rate of vapor is: ',round(mvdot,2),'kg/s.'
print '-> Net power developed by gas turbine is: ',round(Wgasdot,2),'MW.'
print '-> Net power developed by vapor cycle is: ',round(Wvapdot,2),'MW.'
# Part(b)
import math
# The net rate of exergy increase of the air passing through the combustor is
Edotf32 = mgdot*(h3-h2-T0*(s3-s2))*10**-3 # in MW
# The net rate exergy is carried out by the exhaust air stream at 5 is
Edotf51 = mgdot*(h5-h1-T0*(s5-s1))/10**3 # in MW
# The net rate exergy is carried out as the water passes through the condenser is
Edotf89 = mvdot*(h8-h9-T0*(s8-s9))*10**-3 # in MW
R = 8.314 # universal gas constant, in SI units
M = 28.97 # molar mass of air in grams
# The rate of exergy destruction for air turbine is
Eddott = mgdot*T0*(s4-s3-(R/M)*math.log(p4/p3))/10**3 # in MW
# The rate of exergy destruction for compressor is
Eddotc = mgdot*T0*(s2-s1-(R/M)*math.log(p2/p1))/10**3 # in MW
# The rate of exergy destruction for steam turbine is
Eddotst = mvdot*T0*(s8-s7)/10**3 # in MW
# The rate of exergy destruction for pump is
Eddotp = mvdot*T0*(s6-s9)/10**3 # in MW
# For heat exchanger
EddotHE = T0*(mgdot*(s5-s4)+mvdot*(s7-s6))/10**3 # in MW
# Results
print '-> Balance sheet'
print 'Net exergy increase of the gas passing'
print '-> Through the combustor: ',round(Edotf32,2),'MW'
print 'Disposition of the exergy:'
print '• Net power developed'
print 'gas turbine cycle ',round(Wgasdot,2),'MW'
print 'vapor cycle ',round(Wvapdot,2),'MW'
print '• Net exergy lost'
print 'with exhaust gas at state 5 ',round(Edotf51,2),'MW'
print 'from water passing through condenser ',round(Edotf89,2),'MW'
print '• Exergy destruction'
print 'air turbine ',round(Eddott,2),'MW'
print 'compressor ',round(Eddotc,2),'MW'
print 'steam turbine ',round(Eddotst,2),'MW'
print 'pump ',round(Eddotp,2),'MW'
print 'heat exchanger ',round(EddotHE,2),'MW'
```

In [13]:

```
# Given:-
Tnot = 360.00 # in kelvin
pnot = 1.00 # in MPa
A2 = 0.001 # in m^2
k = 1.4
# Calculations
pstarbypnot = (1+(k-1)/2)**(k/(1-k))
pstar = pstarbypnot*pnot
# Part(a)
# Since back pressure of 500 kpa is less than critical pressure pstar(528kpa in this case) found above, the nozzle is choked
# At the exit
M = 1.00
p2 = pstar # in MPa
T2 = Tnot/(1+((k-1)/2)*(M**2)) # exit temperature in kelvin
R = 8.314 # universal gas constant, in SI units
Mwt = 28.97 # molar mass of air in grams
V2 = ((k*(R/Mwt)*T2*10**3)**0.5) # exit velocity in m/s
mdot = (p2/((R/Mwt)*T2))*A2*V2*10**3 # mass flow rate in kg/s
# Results
print '-> The exit mach number for back pressure of 500kpa is: '
print round(M,2)
print '-> The mass flow rate in kg/s for back pressure of 500kpa is:'
print round(mdot,2)
# Part(b)
# Since the back pressure of 784kpa is greater than critical pressure of pstar determined above,the flow throughout the nozzle is subsonic and the exit pressure equals the back pressure,
p2 = 784.00 # exit pressure in kpa
# Calculations
M2 = (((2.00)/(k-1))*(((pnot*10**3)/p2)**((k-1)/k)-1))**0.5 # exit mach number
T2 = Tnot/(1+((k-1)/2)*(M2**2)) # exit temperature in kelvin
V2 = M2*((k*(R/Mwt)*10**3*T2)**0.5) # exit velocity in m/s
mdot2 = (p2/((R/Mwt)*T2))*A2*V2 # mass flow rate in kg/s
# Results
print '-> The mass flow rate at the exit for back pressure of 784kpa is: ',round(mdot2,2),'kg/s.'
print '-> The exit mach number for back pressure of 784 kpa is: '
print round(M2,2)
```

In [14]:

```
# Given:-
# Part(a)
Mt = 0.7 # mach mumber at the throat
At = 6.25 # throat area in cm^2
Ae = 15.00 # exit area in cm^2
# The flow throughout the nozzle, including the exit, is subsonic. Accordingly, with this value for A2byAstar, Table 9.1 gives
M2 = 0.24
# For M2 = 0.24,
T2byTnot = 0.988
p2bypnot = 0.959
k = 1.4
T0 = 280.00 # in kelvin
pnot = 6.8 # in bars
# Calculations
# With Mt = 0.7, Table 9.1 gives
AtbyAstar = 1.09437
A2byAstar = (Ae/At)*AtbyAstar
T2 = T2byTnot*T0 # in kelvin
p2 = p2bypnot*pnot # in bars
V2 = M2*((k*(8.314/28.97)*T2*10**3)**0.5) # velocity at the exit in m/s
mdot = (p2/((8.314/28.97)*T2))*Ae*V2*10**-2 # mass flow rate in kg/s
# Results
print '-> Part(a) the mass flow rate in kg/s is: '
print round(mdot,2)
print '-> The exit pressure in bars is: '
print round(p2,2)
print '-> The exit mach number is: '
print round(M2,2)
# Part(b)
Mt = 1.00 # mach number at the throat
# From table 9.1
M2 = 0.26
T2byTnot = 0.986
p2bypnot = 0.953
T0 = 280.00 # in kelvin
pnot = 6.8 # in bars
# Calculations
T2 = T2byTnot*T0 # in kelvin
p2 = p2bypnot*pnot # in bars
k = 1.4
V2 = M2*((k*(8314/28.97)*T2)**0.5) # exit velocity in m/s
mdot = (p2/((8.314/28.97)*T2))*Ae*V2*10**-2 # mass flow rate in kg/s
# Results
print '-> Part(b) the mass flow rate is: ',mdot,'kg/s.'
print '-> The exit pressure is: ',p2,'bars.'
print '-> The exit mach number is: ',M2
# Part(c)
# From part (b), the exit Mach number in the present part of the example is
M2 = 2.4
# Using this, Table 9.1 gives
p2bypnot = 0.0684
pnot = 6.8 # in bars
# Calculation
p2 = p2bypnot*pnot # in bars
# Results
# Since the nozzle is choked, the mass flow rate is the same as found in part (b).
print '> Part(c) the mass flow rate is: ',mdot,'kg/s.'
print '-> The exit pressure is: ',p2,'bars.'
print '-> The exit mach number is: ',M2
# Part(d)
# Since a normal shock stands at the exit and the flow upstream of the shock is isentropic, the Mach number Mx and the pressure px correspond to the values found in part (c),
Mx = 2.4
px = 0.465 # in bars
# Then, from Table 9.2
My = 0.52
#py is the exit pressure
pybypx = 6.5533
py = px*pybypx
# The pressure downstream of the shock is thus 3.047 bars. This is the exit pressure
# The mass flow is the same as found in part (b).
# Results
print '-> Part(d) the mass flow rate is: ',mdot,'kg/s.'
print '-> The exit pressure is: ',round(py,3),'bars.'
print '-> The exit mach number is: ',My
# Part(e)
# A shock stands in the diverging portion where the area is
Ax = 12.5 # in cm^2
# Since a shock occurs, the flow is sonic at the throat, so
Axstar = 6.25 # in cm^2
At = Axstar
# The Mach number Mx can then be found from Table 9.1, by using AxbyAxstar as
Mx = 2.2
# Results
# With Mx = 2.2, the ratio of stagnation pressures is obtained from Table 9.2 as
pnotybypnotx = 0.62812
# Using this ratio and noting that the flow is subsonic after the shock, Table 9.1 gives
M2 = 0.43
# For M2 = 0.43,
p2bypnoty = 0.88
# Calculations
A2byAystar = (Ae/Axstar)*pnotybypnotx
p2 = p2bypnoty*pnotybypnotx*pnot # in bars
# Results
# Since the flow is choked, the mass flow rate is the same as that found in part (b).
print '-> part(e) the mass flow rate is: ',mdot,'kg/s.'
print '-> the exit pressure is: ',p2,'bars.'
print '-> the exit mach number is: ',M2
```