Esempio n. 1
0
def flowisentropic(gamma, flow, mtype='mach'):
    """
    Calculate isentropic flow ratios.

    http://www.mathworks.nl/help/aerotbx/ug/flowisentropic.html
    """
    M, T, P, rho, area = aerotbx.flowisentropic(**{'gamma':gamma, mtype:flow})
    return M, T, P, rho, area
Esempio n. 2
0
def flowisentropic(gamma, flow, mtype='mach'):
    """
    Calculate isentropic flow ratios.

    http://www.mathworks.nl/help/aerotbx/ug/flowisentropic.html
    """
    M, T, P, rho, area = aerotbx.flowisentropic(**{
        'gamma': gamma,
        mtype: flow
    })
    return M, T, P, rho, area
79.8 17.664 1.081; 84.8 18.553 1.136;
96.8 21.067 1.290; 99.8 21.698 1.328;
102.8 22.306 1.365; 114.8 24.488 1.499;
119.8 25.275 1.547; 124.8 25.992 1.591;
129.8 26.638 1.631; 134.8 27.219 1.666;
139.8 27.734 1.698; 144.8 28.188 1.725;
149.8 28.584 1.750; 154.8 28.924 1.770;
159.8 29.212 1.788; 164.8 29.450 1.803;
176.8 29.832 1.826; 179.8 29.890 1.830;
182.8 29.935 1.832; 194.8 30.000 1.836]""")

# import the windtunnel experimental data (obtained during the HSWTT)
data1 = np.loadtxt("hswtdata_example.txt", skiprows=5)

# use the distribution data to calculate the theoretical isentropic flow
m1, t1, p1, r1, a1 = flowisentropic(sub=dist[:,2])
m2, t2, p2, r2, a2 = flowisentropic(sup=dist[:,2])

# Stitch the subsonic and supersonic solutions together
psubsup = np.vstack((p1[:9],p2[9:]))

# plot the theoretical and experimental data
plt.plot(dist[:,0], psubsup, 'k--', label="Theory")
plt.plot(data1[:,0], data1[:,1], 'k^-', label="Experiment")
plt.axis([19.8, 194.8, 0, 1])
plt.legend(loc="upper right")
plt.xlabel("location $x$ [mm]")
plt.ylabel(r"pressure ratio $\frac{p}{p_0}$ [-]")
plt.show()

plot_s = True
plot_pres_s = True
import matplotlib  # Set graph font size
matplotlib.rcParams.update({'font.size': 16})

# Initialise the flow variables
phi = np.zeros(n + 1 + 3 * int(round(n * (n + 1) / 2.)))
nu = np.zeros(n + 1 + 3 * int(round(n * (n + 1) / 2.)))
M = np.zeros(n + 1 + 3 * int(round(n * (n + 1) / 2.)))
mu = np.zeros(n + 1 + 3 * int(round(n * (n + 1) / 2.)))

# Compute PM angle and Mach angle in the exit
M[0], nu[0], mu[0] = aerotbx.flowprandtlmeyer(gamma=gamma, M=M_e)

# Compute the total pressure ratio in the exit
P_eP_t = aerotbx.flowisentropic(gamma=gamma,
                                M=M_e)[2]  # Outputs [mach, T, P, rho, area]

# Compute total pressure ratio in the ambient after the expansion
P_aP_t = P_eP_t / P_eP_a

# With the total pressure ratio, compute the Mach number behind the expansion fan (region 3)
M[n] = aerotbx.flowisentropic(gamma=gamma, p=P_aP_t)[0][0]

# Compute the flow angle in the region behind the expansion fan (region 3)
(_, nu[n], mu[n]) = aerotbx.flowprandtlmeyer(gamma=gamma, M=M[n])
phi[n] = nu[n] - nu[0] + phi[0]

# Compute the flow angles and Mach in the fan
delta_phi_en = (phi[n] - phi[0]) / (float(n)
                                    )  # Since we take three characteristics
h = 0.1

#Plotting
plot_pres_c = False
plot_mach = False

phi = np.zeros(n + 1 + 2 * round(n * (n + 1) / 2.))
nu = np.zeros(n + 1 + 2 * round(n * (n + 1) / 2.))
M = np.zeros(n + 1 + 2 * round(n * (n + 1) / 2.))
mu = np.zeros(n + 1 + 2 * round(n * (n + 1) / 2.))

(M[0], nu[0], mu[0]) = aerotbx.flowprandtlmeyer(gamma=gamma,
                                                M=M0)  # Output: [m,nu,mu]

# # First calculate the Mach number in region n using the pressure ratio since the expension is isentropic
p_0_p_t = aerotbx.flowisentropic(gamma=gamma,
                                 M=M0)[2]  # Output: [mach,T,P,rho,area]
p_n_p_t = p_0_p_t * (1 / p0_pa
                     )  # Calculate ratio total pressure vs pressure in 3
p_a_p_t = p_n_p_t

#
# # Using this total pressure ratio the mach number in section 3 can be determined
M[n] = aerotbx.flowisentropic(
    gamma=gamma, p=p_n_p_t)[0][0]  # Returns an array of mach numbers
(_, nu[n], mu[n]) = aerotbx.flowprandtlmeyer(gamma=gamma, M=M[n])

phi[n] = nu[n] - nu[0] + phi[0]
dphi_A = (phi[n] - phi[0]) / float(n)

phi[1:n] = np.arange(1, n) * dphi_A
Esempio n. 6
0
import scipy as sp
from aerotbx import flowisentropic

def tablestr(v):
    e = sp.floor(sp.log10(v)) + 1
    m = v / 10**e
    s = ' $-$ ' if e < 0 else ' $+$ '
    return '%.4f' % m + s + '%02d' % sp.absolute(e)

M = sp.concatenate((sp.arange(0, 2, 0.02) + 0.02,
                    sp.arange(2, 5, 0.05) + 0.05,
                    sp.arange(5, 8, 0.1) + 0.1,
                    sp.arange(8, 20, 1) + 1,
                    sp.arange(20, 50, 2) + 2))

M, T, P, rho, area = flowisentropic(M=M)

with open('main.tex', 'w') as f:
    f.write('\\documentclass[a4paper,11pt]{article}\n')
    f.write('\\usepackage[a4paper, top=2cm]{geometry}\n')
    f.write('\\usepackage{longtable}\n')
    f.write('\\title{Appendix}\n')
    f.write('\\author{}\n')
    f.write('\\date{}\n')
    f.write('\\begin{document}\n')
    f.write('\\maketitle\n')
    f.write('\\begin{center}\n')
    f.write('\\section*{\\huge Isentropic Flow Properties}\n')
    f.write('\\setlength\\tabcolsep{10pt}\n')
    f.write('\\begin{longtable}{ c c c c c }\n')
    f.write('\\hline \\\\ $M$ & $\\frac{p_0}{p}$ & $\\frac{\\rho_0}{\\rho}$ & ' + \
Esempio n. 7
0
62.8 16.372 1.002; 74.8 16.958 1.038;
79.8 17.664 1.081; 84.8 18.553 1.136;
96.8 21.067 1.290; 99.8 21.698 1.328;
102.8 22.306 1.365; 114.8 24.488 1.499;
119.8 25.275 1.547; 124.8 25.992 1.591;
129.8 26.638 1.631; 134.8 27.219 1.666;
139.8 27.734 1.698; 144.8 28.188 1.725;
149.8 28.584 1.750; 154.8 28.924 1.770;
159.8 29.212 1.788; 164.8 29.450 1.803;
176.8 29.832 1.826; 179.8 29.890 1.830;
182.8 29.935 1.832; 194.8 30.000 1.836]""")

#import the windtunnel experimental data (obtained during the HSWTT)
data1 = np.loadtxt("hswtdata_example.txt", skiprows=5)

#use the distribution data to calculate the theoretical isentropic flow
m1, t1, p1, r1, a1 = flowisentropic(sub=dist[:, 2])
m2, t2, p2, r2, a2 = flowisentropic(sup=dist[:, 2])

#Stich the subsonic and supersonic solutions together
psubsup = np.vstack((p1[:9], p2[9:]))

#plot the theoretical and experimental data
plt.plot(dist[:, 0], psubsup, 'k--', label="Theory")
plt.plot(data1[:, 0], data1[:, 1], 'k^-', label="Experiment")
plt.axis([19.8, 194.8, 0, 1])
plt.legend(loc="upper right")
plt.xlabel("location $x$ [mm]")
plt.ylabel(r"pressure ratio $\frac{p}{p_0}$ [-]")
plt.show()
import aerotbx

h = 0.5  #outlet height [m]
p0_pa = 2.0
gamma = 1.4
M0 = 2.0
phi0 = 0.0  # Degrees
nu0 = aerotbx.flowprandtlmeyer(gamma=gamma, M=M0)[1]  # Output: [m,nu,mu]

# Know from common knowledge
phi4 = phi7 = phi9 = 0.0

# First use 3 characteristcs solving the problem
# See drawn figure
# First calculate the Mach number in region 3 using the pressure ratio since the expension is isentropic
p_0_p_t = aerotbx.flowisentropic(gamma=gamma,
                                 M=M0)[2]  # Output: [mach,T,P,rho,area]
p_3_p_t = p_0_p_t * (1 / p0_pa
                     )  # Calculate ratio total pressure vs pressure in 3
p_a_p_t = p_3_p_t

# Using this total pressure ratio the mach number in section 3 can be determined
M3 = aerotbx.flowisentropic(
    gamma=gamma, p=p_3_p_t)[0][0]  # Returns an array of mach numbers
nu3 = aerotbx.flowprandtlmeyer(gamma=gamma, M=M3)[1][0]

# Use MOC to obtain mu3 (gamma + from 0 to 3)
phi3 = nu3 - nu0 + phi0

# No go back through expansion fan
dphi_I = (phi3 - phi0) / 3.0  # Phi step over fan I