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)
def Pt_ratio(Mn, gamma=defg._gamma): """Total pressure ration through shock wave Args: Mn: upstream relative normal Mach number to param gamma: (Default value = defg._gamma) Returns: """ return Ps_ratio(Mn, gamma) * Is.PtPs_Mach(downstream_Mn( Mn, gamma)) / Is.PtPs_Mach(Mn, gamma)
def NPR_choked_supersonic(AsAc): """Compute Nozzle Pressure Ratio to get a choked supersonic 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.MachSup_Sigma(AsAc))
def NPR_shock_at_exit(AsAc): """Compute Nozzle Pressure Ratio to get a choked, supersonic regime but shock at exit 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) """ Msup = mf.MachSup_Sigma(AsAc) Msh = sw.downstream_Mn(Msup) return Is.PtPs_Mach(Msh) / sw.Pi_ratio(Msup)
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
def update(self): gc = self.gam_cold cpc = gc*self.r_cold/(gc-1.) self.Tt0 = self.T0*Is.TtTs_Mach(self.M0, gamma=self.gam_cold) self.Pt0 = self.P0*Is.PtPs_Mach(self.M0, gamma=self.gam_cold) self.V0 = self.M0*np.sqrt(gc*self.r_cold*self.T0) self.Pt2 = self.Pt0*self.xi_inlet self.Tt2 = self.Tt0 self.Pt3 = self.Pt2*self.OPR self.Tt3 = self.Tt2*self.OPR**((gc-1.)/(gc*self.etapolCHP)) #self.Tt4 = Ti_4 self.Pt4 = self.Pt3*self.xi_cc gh = self.gam_hot cph = gh*self.r_hot/(gh-1.) self.far = (cph*self.Tt4 - cpc*self.Tt3)/(self.xi_cc*self.Pci - cph*self.Tt4) self.Tt45 = self.Tt4 - cpc*(self.Tt3-self.Tt2)/(self.eta_shaft*cph*(1.+self.far)) #print self.Tt3, self.Pt4, self.Tt45, self.Tt4, self.far self.Pt45 = self.Pt4*(self.Tt45/self.Tt4)**(gh/((gh-1.)*self.etapolTHP))
def IsentropicPsratio_Mach_deflection(Mach, dev, gamma=defg._gamma): m2 = Mach_PrandtlMeyer(PrandtlMeyer_Mach(Mach, gamma) - dev, gamma) return Is.PtPs_Mach(Mach, gamma) / Is.PtPs_Mach(m2, gamma)
def deflection_Mach_IsentropicPsratio(Mach, Pratio, gamma=defg._gamma): m2 = Is.Mach_PtPs(Is.PtPs_Mach(Mach, gamma) / Pratio, gamma) return -PrandtlMeyer_Mach(Mach, gamma) + PrandtlMeyer_Mach(m2, gamma)
def InitialValues(self): self.Pt0 = self.P0 * Is.PtPs_Mach(Mach=self.M0, gamma=self.g.gamma) self.Tt0 = self.T0 * Is.TtTs_Mach(Mach=self.M0, gamma=self.g.gamma) self.V0 = self.M0 * np.sqrt(self.g.gamma * self.g.r * self.T0) self.current_stage_corps = 1
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)
def Ptot(self): """returns Total pressure""" return self.p * Is.PtPs_Mach(self.Mach(), self._gamma)
def compute_from_pt_rtt_M(self, pt, rtt, M): ps = pt / Is.PtPs_Mach(M, self._gamma) rts = rtt / Is.TtTs_Mach(M, self._gamma) self.__init__(rho=ps / rts, u=M * np.sqrt(self._gamma * rts), p=ps)
def test_stagnation_i2t(): assert Is.TtTs_Mach(2.) == Is.TiTs_Mach(2.) assert Is.PtPs_Mach(2.) == Is.PiPs_Mach(2.) assert Is.Mach_PiPs(3.) == Is.Mach_PtPs(3.) assert Is.Mach_TiTs(3.) == Is.Mach_TtTs(3.) assert Is.Velocity_MachTi(.8, 300.) == Is.Velocity_MachTt(.8, 300.)