Example #1
0
    def set_NPR(self, NPR):
        """ Define Nozzle Pressure Ratio (inlet Ptot over outlet Ps) for this case
		Define Nozzle pressure ratio and compute Mach number, Ptot and Ps according to nozzle regime
        :param NPR: NPR value (>1)

		"""
        self._Pt = np.ones_like(self.AxoAc)
        if NPR < self.NPR0:
            _Ms = Is.Mach_PtPs(NPR, gamma=self.gamma)
            self._M = mf.MachSub_Sigma(self.AxoAc / self.AsoAc *
                                       mf.Sigma_Mach(_Ms),
                                       gamma=self.gamma)
            self._Ps = self._Pt / Is.PtPs_Mach(self._M, gamma=self.gamma)
        else:
            self._M = np.ones_like(self.AxoAc)
            self._M[:self.ithroat + 1] = mf.MachSub_Sigma(
                self.AxoAc[:self.ithroat + 1], gamma=self.gamma)
            self._M[self.ithroat + 1:] = mf.MachSup_Sigma(
                self.AxoAc[self.ithroat + 1:], gamma=self.gamma)
            if NPR < self.NPRsw:
                # analytical solution for Ms, losses and upstream Mach number of shock wave
                Ms = Ms_from_AsAc_NPR(self.AsoAc, NPR)
                Ptloss = Is.PtPs_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(self._M - Msh).argmin()
                self._M[ish:] = mf.MachSub_Sigma(
                    self.AxoAc[ish:] * mf.Sigma_Mach(Ms) / self.AsoAc)
                self._Pt[ish:] = Ptloss
            self._Ps = self._Pt / Is.PtPs_Mach(self._M)
Example #2
0
def NPR_choked_subsonic(AsAc):
    """Compute Nozzle Pressure Ratio to get a choked but subsonic regime in a nozzle with As/Ac diffuser

	Args:
		AsAc ([real]): ratio of exit over throat surfaces 
	Returns:
		[real]: Nozzle Pressure ratio (inlet total pressure over exit static pressure)
	"""
    return Is.PtPs_Mach(mf.MachSub_Sigma(AsAc))
Example #3
0
    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
Example #4
0
 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)
Example #5
0
def _NPR_Ms_list(AsAc):
    """
    	Computes all NPR limits and associated exit Mach number

		internal function
 
		:param AsAc:  ratio of section at exit over throat
		:return:      result NPR and Mach numbers
 
 		:Example:

		>>> import aerokit.aero.MassFlow as mf ; mf.Sigma_Mach(Is.Mach_PtPs(np.array(_NPR_Ms_list(2.)[:3:2])))
		array([ 2.,  2.])

		.. seealso:: NPR_choked_subsonic(), NPR_choked_supersonic(), NPR_shock_at_exit()
		.. note:: available for scalar or array (numpy) computations
    """
    Msub = mf.MachSub_Sigma(AsAc)
    NPR0 = Is.PtPs_Mach(Msub)
    Msup = mf.MachSup_Sigma(AsAc)
    Msh = sw.downstream_Mn(Msup)
    NPRsw = Is.PtPs_Mach(Msh) / sw.Pi_ratio(Msup)
    NPR1 = Is.PtPs_Mach(Msup)
    return NPR0, NPRsw, NPR1, Msub, Msh, Msup
Example #6
0
from flowdyn.xnum import *
from flowdyn.integration import rk3ssp
import flowdyn.modelphy.euler as euler
import flowdyn.modeldisc as modeldisc
import flowdyn.solution.euler_nozzle as sol

gam = 1.4
bctype = "outsub_rh"
ncell = 100
nit_super = 1000
nit_tot = 10000

# expected Mach number at exit when supersonic ; defines As/Ac ratio
Msup = 1.8
AsAc = mf.Sigma_Mach(Msup, gam)
Msub = mf.MachSub_Sigma(AsAc, gam)
NPRsup = Is.PtPs_Mach(Msup, gam)
NPRsub = Is.PtPs_Mach(Msub, gam)

res = {}
meshsim = mesh.unimesh(ncell=ncell, length=10.0)


def S(x):  # section law, throat is at x=5
    return 1 + (AsAc - 1.0) * (1.0 - np.exp(-0.5 * (x - 2.0)**2))


model = euler.nozzle(gamma=gam, sectionlaw=S)
nozz = sol.nozzle(model, S(meshsim.centers()), NPR=NPRsup)
finit = nozz.fdata(meshsim)
print(NPRsup, AsAc, Msup, Msub)
Example #7
0
def test_MachSub_Sigma(AsAc):
    mach = mf.MachSub_Sigma(AsAc)
    assert (mach < 1)
    assert mf.Sigma_Mach(mach) == pytest.approx(AsAc, rel=1.e-6)