def test_nozzle_class(): target_AoAc = 6. length = 8. Noz_x = np.linspace(0., length, 200, endpoint=True) ma_max = mf.Mach_Sigma(target_AoAc, Mach=2.) ma = 1. + (ma_max-1.)*np.sin(.5*(Noz_x-1.)*np.pi/(length-1.)) Noz_AoAc = mf.Sigma_Mach(ma) convdiv = noz.nozzle(Noz_x, Noz_AoAc, AsoAc=target_AoAc) assert convdiv.AsoAc == target_AoAc assert convdiv.ithroat == 25
def test_nozzle(): target_AoAc = 6. length = 8. Noz_x = np.linspace(0., length, 200, endpoint=True) ma_max = mf.Mach_Sigma(target_AoAc, Mach=2.) ma = 1. + (ma_max-1.)*np.sin(.5*(Noz_x-1.)*np.pi/(length-1.)) Noz_AoAc = mf.Sigma_Mach(ma) convdiv = noz.nozzle(Noz_x, Noz_AoAc, AsoAc=target_AoAc, NPR=4.) assert not np.any(np.isnan(convdiv.Mach())) assert not np.any(np.isnan(convdiv.Ps())) assert not np.any(np.isnan(convdiv.Ptot()))
def set_NPR(self, NPR): """ Define Nozzle Pressure Ratio (inlet Ptot over outlet Ps) for this case :param NPR: NPR value (>1) """ self.NPR = NPR defg.set_gamma(self._gam) if NPR < self.NPR0: # flow is fully subsonic _Ms = Is.Mach_PiPs(NPR) _M = mf.MachSub_Sigma(self.section * mf.Sigma_Mach(_Ms) / self.section[-1]) _Pt = 0. * _M + NPR _Ps = _Pt / Is.PiPs_Mach(_M) else: # compute Mach, assumed to be subsonic before throat, supersonic after _Minit = 0. * self.section + .5 _Minit[self.ithroat:] = 2. _M = mf.Mach_Sigma(self.section / self.section[self.ithroat], Mach=_Minit) _Pt = NPR + 0. * _M # CHECK, there is a shock # analytical solution for Ms, losses and upstream Mach number of shock wave Ms = nz.Ms_from_AsAc_NPR(self.AsoAc, NPR) Ptloss = Is.PiPs_Mach(Ms) / NPR Msh = sw.Mn_Pi_ratio(Ptloss) # if NPR < self.NPRsw: # throat is choked, there may be a shock # redefine curves starting from 'ish' index (closest value of Msh in supersonic flow) ish = np.abs(_M - Msh).argmin() _M[ish:] = mf.MachSub_Sigma( self.section[ish:] * mf.Sigma_Mach(Ms) / self.section[-1]) _Pt[ish:] = Ptloss * NPR _Ps = _Pt / Is.PiPs_Mach(_M) # self._M = _M self._Pt = _Pt self._Ps = _Ps return
def set_NPR(NPR): if NPR < NPR0: _Ms = Is.Mach_PiPs(NPR, gamma=self.model.gamma) self._M = mf.MachSub_Sigma(self.AsoAc * mf.Sigma_Mach(Ma_col) / self.AsoAc[-1], gamma=self.model.gamma) self._Pt = 0. * coord_x + 1. self._Ps = _Pt / Is.PiPs_Mach(self._M, gamma=self.model.gamma) elif NPR < NPRsw: _M = mf.Mach_Sigma(Noz_AoAc, Mach=_Minit) # # analytical solution for Ms, losses and upstream Mach number of shock wave Ms = nz.Ms_from_AsAc_NPR(target_AoAc, NPR) Ptloss = Is.PiPs_Mach(Ms) / NPR Msh = sw.Mn_Pi_ratio(Ptloss) # # redefine curves starting from 'ish' index (closest value of Msh in supersonic flow) ish = np.abs(_M - Msh).argmin() _M[ish:] = mf.MachSub_Sigma(Noz_AoAc[ish:] * mf.Sigma_Mach(Ms) / target_AoAc) _Pt[ish:] = Ptloss _Ps = _Pt / Is.PiPs_Mach(_M)
fontsize=12, y=0.93) ax[0].set_ylabel('$p_{i3}/p_{i0}$', fontsize=10) ax[0].grid(which='major', linestyle=':', alpha=0.5) ax[1].set_ylabel('$p_{i4}/p_{i0}$', fontsize=10) ax[1].grid(which='major', linestyle=':', alpha=0.5) ax[2].set_xlabel('$T_{i4}/T_{i3}$', fontsize=10) ax[2].set_ylabel('$M_{3}$', fontsize=10) ax[2].grid(which='major', linestyle=':', alpha=0.5) # --- (FS) fully supersonic flow (not expected on design) M3sup = mf.Mach_Sigma(A3A2 * mf.Sigma_Mach(M2, gam), gam) M4max = mf.Mach_Sigma(A3A2 / A8A2, 2., gam) # look for supersonic value alphamax = ray.Ti_Ticri(M4max, gam) / ray.Ti_Ticri(M3sup, gam) print("unchoking of fully supersonic flow for Ti4/Ti0 = %6.3f" % (alphamax)) FSalpha = np.log10(np.logspace(1., alphamax, npts + 1)) FSm4 = ray.SupMach_TiTicri(FSalpha / alphamax * ray.Ti_Ticri(M4max, gam), gam) FSpi4 = ray.Pi_Picri(FSm4, gam) / ray.Pi_Picri(M3sup, gam) FSpi3 = np.ones(npts + 1) FSm3 = M3sup * np.ones(npts + 1) ax[0].plot(FSalpha, FSpi3, '-', color='#ff0000') ax[1].plot(FSalpha, FSpi4, '-', color='#ff0000') ax[2].plot(FSalpha, FSm3, '-', color='#ff0000') # --- (CW) conventional working state
import numpy as np import aerokit.aero.MassFlow as mf import matplotlib.pyplot as plt # g = 1.4 mmax = 5. n = 1000 Mach = np.linspace(.05, mmax, n) Sigma = mf.Sigma_Mach(Mach) Mres = mf.Mach_Sigma(Sigma, Mach) fig, ax = plt.subplots(1, 2) ax[0].plot(Mach, Mres, Mach, mf.__MachSub_sigma(Sigma, g), Mach, mf.__MachSup_sigma(Sigma, g)) ax[0].set_xlim(0, mmax) ax[0].set_ylim(0, mmax) # Taylor expansions m = np.linspace(0.05, 5, 1000) gpuogmu = (g + 1.) / (g - 1.) sig1 = 1. / m / ((g + 1) / 2.)**(gpuogmu / 2.) sig2 = (1. + (3 - g) / 4. / (g - 1.) * (m - 1.)**2) sig3 = (m**2 / gpuogmu)**(gpuogmu / 2.) / m ax[1].plot(m, sig1, m, sig2, m, sig3, m, mf.Sigma_Mach(m)) plt.show()
def test_sigma_reverse_numpy(): m = np.linspace(.01, 2., 30) np.testing.assert_allclose(m, mf.Mach_Sigma(mf.Sigma_Mach(m), m))