# Example 5.1.py
# Consider the subsonic-supersonic flow through a convergent-divergent nozzle. The
# reservoir pressure and temperature are 10 atm and 300 K, repectively. There are
# two locations in the nozzle where A/Astar = 6, one in the convergent section and
# the other in the divergent section. At each location calculate M, p, T, u.
# Variable declaration
po = 10.0 # reservoir pressure (in atm)
To = 300.0 # reservoir temperature (in K)
A_by_Astar = 6.0 # area ratio
gamma = 1.4 # ratio of specific heat
R = 287.0 # gas constant (in J/ Kg K)
# Calculations
# from table A1 for subsonic flow with A/Astar = 6.0
Msub = 0.097 # mach number in converging section
po_by_p = 1.006 # po/p in converging section
To_by_T = 1.002 # To/T in converging section
psub = 1 / po_by_p * po # pressure (in atm) in converging section
Tsub = 1 / To_by_T * To # temperature (in K) in converging section
asub = pow(gamma*R*Tsub, 0.5) # speed of sound (in m/s) in converging section
usub = Msub*asub # velocity (in m/s) in converging section
# from table A1 for supersonic flow with A/Astar = 6.0
Msup = 3.368 # mach number in diverging section
po_by_p = 63.13 # po/p in diverging section
To_by_T = 3.269 # To/T in diverging section
psup = 1 / po_by_p * po # pressure (in atm) in diverging section
Tsup = 1 / To_by_T * To # temperature (in K) in diverging section
asup = pow(gamma*R*Tsup, 0.5) # speed of sound (in m/s) in diverging section
usup = Msup*asup # velocity (in m/s) in diverging section
# Results
print "Converging section"
print "M = %.3f" %(Msub)
print "p = %.2f atm" %(psub)
print "T = %.1f K" %(Tsub)
print "u = %.2f m/s" %(usub)
print "Divering section"
print "M = %.3f" %(Msup)
print "p = %.4f atm" %(psup)
print "T = %.2f K" %(Tsup)
print "u = %.2f m/s" %(usup)
# Example 5.2.py
# A supersonic wind tunnel is designed to produce Mach 2.5 flow in the test section
# with standard sea level conditions. Calculate the exit area ratio and reservoir
# conditions necessary to achieve these design conditions.
# Variable declaration
Me = 2.5 # exit mach number
pe = 1.0 # sea level pressure (in atm)
Te = 288.0 # sea level temperature (in K)
# Calculations
# from table A1 for Me = 2.5
Ae_by_Astar = 2.637 # Ae/Astar
po_by_pe = 17.09 # po/p
To_by_Te = 2.25 # To/T
po = po_by_pe * pe # reservoir pressure (in atm)
To = To_by_Te * Te # reservoir temperature (in K)
# Results
print "Area ratio required %.3f" %(Ae_by_Astar)
print "Reservoir pressure required %.2f atm" %(po)
print "Reservoir temperature required %.1f K" %(To)
# Example 5.3.py
# Consider a rocket engine burning hydrogen and oxygen; combustion chamber temper-
# ature and pressure are 3571 K and 25 atm, respectively. The molecular weight of
# the chemically reacting gas in the combustion chamber is 16.0 and gamma = 1.22.
# The pressure at the exit of the convergent-divergent rocket nozzle is 1.174*10^-2
# atm. The area of the throat is 0.4 m^2. Assuming a calorifically perfect gas,
# calculate (a) the exit mach number (b) the exit velocity (c) the mass through the
# nozzle and (d) the area of the exit.
# Variable declaration
po = 25.0 # combustion chamber pressure (in atm)
To = 3571.0 # combustion chamber temperature (in K)
pe = 1.174e-2 # pressure at the exit of the nozzle (in atm)
Astar = 0.4 # throat area (in m^2)
gamma = 1.22 # ratio of specific heats
mol_wt = 16.0 # molecular weight (in gms)
# Calculations
# part (a)
Me = pow(2/(gamma-1) *(pow(po/pe,(gamma-1)/gamma) - 1), 0.5) # Exit mach number
# part (b)
Te_by_To = pow(pe/po, (gamma-1)/gamma) # Te/To
Te = Te_by_To * To # exit temperature (in K)
R = 8314.0/mol_wt # gas constant (in J/Kg K)
ae = pow(gamma*R*Te, 0.5) # speed of sound at exit (in m/s)
ve = Me * ae # velocity at exit (in m/s)
# part (c)
rhoo = po*101325/R/To # density at reservoir (in Kg/m^3)
rhostar_by_rhoo = pow(2.0/(gamma+1),1/(gamma-1)) # rhostar/rhoo
rhostar = rhostar_by_rhoo * rhoo # rhostar, throat density (in Kg/m^3)
Tstar_by_To = 2.0/(gamma+1) # Tstar/To
Tstar = Tstar_by_To * To # Tstar, throat temperature (in K)
astar = pow(gamma*R*Tstar, 0.5) # speed of sound at throat (in m/s)
mass = rhostar*Astar*astar # mass flow rate at throat (in Kg/s)
# part (d)
rhoe = pe*101325/R/Te # density at exit (in Kg/m^3)
Ae = mass/rhoe/ve # exit area (in m^2)
# Results
print "Exit mach number %.2f" %(Me)
print "Exit velocity %.2f m/s" %(ve)
print "Mass flow rate %.2f Kg/s" %(mass)
print "Area of the exit %.2f m^2" %(Ae)
# Example 5.4.py
# Consider the flow through a convergent-divergent duct with an exit to throat area
# ratio of 2. The reservoir pressure is 1 atm, and the exit pressure is 0.95 atm.
# Calculate the mach numbers at the throat and at the exit.
# Variable declaration
po = 1.0 # reservoir pressure (in atm)
pe = 0.95 # pressure at the exit (in atm)
Ae_by_At = 2.0 # ratio of exit to throat area
# Calculations
# from table A1 for po/pe = 1.053
Me = 0.28 # mach number at exit
Ae_by_Astar = 2.17 # nearest entry
At_by_Astar = 1 / Ae_by_At * Ae_by_Astar # At/Astar = At/Ae * Ae/Astar
# from table A1 for At/A* = 1.085
Mt = 0.72 # mach number at throat
# Results
print "Mach number at exit %.2f" %(Me)
print "Mach number at throat %.2f" %(Mt)
# Example 5.5.py
# Consider a convergent divergent duct with an exit to throat area ratio of 1.6.
# Calculate the exit to reservoir pressure ratio required to achieve sonic flow
# at the throat, but subsonic flow everywhere else.
# Variable declaration
Ae_by_At = 1.6 # ratio of exit to throat area
# Calculations
# since M = 1 at the throat Mt = Astar
# Ae/At = Ae/Astar = 1.6
# from table A1 for Ae/Astar = 1.6
po_by_pe = 1.1117 # po/pe
pe_by_po = 1/po_by_pe # pe/po
# Results
print "Exit to reservoir required pressure ratio is %.1f" %(pe_by_po)
# Example 5.6.py
# Consider a convergent divergent nozzle with an exit to throat area ratio of 3.
# A normal shock wave is inside the divergent portion at a location where the local
# area ratio is A/At = 2.0. Calculate the exit to reservoir pressure ratio.
# Variable declaration
Ae_by_At = 3.0 # ratio of exit to throat area
# Calculations
# from table A1 for A/At = 2.0
M1 = 2.2 # mach number in front the shock
# from table A2 for M1 = 2.2
M2 = 0.5471 # mach number behind the shock
po2_by_po1 = 0.6281 # stagnation pressure ratio accross the shock
# from table A1 for M2 = 0.5471
A2_by_A2star = 1.27 # A2/A2star
At_by_A2 = 1/2.0 # At/A2
Ae_by_A2star = Ae_by_At * At_by_A2 * A2_by_A2star #Ae/A2star = Ae/At * At/A2 * A2/A2star
# from table A1 for Ae/A2star = 1.905
Me = 0.32 # exit mach number
poe_by_pe = 1.074 # poe/pe
# po = po1 and poe = po2
pe_by_po = 1 / poe_by_pe * po2_by_po1 # pe/po = pe/poe * poe/po2 * po2/po1 * po1/po
# Results
print "Exit to reservoir pressure ratio is %.3f" %(pe_by_po)
# Example 5.7.py
# Consider the wind tunnel described in example 5.2. Estimate the ratio of diffuser
# throat area to nozzle throat area required to allow the tunnel to start. Also,
# assuming that the diffuser efficiency is 1.2 after the tunnel has started, calculate
# the pressure ratio across the tunnel necessary for running i.e. calculate the ratio
# of total pressure at the diffuser exit to the reservoir pressure.
# Variable declaration
M = 2.5 # mach number before the shock
eta_d = 1.2 # diffuser efficiency
# Calculations
# from table for M = 2.5
po2_by_po1 = 0.499 # po2/po1
At2_by_At1 = 1 / po2_by_po1 # At2/At1 = po1/po2
Pdo_by_po = eta_d * po2_by_po1 # pdo/po
# Results
print "Ratio of diffuser throat area to nozzle throat area %.2f" %(At2_by_At1)
print "Ratio of total pressure at the diffuser exit to the reservoir pressure, %.3f"%(Pdo_by_po)