Пример #1
0
 def compute(self,conditions):
     """This computes the output values from the input values according to
     equations from the source.
     
     Assumptions:
     Constant polytropic efficiency and pressure ratio
     
     Source:
     https://web.stanford.edu/~cantwell/AA283_Course_Material/AA283_Course_Notes/
     
     Inputs:
     conditions.freestream.
       isentropic_expansion_factor         [-]
       specific_heat_at_constant_pressure  [J/(kg K)]
       pressure                            [Pa]
       stagnation_pressure                 [Pa]
       stagnation_temperature              [K]
       gas_specific_constant               [J/(kg K)]
       mach_number                         [-]
     self.inputs.
       stagnation_temperature              [K]
       stagnation_pressure                 [Pa]
                
     Outputs:
     self.outputs.
       stagnation_temperature              [K]  
       stagnation_pressure                 [Pa]
       stagnation_enthalpy                 [J/kg]
       mach_number                         [-]
       static_temperature                  [K]
       static_enthalpy                     [J/kg]
       velocity                            [m/s]
       static_pressure                     [Pa]
       area_ratio                          [-]
             
     Properties Used:
     self.
       pressure_ratio                      [-]
       polytropic_efficiency               [-]
       pressure_recovery                   [-]
     """           
     
     #unpack the values
     
     #unpack from conditions
     gamma    = conditions.freestream.isentropic_expansion_factor
     Cp       = conditions.freestream.specific_heat_at_constant_pressure
     Po       = conditions.freestream.pressure
     Pto      = conditions.freestream.stagnation_pressure
     Tto      = conditions.freestream.stagnation_temperature
     R        = conditions.freestream.gas_specific_constant
     Mo       = conditions.freestream.mach_number
     
     #unpack from inputs
     Tt_in    = self.inputs.stagnation_temperature
     Pt_in    = self.inputs.stagnation_pressure
     
     #unpack from self
     pid      = self.pressure_ratio
     etapold  = self.polytropic_efficiency
     eta_rec =  self.pressure_recovery
     
     #Method for computing the nozzle properties
     
     #--Getting the output stagnation quantities
     Pt_out   = Pt_in*pid*eta_rec
     Tt_out   = Tt_in*(pid*eta_rec)**((gamma-1)/(gamma)*etapold)
     ht_out   = Cp*Tt_out
     
     
     #compute the output Mach number, static quantities and the output velocity
     Mach          = np.sqrt((((Pt_out/Po)**((gamma-1)/gamma))-1)*2/(gamma-1))
     
     #Remove check on mach numbers from expansion nozzle
     i_low         = Mach < 10.0
     
     #initializing the Pout array
     P_out         = 1.0 *Mach/Mach
     
     #Computing output pressure and Mach number for the case Mach <1.0
     P_out[i_low]  = Po[i_low]
     Mach[i_low]   = np.sqrt((((Pt_out[i_low]/Po[i_low])**((gamma[i_low]-1.)/gamma[i_low]))-1.)*2./(gamma[i_low]-1.))
     
     #Computing the output temperature,enthalpy, velocity and density
     T_out         = Tt_out/(1.+(gamma-1.)/2.*Mach*Mach)
     h_out         = Cp*T_out
     u_out         = np.sqrt(2.*(ht_out-h_out))
     rho_out       = P_out/(R*T_out)
     
     #Computing the freestream to nozzle area ratio (mainly from thrust computation)
     area_ratio    = (fm_id(Mo,gamma)/fm_id(Mach,gamma)*(1/(Pt_out/Pto))*(np.sqrt(Tt_out/Tto)))
     
     #pack computed quantities into outputs
     self.outputs.stagnation_temperature  = Tt_out
     self.outputs.stagnation_pressure     = Pt_out
     self.outputs.stagnation_enthalpy     = ht_out
     self.outputs.mach_number             = Mach
     self.outputs.static_temperature      = T_out
     self.outputs.density                 = rho_out
     self.outputs.static_enthalpy         = h_out
     self.outputs.velocity                = u_out
     self.outputs.static_pressure         = P_out
     self.outputs.area_ratio              = area_ratio
Пример #2
0
 def compute(self,conditions):
     
     #unpack the values
     
     #unpack from conditions
     gamma    = conditions.freestream.isentropic_expansion_factor
     Cp       = conditions.freestream.specific_heat_at_constant_pressure
     Po       = conditions.freestream.pressure
     Pto      = conditions.freestream.stagnation_pressure
     Tto      = conditions.freestream.stagnation_temperature
     R        = conditions.freestream.universal_gas_constant
     Mo       = conditions.freestream.mach_number
     
     #unpack from inputs
     Tt_in    = self.inputs.stagnation_temperature
     Pt_in    = self.inputs.stagnation_pressure
     
     #unpack from self
     pid      = self.pressure_ratio
     etapold  = self.polytropic_efficiency
     
     
     #Method for computing the nozzle properties
     
     #--Getting the output stagnation quantities
     Pt_out   = Pt_in*pid
     Tt_out   = Tt_in*pid**((gamma-1)/(gamma)*etapold)
     ht_out   = Cp*Tt_out
     
     
     #compute the output Mach number, static quantities and the output velocity
     Mach          = np.sqrt((((Pt_out/Po)**((gamma-1)/gamma))-1)*2/(gamma-1))
     T_out         = Tt_out/(1+(gamma-1)/2*Mach**2)
     h_out         = Cp*T_out
     u_out         = np.sqrt(2*(ht_out-h_out))
     
     #Checking from Mach numbers below, above 1.0
     i_low         = Mach < 1.0
     i_high        = Mach >=1.0
     
     #initializing the Pout array
     P_out         = 1.0 *Mach/Mach
     
     #Computing output pressure and Mach number for the case Mach <1.0
     P_out[i_low]  = Po[i_low]
     Mach[i_low]   = np.sqrt((((Pt_out[i_low]/Po[i_low])**((gamma-1)/gamma))-1)*2/(gamma-1))
     
     #Computing output pressure and Mach number for the case Mach >=1.0        
     Mach[i_high]  = 1.0*Mach[i_high]/Mach[i_high]
     P_out[i_high] = Pt_out[i_high]/(1+(gamma-1)/2*Mach[i_high]**2)**(gamma/(gamma-1))
     
     #Computing the output temperature,enthalpy, velocity and density
     T_out         = Tt_out/(1+(gamma-1)/2*Mach**2)
     h_out         = Cp*T_out
     u_out         = np.sqrt(2*(ht_out-h_out))
     rho_out       = P_out/(R*T_out)
     
     #Computing the freestream to nozzle area ratio (mainly from thrust computation)
     area_ratio    = (fm_id(Mo)/fm_id(Mach)*(1/(Pt_out/Pto))*(np.sqrt(Tt_out/Tto)))
     
     #pack computed quantities into outputs
     self.outputs.stagnation_temperature  = Tt_out
     self.outputs.stagnation_pressure     = Pt_out
     self.outputs.stagnation_enthalpy     = ht_out
     self.outputs.mach_number             = Mach
     self.outputs.static_temperature      = T_out
     self.outputs.static_enthalpy         = h_out
     self.outputs.velocity                = u_out
     self.outputs.static_pressure         = P_out
     self.outputs.area_ratio              = area_ratio
Пример #3
0
    def compute_limited_geometry(self,conditions):
        
        """This is a variable geometry nozzle component that allows 
        for supersonic outflow. all possible nozzle conditions, including 
        overexpansion and underexpansion.
        
        Assumptions:
        Constant polytropic efficiency and pressure ratio
        
        Source:
        https://web.stanford.edu/~cantwell/AA283_Course_Material/AA283_Course_Notes/
        https://web.stanford.edu/~cantwell/AA210A_Course_Material/AA210A_Course_Notes/
        
        Inputs:
        conditions.freestream.
          isentropic_expansion_factor         [-]
          specific_heat_at_constant_pressure  [J/(kg K)]
          pressure                            [Pa]
          stagnation_pressure                 [Pa]
          stagnation_temperature              [K]
          gas_specific_constant               [J/(kg K)] 
          mach_number                         [-]
        self.inputs.
          stagnation_temperature              [K]
          stagnation_pressure                 [Pa]
                   
        Outputs:
        self.outputs.
          stagnation_temperature              [K]  
          stagnation_pressure                 [Pa]
          stagnation_enthalpy                 [J/kg]
          mach_number                         [-]
          static_temperature                  [K]
          static_enthalpy                     [J/kg]
          velocity                            [m/s]
          static_pressure                     [Pa]
                
        Properties Used:
        self.
          pressure_ratio                      [-]
          polytropic_efficiency               [-]
          max_area_ratio                      [-]
          min_area_ratio                      [-]
        """           
        
        #unpack the values
        
        #unpack from conditions
        gamma    = conditions.freestream.isentropic_expansion_factor
        Cp       = conditions.freestream.specific_heat_at_constant_pressure
        Po       = conditions.freestream.pressure
        Pto      = conditions.freestream.stagnation_pressure
        Tto      = conditions.freestream.stagnation_temperature
        R        = conditions.freestream.gas_specific_constant
        Mo       = conditions.freestream.mach_number
        To       = conditions.freestream.temperature
        
        #unpack from inputs
        Tt_in    = self.inputs.stagnation_temperature
        Pt_in    = self.inputs.stagnation_pressure                
        
        #unpack from self
        pid             = self.pressure_ratio
        etapold         = self.polytropic_efficiency
        max_area_ratio  = self.max_area_ratio
        min_area_ratio  = self.min_area_ratio
        
        
        # Method for computing the nozzle properties
        #--Getting the output stagnation quantities
        Pt_out   = Pt_in*pid
        Tt_out   = Tt_in*pid**((gamma-1.)/(gamma)*etapold)
        ht_out   = Cp*Tt_out
  
        # Method for computing the nozzle properties
        #-- Initial estimate for exit area
        area_ratio = (max_area_ratio + min_area_ratio)/2.
        
        #-- Compute limits of each possible flow condition       
        subsonic_pressure_ratio     = pressure_ratio_isentropic(area_ratio, gamma, True)
        nozzle_shock_pressure_ratio = pressure_ratio_shock_in_nozzle(area_ratio, gamma)
        supersonic_pressure_ratio   = pressure_ratio_isentropic(area_ratio, gamma, False) 
        supersonic_max_Area         = pressure_ratio_isentropic(max_area_ratio, gamma, False)
        supersonic_min_Area         = pressure_ratio_isentropic(min_area_ratio, gamma, False)

        #-- Compute the output Mach number guess with freestream pressure
        #-- Initializing arrays
        P_out       = np.ones_like(Pt_out)
        A_ratio     = area_ratio*np.ones_like(Pt_out)
        M_out       = np.ones_like(Pt_out)

        # Establishing a correspondence between real pressure ratio and limits of each flow condition
        
        # Determine if flow is within subsonic/sonic range
        i_sub               = Po/Pt_out >= subsonic_pressure_ratio 
        
        # Detemine if there is a shock in nozzle
        i2                  = Po/Pt_out < subsonic_pressure_ratio
        i3                  = Po/Pt_out >= nozzle_shock_pressure_ratio
        i_shock             = np.logical_and(i2,i3)      
        
        # Determine if flow is overexpanded
        i4                  = Po/Pt_out < nozzle_shock_pressure_ratio
        i5                  = Po/Pt_out > supersonic_min_Area
        i_over              = np.logical_and(i4,i5)  
        
        # Determine if flow is supersonic
        i6                  = Po/Pt_out <= supersonic_min_Area
        i7                  = Po/Pt_out >= supersonic_max_Area
        i_sup               = np.logical_and(i6,i7) 
        
        # Determine if flow is underexpanded
        i_und               = Po/Pt_out < supersonic_max_Area
        
        #-- Subsonic and sonic flow
        P_out[i_sub]        = Po[i_sub]
        M_out[i_sub]        = np.sqrt((((Pt_out[i_sub]/P_out[i_sub])**((gamma[i_sub]-1.)/gamma[i_sub]))-1.)*2./(gamma[i_sub]-1.))
        A_ratio[i_sub]      = 1./fm_id(M_out[i_sub],gamma[i_sub])
        
        #-- Shock inside nozzle
        P_out[i_shock]      = Po[i_shock]
        M_out[i_shock]      = np.sqrt((((Pt_out[i_shock]/P_out[i_shock])**((gamma[i_shock]-1.)/gamma[i_shock]))-1.)*2./(gamma[i_shock]-1.))   
        A_ratio[i_shock]    = 1./fm_id(M_out[i_shock],gamma[i_shock])
        
        #-- Overexpanded flow
        P_out[i_over]       = supersonic_min_Area[i_over]*Pt_out[i_over] 
        M_out[i_over]       = np.sqrt((((Pt_out[i_over]/P_out[i_over])**((gamma[i_over]-1.)/gamma[i_over]))-1.)*2./(gamma[i_over]-1.))
        A_ratio[i_over]     = 1./fm_id(M_out[i_over],gamma[i_over])
        
        #-- Isentropic supersonic flow, with variable area adjustments
        P_out[i_sup]        = Po[i_sup]
        M_out[i_sup]        = np.sqrt((((Pt_out[i_sup]/P_out[i_sup])**((gamma[i_sup]-1.)/gamma[i_sup]))-1.)*2./(gamma[i_sup]-1.))    
        A_ratio[i_sup]      = 1./fm_id(M_out[i_sup],gamma[i_sup])
        
        #-- Underexpanded flow
        P_out[i_und]        = supersonic_max_Area[i_und]*Pt_out[i_und] 
        M_out[i_und]        = np.sqrt((((Pt_out[i_und]/P_out[i_und])**((gamma[i_und]-1.)/gamma[i_und]))-1.)*2./(gamma[i_und]-1.))
        A_ratio[i_und]      = 1./fm_id(M_out[i_und],gamma[i_und])
        
        #-- Calculate other flow properties
        T_out   = Tt_out/(1.+(gamma-1.)/2.*M_out*M_out)
        h_out   = Cp*T_out
        u_out   = M_out*np.sqrt(gamma*R*T_out)
        rho_out = P_out/(R*T_out)

        #pack computed quantities into outputs
        self.outputs.stagnation_temperature  = Tt_out
        self.outputs.stagnation_pressure     = Pt_out
        self.outputs.stagnation_enthalpy     = ht_out
        self.outputs.mach_number             = M_out
        self.outputs.static_temperature      = T_out
        self.outputs.rho                     = rho_out
        self.outputs.static_enthalpy         = h_out
        self.outputs.velocity                = u_out
        self.outputs.static_pressure         = P_out
        self.outputs.area_ratio              = A_ratio
Пример #4
0
    def compute(self, conditions):

        #unpack the values

        #unpack from conditions
        gamma = conditions.freestream.isentropic_expansion_factor
        Cp = conditions.freestream.specific_heat_at_constant_pressure
        Po = conditions.freestream.pressure
        Pto = conditions.freestream.stagnation_pressure
        Tto = conditions.freestream.stagnation_temperature
        R = conditions.freestream.universal_gas_constant
        Mo = conditions.freestream.mach_number

        #unpack from inputs
        Tt_in = self.inputs.stagnation_temperature
        Pt_in = self.inputs.stagnation_pressure

        #unpack from self
        pid = self.pressure_ratio
        etapold = self.polytropic_efficiency

        #Method for computing the nozzle properties

        #--Getting the output stagnation quantities
        Pt_out = Pt_in * pid
        Tt_out = Tt_in * pid**((gamma - 1) / (gamma) * etapold)
        ht_out = Cp * Tt_out

        #compute the output Mach number, static quantities and the output velocity
        Mach = np.sqrt(
            (((Pt_out / Po)**((gamma - 1) / gamma)) - 1) * 2 / (gamma - 1))

        #Checking from Mach numbers below, above 1.0
        i_low = Mach < 1.0
        i_high = Mach >= 1.0

        #initializing the Pout array
        P_out = 1.0 * Mach / Mach

        #Computing output pressure and Mach number for the case Mach <1.0
        P_out[i_low] = Po[i_low]
        Mach[i_low] = np.sqrt(
            (((Pt_out[i_low] / Po[i_low])**((gamma - 1) / gamma)) - 1) * 2 /
            (gamma - 1))

        #Computing output pressure and Mach number for the case Mach >=1.0
        Mach[i_high] = 1.0 * Mach[i_high] / Mach[i_high]
        P_out[i_high] = Pt_out[i_high] / (
            1 + (gamma - 1) / 2 * Mach[i_high]**2)**(gamma / (gamma - 1))

        #Computing the output temperature,enthalpy, velocity and density
        T_out = Tt_out / (1 + (gamma - 1) / 2 * Mach**2)
        h_out = Cp * T_out
        u_out = np.sqrt(2 * (ht_out - h_out))
        rho_out = P_out / (R * T_out)

        #Computing the freestream to nozzle area ratio (mainly from thrust computation)
        area_ratio = (fm_id(Mo) / fm_id(Mach) * (1 / (Pt_out / Pto)) *
                      (np.sqrt(Tt_out / Tto)))

        #pack computed quantities into outputs
        self.outputs.stagnation_temperature = Tt_out
        self.outputs.stagnation_pressure = Pt_out
        self.outputs.stagnation_enthalpy = ht_out
        self.outputs.mach_number = Mach
        self.outputs.static_temperature = T_out
        self.outputs.static_enthalpy = h_out
        self.outputs.velocity = u_out
        self.outputs.static_pressure = P_out
        self.outputs.area_ratio = area_ratio
Пример #5
0
    def compute(self, conditions):
        """This computes the output values from the input values according to
        equations from the source.
        
        Assumptions:
        Constant polytropic efficiency and pressure ratio
        
        Source:
        https://web.stanford.edu/~cantwell/AA283_Course_Material/AA283_Course_Notes/
        
        Inputs:
        conditions.freestream.
          isentropic_expansion_factor         [-]
          specific_heat_at_constant_pressure  [J/(kg K)]
          pressure                            [Pa]
          stagnation_pressure                 [Pa]
          stagnation_temperature              [K]
          gas_specific_constant               [J/(kg K)]
          mach_number                         [-]
        self.inputs.
          stagnation_temperature              [K]
          stagnation_pressure                 [Pa]
                   
        Outputs:
        self.outputs.
          stagnation_temperature              [K]  
          stagnation_pressure                 [Pa]
          stagnation_enthalpy                 [J/kg]
          mach_number                         [-]
          static_temperature                  [K]
          static_enthalpy                     [J/kg]
          velocity                            [m/s]
          static_pressure                     [Pa]
          area_ratio                          [-]
                
        Properties Used:
        self.
          pressure_ratio                      [-]
          polytropic_efficiency               [-]
          pressure_recovery                   [-]
        """

        #unpack the values

        #unpack from conditions
        gamma = conditions.freestream.isentropic_expansion_factor
        Cp = conditions.freestream.specific_heat_at_constant_pressure
        Po = conditions.freestream.pressure
        Pto = conditions.freestream.stagnation_pressure
        Tto = conditions.freestream.stagnation_temperature
        R = conditions.freestream.gas_specific_constant
        Mo = conditions.freestream.mach_number

        #unpack from inputs
        Tt_in = self.inputs.stagnation_temperature
        Pt_in = self.inputs.stagnation_pressure

        #unpack from self
        pid = self.pressure_ratio
        etapold = self.polytropic_efficiency
        eta_rec = self.pressure_recovery

        #Method for computing the nozzle properties

        #--Getting the output stagnation quantities
        Pt_out = Pt_in * pid * eta_rec
        Tt_out = Tt_in * (pid * eta_rec)**((gamma - 1) / (gamma) * etapold)
        ht_out = Cp * Tt_out

        #compute the output Mach number, static quantities and the output velocity
        Mach = np.sqrt(
            (((Pt_out / Po)**((gamma - 1) / gamma)) - 1) * 2 / (gamma - 1))

        #Remove check on mach numbers from expansion nozzle
        i_low = Mach < 10.0

        #initializing the Pout array
        P_out = 1.0 * Mach / Mach

        #Computing output pressure and Mach number for the case Mach <1.0
        P_out[i_low] = Po[i_low]
        Mach[i_low] = np.sqrt((((Pt_out[i_low] / Po[i_low])**(
            (gamma[i_low] - 1.) / gamma[i_low])) - 1.) * 2. /
                              (gamma[i_low] - 1.))

        #Computing the output temperature,enthalpy, velocity and density
        T_out = Tt_out / (1. + (gamma - 1.) / 2. * Mach * Mach)
        h_out = Cp * T_out
        u_out = np.sqrt(2. * (ht_out - h_out))
        rho_out = P_out / (R * T_out)

        #Computing the freestream to nozzle area ratio (mainly from thrust computation)
        area_ratio = (fm_id(Mo, gamma) / fm_id(Mach, gamma) *
                      (1 / (Pt_out / Pto)) * (np.sqrt(Tt_out / Tto)))

        #pack computed quantities into outputs
        self.outputs.stagnation_temperature = Tt_out
        self.outputs.stagnation_pressure = Pt_out
        self.outputs.stagnation_enthalpy = ht_out
        self.outputs.mach_number = Mach
        self.outputs.static_temperature = T_out
        self.outputs.density = rho_out
        self.outputs.static_enthalpy = h_out
        self.outputs.velocity = u_out
        self.outputs.static_pressure = P_out
        self.outputs.area_ratio = area_ratio
Пример #6
0
    def compute_limited_geometry(self, conditions):
        """This is a variable geometry nozzle component that allows 
        for supersonic outflow. all possible nozzle conditions, including 
        overexpansion and underexpansion.
        
        Assumptions:
        Constant polytropic efficiency and pressure ratio
        
        Source:
        https://web.stanford.edu/~cantwell/AA283_Course_Material/AA283_Course_Notes/
        https://web.stanford.edu/~cantwell/AA210A_Course_Material/AA210A_Course_Notes/
        
        Inputs:
        conditions.freestream.
          isentropic_expansion_factor         [-]
          specific_heat_at_constant_pressure  [J/(kg K)]
          pressure                            [Pa]
          stagnation_pressure                 [Pa]
          stagnation_temperature              [K]
          gas_specific_constant               [J/(kg K)] 
          mach_number                         [-]
        self.inputs.
          stagnation_temperature              [K]
          stagnation_pressure                 [Pa]
                   
        Outputs:
        self.outputs.
          stagnation_temperature              [K]  
          stagnation_pressure                 [Pa]
          stagnation_enthalpy                 [J/kg]
          mach_number                         [-]
          static_temperature                  [K]
          static_enthalpy                     [J/kg]
          velocity                            [m/s]
          static_pressure                     [Pa]
                
        Properties Used:
        self.
          pressure_ratio                      [-]
          polytropic_efficiency               [-]
          max_area_ratio                      [-]
          min_area_ratio                      [-]
        """

        #unpack the values

        #unpack from conditions
        gamma = conditions.freestream.isentropic_expansion_factor
        Cp = conditions.freestream.specific_heat_at_constant_pressure
        Po = conditions.freestream.pressure
        Pto = conditions.freestream.stagnation_pressure
        Tto = conditions.freestream.stagnation_temperature
        R = conditions.freestream.gas_specific_constant
        Mo = conditions.freestream.mach_number
        To = conditions.freestream.temperature

        #unpack from inputs
        Tt_in = self.inputs.stagnation_temperature
        Pt_in = self.inputs.stagnation_pressure

        #unpack from self
        pid = self.pressure_ratio
        etapold = self.polytropic_efficiency
        max_area_ratio = self.max_area_ratio
        min_area_ratio = self.min_area_ratio

        # Method for computing the nozzle properties
        #--Getting the output stagnation quantities
        Pt_out = Pt_in * pid
        Tt_out = Tt_in * pid**((gamma - 1.) / (gamma) * etapold)
        ht_out = Cp * Tt_out

        # Method for computing the nozzle properties
        #-- Initial estimate for exit area
        area_ratio = (max_area_ratio + min_area_ratio) / 2.

        #-- Compute limits of each possible flow condition
        subsonic_pressure_ratio = pressure_ratio_isentropic(
            area_ratio, gamma, True)
        nozzle_shock_pressure_ratio = pressure_ratio_shock_in_nozzle(
            area_ratio, gamma)
        supersonic_pressure_ratio = pressure_ratio_isentropic(
            area_ratio, gamma, False)
        supersonic_max_Area = pressure_ratio_isentropic(
            max_area_ratio, gamma, False)
        supersonic_min_Area = pressure_ratio_isentropic(
            min_area_ratio, gamma, False)

        #-- Compute the output Mach number guess with freestream pressure
        #-- Initializing arrays
        P_out = np.ones_like(Pt_out)
        A_ratio = area_ratio * np.ones_like(Pt_out)
        M_out = np.ones_like(Pt_out)

        # Establishing a correspondence between real pressure ratio and limits of each flow condition

        # Determine if flow is within subsonic/sonic range
        i_sub = Po / Pt_out >= subsonic_pressure_ratio

        # Detemine if there is a shock in nozzle
        i2 = Po / Pt_out < subsonic_pressure_ratio
        i3 = Po / Pt_out >= nozzle_shock_pressure_ratio
        i_shock = np.logical_and(i2, i3)

        # Determine if flow is overexpanded
        i4 = Po / Pt_out < nozzle_shock_pressure_ratio
        i5 = Po / Pt_out > supersonic_min_Area
        i_over = np.logical_and(i4, i5)

        # Determine if flow is supersonic
        i6 = Po / Pt_out <= supersonic_min_Area
        i7 = Po / Pt_out >= supersonic_max_Area
        i_sup = np.logical_and(i6, i7)

        # Determine if flow is underexpanded
        i_und = Po / Pt_out < supersonic_max_Area

        #-- Subsonic and sonic flow
        P_out[i_sub] = Po[i_sub]
        M_out[i_sub] = np.sqrt((((Pt_out[i_sub] / P_out[i_sub])**(
            (gamma[i_sub] - 1.) / gamma[i_sub])) - 1.) * 2. /
                               (gamma[i_sub] - 1.))
        A_ratio[i_sub] = 1. / fm_id(M_out[i_sub], gamma[i_sub])

        #-- Shock inside nozzle
        P_out[i_shock] = Po[i_shock]
        M_out[i_shock] = np.sqrt((((Pt_out[i_shock] / P_out[i_shock])**(
            (gamma[i_shock] - 1.) / gamma[i_shock])) - 1.) * 2. /
                                 (gamma[i_shock] - 1.))
        A_ratio[i_shock] = 1. / fm_id(M_out[i_shock], gamma[i_shock])

        #-- Overexpanded flow
        P_out[i_over] = supersonic_min_Area[i_over] * Pt_out[i_over]
        M_out[i_over] = np.sqrt((((Pt_out[i_over] / P_out[i_over])**(
            (gamma[i_over] - 1.) / gamma[i_over])) - 1.) * 2. /
                                (gamma[i_over] - 1.))
        A_ratio[i_over] = 1. / fm_id(M_out[i_over], gamma[i_over])

        #-- Isentropic supersonic flow, with variable area adjustments
        P_out[i_sup] = Po[i_sup]
        M_out[i_sup] = np.sqrt((((Pt_out[i_sup] / P_out[i_sup])**(
            (gamma[i_sup] - 1.) / gamma[i_sup])) - 1.) * 2. /
                               (gamma[i_sup] - 1.))
        A_ratio[i_sup] = 1. / fm_id(M_out[i_sup], gamma[i_sup])

        #-- Underexpanded flow
        P_out[i_und] = supersonic_max_Area[i_und] * Pt_out[i_und]
        M_out[i_und] = np.sqrt((((Pt_out[i_und] / P_out[i_und])**(
            (gamma[i_und] - 1.) / gamma[i_und])) - 1.) * 2. /
                               (gamma[i_und] - 1.))
        A_ratio[i_und] = 1. / fm_id(M_out[i_und], gamma[i_und])

        #-- Calculate other flow properties
        T_out = Tt_out / (1. + (gamma - 1.) / 2. * M_out * M_out)
        h_out = Cp * T_out
        u_out = M_out * np.sqrt(gamma * R * T_out)
        rho_out = P_out / (R * T_out)

        #pack computed quantities into outputs
        self.outputs.stagnation_temperature = Tt_out
        self.outputs.stagnation_pressure = Pt_out
        self.outputs.stagnation_enthalpy = ht_out
        self.outputs.mach_number = M_out
        self.outputs.static_temperature = T_out
        self.outputs.rho = rho_out
        self.outputs.static_enthalpy = h_out
        self.outputs.velocity = u_out
        self.outputs.static_pressure = P_out
        self.outputs.area_ratio = A_ratio
Пример #7
0
    def compute(self, conditions):
        """ This computes the output values from the input values according to
        equations from the source.

        Assumptions:
        Constant polytropic efficiency and pressure ratio
        If pressures make the Mach number go negative, these values are corrected

        Source:
        https://web.stanford.edu/~cantwell/AA283_Course_Material/AA283_Course_Notes/

        Inputs:
        conditions.freestream.
          isentropic_expansion_factor         [-]
          specific_heat_at_constant_pressure  [J/(kg K)]
          pressure                            [Pa]
          stagnation_pressure                 [Pa]
          stagnation_temperature              [K]
          specific_gas_constant               [J/(kg K)] 
          mach_number                         [-]
        self.inputs.
          stagnation_temperature              [K]
          stagnation_pressure                 [Pa]

        Outputs:
        self.outputs.
          stagnation_temperature              [K]  
          stagnation_pressure                 [Pa]
          stagnation_enthalpy                 [J/kg]
          mach_number                         [-]
          static_temperature                  [K]
          static_enthalpy                     [J/kg]
          velocity                            [m/s]
          static_pressure                     [Pa]
          area_ratio                          [-]
          denisty                             [kg/m^3]

        Properties Used:
        self.
          pressure_ratio                      [-]
          polytropic_efficiency               [-]
        """
        #unpack the values

        #unpack from conditions
        gamma = conditions.freestream.isentropic_expansion_factor
        Cp = conditions.freestream.specific_heat_at_constant_pressure
        Po = conditions.freestream.pressure
        Pto = conditions.freestream.stagnation_pressure
        Tto = conditions.freestream.stagnation_temperature
        R = conditions.freestream.gas_specific_constant
        Mo = conditions.freestream.mach_number

        #unpack from inputs
        Tt_in = self.inputs.stagnation_temperature
        Pt_in = self.inputs.stagnation_pressure

        #unpack from self
        pid = self.pressure_ratio
        etapold = self.polytropic_efficiency

        #Method for computing the nozzle properties

        #--Getting the output stagnation quantities
        Pt_out = Pt_in * pid
        Tt_out = Tt_in * pid**((gamma - 1) / (gamma) * etapold)
        ht_out = Cp * Tt_out

        # A cap so pressure doesn't go negative
        Pt_out[Pt_out < Po] = Po[Pt_out < Po]

        #compute the output Mach number, static quantities and the output velocity
        Mach = np.sqrt(
            (((Pt_out / Po)**((gamma - 1) / gamma)) - 1) * 2 / (gamma - 1))

        #Checking from Mach numbers below, above 1.0
        i_low = Mach < 1.0
        i_high = Mach >= 1.0

        #initializing the Pout array
        P_out = 1.0 * Mach / Mach

        #Computing output pressure and Mach number for the case Mach <1.0
        P_out[i_low] = Po[i_low]
        Mach[i_low] = np.sqrt((((Pt_out[i_low] / Po[i_low])**(
            (gamma[i_low] - 1.) / gamma[i_low])) - 1.) * 2. /
                              (gamma[i_low] - 1.))

        #Computing output pressure and Mach number for the case Mach >=1.0
        Mach[i_high] = 1.0 * Mach[i_high] / Mach[i_high]
        P_out[i_high] = Pt_out[i_high] / (
            1. + (gamma[i_high] - 1.) / 2. * Mach[i_high] * Mach[i_high])**(
                gamma[i_high] / (gamma[i_high] - 1.))

        # A cap to make sure Mach doesn't go to zero:
        if np.any(Mach <= 0.0):
            warn('Pressures Result in Negative Mach Number, making positive',
                 RuntimeWarning)
            Mach[Mach <= 0.0] = 0.001

        #Computing the output temperature,enthalpy, velocity and density
        T_out = Tt_out / (1 + (gamma - 1) / 2 * Mach * Mach)
        h_out = Cp * T_out
        u_out = np.sqrt(2 * (ht_out - h_out))
        rho_out = P_out / (R * T_out)

        #Computing the freestream to nozzle area ratio (mainly from thrust computation)
        area_ratio = (fm_id(Mo, gamma) / fm_id(Mach, gamma) *
                      (1 / (Pt_out / Pto)) * (np.sqrt(Tt_out / Tto)))

        #pack computed quantities into outputs
        self.outputs.stagnation_temperature = Tt_out
        self.outputs.stagnation_pressure = Pt_out
        self.outputs.stagnation_enthalpy = ht_out
        self.outputs.mach_number = Mach
        self.outputs.static_temperature = T_out
        self.outputs.density = rho_out
        self.outputs.static_enthalpy = h_out
        self.outputs.velocity = u_out
        self.outputs.static_pressure = P_out
        self.outputs.area_ratio = area_ratio