# Example 4.1.py
# A uniform supersonic stream with M1 = 3.0, p1 = 1 atm, T1 = 288 K encounters
# a compression corner which deflects the stream by an angle theta = 20 deg.
# Calculate the shock wave angle, and p2, T2, M2, po2 and To2 behind the shock
# wave.
# Variable declaration
M1 = 3.0 # upstream mach number
p1 = 1.0 # upstream pressure (in atm)
T1 = 288 # upstream temperature (in K)
theta = 20 # deflection (in degrees)
# Calculations
# subscript 2 means behind the shock
# from figure 4.5 from M1 = 3.0, theta = 20.0 deg.
beta = 37.5 # shock angle (in degress)
# degree to radian conversion is done by multiplying by pi/180
from numpy import sin, pi
Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock
# from Table A2 for Mn1 = 1.826
p2_by_p1 = 3.723 # p2/p1
T2_by_T1 = 1.551 # T2/T1
Mn2 = 0.6108
po2_by_po1 = 0.8011 # po2/po1
p2 = p2_by_p1 * p1 # p2 (in atm) = p2/p1 * p1
T2 = T2_by_T1 * T1 # T2 (in K) = T2/T1 * T1
M2 = Mn2/(sin((beta-theta)*pi/180)) # mach number behind the shock
# from A1 for M1 = 3.0
po1_by_p1 = 36.73
To1_by_T1 = 2.8
po2 = po2_by_po1 * po1_by_p1 * p1 # po2 (in atm) = po2/po1 * po1/p1 * p1
To2 = To1 = To1_by_T1 * T1 # To2 (in atm) = To2/To1 * To1/T1 * T1
# Result
print "Shock wave angle %.2f degrees"%(beta)
print "p2 = %.2f atm" %(p2)
print "T2 = %.2f K" %(T2)
print "M2 = %.2f " %(M2)
print "po2 = %.2f atm" %(po2)
print "To2 = %.2f K" %(To2)
# Example 4.2.py
# In Example 4.1, the deflection angle is increased to theta = 30 degrees.
# Calculate the pressure and Mach number behind the wave, and compare these
# results with those of Example 4.1.
# Variable declaration
M1 = 3.0 # upstream mach number
p1 = 1.0 # upstream pressure (in atm)
T1 = 288 # upstream temperature (in K)
theta = 30 # deflection (in degrees)
# Calculations
# subscript 2 means behind the shock
# from figure 4.5 from M1 = 3.0, theta = 30.0 deg.
beta = 52.0 # shock angle (in degress)
# degree to radian conversion is done by multiplying by pi/180
from numpy import sin, pi
Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock
# from Table A2 for Mn1 = 2.364
p2_by_p1 = 6.276 # p2/p1
Mn2 = 0.5286
p2 = p2_by_p1 * p1 # p2 (in atm) = p2/p1 * p1
M2 = Mn2/(sin((beta-theta)*pi/180)) # mach number behind the shock
print "Shock wave angle %.2f degrees"%(beta)
print "p2 = %.3f atm" %(p2)
print "M2 = %.2f " %(M2)
comparison = """
Comparing the above results with those from Example 4.1. When theta is increased, the shock wave becomes stronger, as evidenced by the increased pressure behind
the shock(6.276 atm as compared to 3.723). The Mach number behind the shock is
reduced(1.41 compared to 2.03). Also, as theta is increased, beta also increases
(52 degrees compared to 37.5 degrees.
"""
print comparison
# Example 4.3.py
# In Example 4.1, the free stream mach number is increased to 5.0.
# Calculate the pressure and Mach number behind the wave, and compare these
# results with those of Example 4.1.
# Variable declaration
M1 = 5.0 # upstream mach number
p1 = 1.0 # upstream pressure (in atm)
T1 = 288 # upstream temperature (in K)
theta = 20.0 # deflection (in degrees)
# Calculations
# subscript 2 means behind the shock
# from figure 4.5 from M1 = 5.0, theta = 20.0 deg.
beta = 30.0 # shock angle (in degress)
# degree to radian conversion is done by multiplying by pi/180
from numpy import sin, pi
Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock
# from Table A2 for Mn1 = 2.5
p2_by_p1 = 7.125 # p2/p1
Mn2 = 0.513
p2 = p2_by_p1 * p1 # p2 (in atm) = p2/p1 * p1
M2 = Mn2/(sin((beta-theta)*pi/180)) # mach number behind the shock
print "Shock wave angle %.2f degrees"%(beta)
print "p2 = %.3f atm" %(p2)
print "M2 = %.2f " %(M2)
# Example 4.5.py
# Consider a 15 deg half angle wedge at zero angle of attack. Calculate the
# pressure coefficient on the wedge surface in a Mach 3 flow of air.
# Variable declaration
M1 = 3.0 # upstream mach number
theta = 15.0 # deflection (in degrees)
gamma = 1.4 # ratio of specific heats
# Calculations
# subscript 2 means behind the shock
# from figure 4.5 from M1 = 3.0, theta = 15.0 deg.
beta = 32.2 # shock angle (in degress)
# degree to radian conversion is done by multiplying by pi/180
from numpy import sin, pi
Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock
# from Table A2 for Mn1 = 1.6
p2_by_p1 = 2.82 # p2/p1
Cp = 2/(gamma*M1*M1) * (p2_by_p1 - 1)
# Results
print "Coefficient of pressure is %.3f"%(Cp)
# Example 4.6.py
# Consider a 15 deg half angle wedge at zero angle of attack in a Mach 3 flow of
# air. Calculate the drag coefficient. Assume that the pressure exerted over the
# base of the wedge, the base pressure, is equal to the free stream pressure.
# Variable declaration
M1 = 3.0 # upstream mach number
theta = 15.0 # deflection (in degrees)
gamma = 1.4 # ratio of specific heats
# Calculations
# subscript 2 means behind the shock
# from figure 4.5 from M1 = 3.0, theta = 15.0 deg.
beta = 32.2 # shock angle (in degress)
# degree to radian conversion is done by multiplying by pi/180
from numpy import sin, pi, tan
Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock
# from Table A2 for Mn1 = 1.6
p2_by_p1 = 2.82 # p2/p1
Cd = 4/(gamma*M1*M1)*(p2_by_p1 - 1)*tan(theta*pi/180)
# Results
print "Coefficient of drag is %.3f"%(Cd)
# Example 4.7.py
# Consider a horizontal supersonic flow at Mach 2.8 with a static pressure and
# temperature of 1 atm and 519 R, respectively. This flow passes over a compr-
# ession corner with deflection angle of 16 degrees. The oblique shock generated
# at the corner propagates into the flow, and is incident on a horizontal wall,
# as shown in Fig. 4.15. Calculate the angle phi made by the reflected shock wave
# with respect to the wall, and the Mach number, pressure and temperature behind
# the reflected shock.
# Variable declaration
M1 = 2.8 # upstream mach number
p1 = 1.0 # upstream pressure (in atm)
T1 = 519.0 # upstream temperature (in R)
theta = 16.0 # deflection (in degrees)
# Calculations
# subscript 2 means behind the shock
# from figure 4.5 from M1 = 2.8, theta = 16.0 deg.
beta_1 = 35.0 # shock angle (in degress)
# degree to radian conversion is done by multiplying by pi/180
from numpy import sin, pi
Mn1 = M1 * sin(beta_1*pi/180) # upstream mach number normal to the shock
# from Table A2 for Mn1 = 1.606
p2_by_p1 = 2.82 # p2/p1
T2_by_T1 = 1.388 # T2/T1
Mn2 = 0.6684
p2 = p2_by_p1 * p1 # p2 (in atm) = p2/p1 * p1
T2 = T2_by_T1 * T1 # T2 (in R) = T2/T1 * T1
M2 = Mn2/(sin((beta_1-theta)*pi/180)) # mach number behind the shock
# from figure 4.5 from M2 = 2.053, theta = 16.0 deg.
beta_2 = 45.5 # shock angle of reflected(in degress)
# degree to radian conversion is done by multiplying by pi/180
Mn2 = M2 * sin(beta_2*pi/180) # upstream mach number normal to the shock
# from Table A2 for Mn1 = 1.46
p3_by_p2 = 2.32 # p3/p2
T3_by_T2 = 1.294 # T3/T2
Mn3 = 0.7157
p3 = p3_by_p2 * p2 # p3 (in atm) = p3/p2 * p2
T3 = T3_by_T2 * T2 # T3 (in R) = T3/T2 * T2
phi = beta_2 - theta # (in degrees)
M3 = Mn3/(sin((beta_2-theta)*pi/180)) # mach number behind the reflected shock
# Result
print "phi %.2f degrees" %(phi)
print "Pressure behind reflected shock, p3 = %.2f atm" %(p3)
print "Temperature behind reflected shock, T3 = %.2f R" %(T3)
print "Mach behind reflected shock, M3 = %.2f " %(M3)
# Example 4.8.py
# A uniform supersonic stream with M1 = 1.5, p1 = 1700 lb/ft^2, and T1 = 460.0 R
# encounters an expansion corner which deflects the stream by and angle theta_2
# = 20 degrees. Calculate M2, p2, T2, po2, To2, and the angles the forward and
# rearward Mach lines make with respect to the upstream flow direction.
# Variable declaration
M1 = 1.5 # upstream mach number
p1 = 1700.0 # upstream pressure (in lb/ft^2)
T1 = 460.0 # upstream temperature (in R)
theta_2 = 20.0 # deflection (in degrees)
# Calculations
# subscript 2 means after the expansion fan
# from Table A5 for M1 = 1.5
v1 = 11.91 # (in degrees)
mu1 = 41.81 # (in degrees)
v2 = v1 + theta_2
# from Table A5, for v2 = 31.91
M2 = 2.207 # Mach behind the expansion fan
mu2 = 26.95 # (in degrees)
# from Table A1 for M1 = 1.5
po1_by_p1 = 3.671 # po1/p1
To1_by_T1 = 1.45 # To1/T1
# from Table A1 for M2 = 2.207
po2_by_p2 = 10.81 # po2/p2
To2_by_T2 = 1.974 # To2/T2
p2 = 1/po2_by_p2 * po1_by_p1 * p1 # p2 (in lb/ft^2) = p2/po2 * po2/po1 * po1/p1 * p1 and po2 = po1
T2 = 1/To2_by_T2 * To1_by_T1 * T1 # T2 (in R) = T2/To2 * To2/To1 * To1/T1 * T1 and To2 = To1
po2 = po1 = po1_by_p1 * p1 # po2 (in lb/ft^2) = po1/p1 * p1
To2 = To1 = To1_by_T1 * T1 # To2 (in R) = To1/T1 * T1
angle_forward = mu1 # angle of forward ray (in degrees)
angle_rearward = mu2 - theta_2 # angle of backward ray (in degrees)
# Result
print "M2 = %.3f" %(M2)
print "p2 = %.2f lb/ft^2" %(p2)
print "T2 = %.2f deg R" %(T2)
print "po2 = %.2f lb/ft^2" %(po2)
print "To2 = %.2f deg R" %(To2)
print "Angle forward = %.2f degrees" %(angle_forward)
print "Angle rearward = %.2f degrees" %(angle_rearward)
# Example 4.9.py
# Consider the arrangement shows in fig. 4.29. A 15 degree half angle diamond
# wedge airfoil is in supersonic flow at zero angle of attack. A pitot tube is
# inserted into the flow at the location shown in fig 4.29. The pressure measured
# by the Pitot tube is 2.596 atm. At point a on the backface, the pressure is 0.1
# atm. Calculate the freestream Mach number M1.
from numpy import sin, pi
# Variable declaration
theta = 15.0 # wedge angle/deflection (in degrees)
po4 = 2.596 # measured pressure (in atm)
p3 = 0.1 # pressure at point a (in atm)
# Calculations
po4_by_p3 = po4/p3
# from Table A 2 for po4/p3 = 25.96
M3 = 4.45
v3 = 71.27
v2 = v3 - 2*theta
# from Table A 5, for v2 = 41.27 degrees
M2 = 2.6
# Mn2 = M2*sin((beta-theta)*pi/180) @equation 1
# Guessing
# Guess 1
M1 = 4.0 # Guess for freestream number
beta = 27.0 # from fig 4.5 (in degrees)
Mn1 = M1*sin(beta*pi/180) # mach number normal to shock
# from Table A2 for Mn1 = 1.816
Mn2 = 0.612
# but Mn2 from equation 1 is 0.54
# Guess 2
M1 = 4.5 # Guess for freestream number
beta = 25.5 # from fig 4.5 (in degrees)
Mn1 = M1*sin(beta*pi/180) # mach number normal to shock
# from Table A2 for Mn1 = 1.937
Mn2 = 0.588
# but Mn2 from equation 1 is 0.47
# Guess 3
M1 = 3.5 # Guess for freestream number
beta = 29.2 # from fig 4.5 (in degrees)
Mn1 = M1*sin(beta*pi/180) # mach number normal to shock
# from Table A2 for Mn1 = 1.71
Mn2 = 0.638
# but Mn2 from equation 1 is 0.638
# Result
print "Freestream mach number is %.1f" %(M1)
# Example 4.10.py
# Consider an infinitely this flat plate at 5 degrees angle of attack in a Mach
# 2.6 free stream. Calculate the lift and drag coefficients.
from numpy import sin, cos, pi
# Variable declaration
alpha = 5.0 # angle of attack in degrees (in degrees)
M1 = 2.6 # freestream mach number
gamma = 1.4 # ratio of specific heats
# Calculations
# from table A5 for M1 = 2.6
v1 = 41.41 # (in degrees)
v2 = v1 + alpha # (in degrees)
# from table A5 for v2 = 46.41 deg
M2 = 2.85
# from A1 for M1 = 2.6
po1_by_p1 = 19.95
# from A1 for M2 = 2.85
po2_by_p2 = 29.29
p2_by_p1 = 1/po2_by_p2 * po1_by_p1 # p2/p1 = p2/po2 * po2/po1 * po1/p1 and po2 = po1
# from theta-beta-M diagram for M1 = 2.6
theta = 5.0 # deflection (in degrees)
beta = 26.5 # shock angle (in degrees)
Mn1 = M1*sin(beta*pi/180) # mach number normal to the shock
# from table A2 for Mn1 = 1.16
p3_by_p1 = 1.403 # p3/p1
cl = 2.0/(gamma*M1*M1)*(p3_by_p1 - p2_by_p1)*cos(alpha*pi/180) # coefficient of lift
cd = 2.0/(gamma*M1*M1)*(p3_by_p1 - p2_by_p1)*sin(alpha*pi/180) # coefficient of drag
# Results
print "Lift coefficient : %.3f"%(cl)
print "Drag coefficient : %.4f"%(cd)