示例#1
0
    def __call__(self, conditions):
        """ process vehicle to setup geometry, condititon and configuration
            
            Inputs:
                conditions - DataDict() of aerodynamic conditions
                results - DataDict() of 
                
            Outputs:

                
            Assumptions:

                
        """

        # unpack
        configuration = self.configuration
        geometry = self.geometry
        stability_model = self.stability_model

        q = conditions.freestream.dynamic_pressure
        Sref = geometry.reference_area
        mach = conditions.freestream.mach_number
        velocity = conditions.freestream.velocity
        density = conditions.freestream.density
        Span = geometry.wings['main_wing'].spans.projected
        mac = geometry.wings['main_wing'].chords.mean_aerodynamic
        aero = conditions.aerodynamics

        # set up data structures
        static_stability = Data()
        dynamic_stability = Data()

        # Calculate CL_alpha
        if not conditions.has_key('lift_curve_slope'):
            conditions.lift_curve_slope = datcom(geometry.wings['main_wing'],
                                                 mach)

        # Calculate change in downwash with respect to change in angle of attack
        for surf in geometry.wings:
            sref = surf.areas.reference
            span = (surf.aspect_ratio * sref)**0.5
            surf.CL_alpha = datcom(surf, mach)
            surf.ep_alpha = Supporting_Functions.ep_alpha(
                surf.CL_alpha, sref, span)

        # Static Stability Methods
        static_stability.cm_alpha = taw_cmalpha(geometry, mach, conditions,
                                                configuration)
        static_stability.cn_beta = taw_cnbeta(geometry, conditions,
                                              configuration)

        # Dynamic Stability
        if np.count_nonzero(
                configuration.mass_properties.moments_of_inertia.tensor) > 0:
            # Dynamic Stability Approximation Methods - valid for non-zero I tensor

            # Derivative of yawing moment with respect to the rate of yaw
            cDw = aero.drag_breakdown.parasite[
                'main_wing'].parasite_drag_coefficient  # Might not be the correct value
            l_v = geometry.wings['vertical_stabilizer'].origin[
                0] + geometry.wings['vertical_stabilizer'].aerodynamic_center[
                    0] - geometry.wings['main_wing'].origin[
                        0] - geometry.wings['main_wing'].aerodynamic_center[0]
            dynamic_stability.cn_r = Supporting_Functions.cn_r(
                cDw, geometry.wings['vertical_stabilizer'].areas.reference,
                Sref, l_v, span,
                geometry.wings['vertical_stabilizer'].dynamic_pressure_ratio,
                geometry.wings['vertical_stabilizer'].CL_alpha)

            # Derivative of rolling moment with respect to roll rate
            dynamic_stability.cl_p = 0  # Need to see if there is a low fidelity way to calculate cl_p

            # Derivative of roll rate with respect to sideslip (dihedral effect)
            dynamic_stability.cl_beta = 0  # Need to see if there is a low fidelity way to calculate cl_beta

            # Derivative of pitching moment with respect to pitch rate
            l_t = geometry.wings['horizontal_stabilizer'].origin[
                0] + geometry.wings['horizontal_stabilizer'].aerodynamic_center[
                    0] - geometry.wings['main_wing'].origin[
                        0] - geometry.wings['main_wing'].aerodynamic_center[
                            0]  #Need to check this is the length of the horizontal tail moment arm
            dynamic_stability.cm_q = Supporting_Functions.cm_q(
                conditions.lift_curve_slope, l_t,
                mac)  # Need to check Cm_i versus Cm_alpha

            # Derivative of pitching rate with respect to d(alpha)/d(t)
            dynamic_stability.cm_alpha_dot = Supporting_Functions.cm_alphadot(
                static_stability.cm_alpha,
                geometry.wings['horizontal_stabilizer'].ep_alpha, l_t,
                mac)  # Need to check Cm_i versus Cm_alpha

            # Derivative of Z-axis force with respect to angle of attack
            dynamic_stability.cz_alpha = Supporting_Functions.cz_alpha(
                aero.drag_coefficient, conditions.lift_curve_slope)

            stability_model.dutch_roll = Approximations.dutch_roll(
                velocity, static_stability.cn_beta, Sref, density, Span,
                configuration.mass_properties.moments_of_inertia.tensor[2][2],
                dynamic_stability.cn_r)

            if dynamic_stability.cl_p != 0:
                stability_model.roll_tau = Approximations.roll(
                    configuration.mass_properties.momen[2][2], Sref, density,
                    velocity, Span, dynamic_stability.cl_p)
                dynamic_stability.cy_phi = Supporting_Functions.cy_phi(
                    aero.lift_coefficient)
                dynamic_stability.cl_r = Supporting_Functions.cl_r(
                    aero.lift_coefficient)  # Will need to be changed
                stability_model.spiral_tau = Approximations.spiral(
                    conditions.weights.total_mass, velocity, density, Sref,
                    dynamic_stability.cl_p, static_stability.cn_beta,
                    dynamic_stability.cy_phi, dynamic_stability.cl_beta,
                    dynamic_stability.cn_r, dynamic_stability.cl_r)
            stability_model.short_period = Approximations.short_period(
                velocity, density, Sref, mac, dynamic_stability.cm_q,
                dynamic_stability.cz_alpha, conditions.weights.total_mass,
                static_stability.cm_alpha,
                configuration.mass_properties.moments_of_inertia.tensor[1][1],
                dynamic_stability.cm_alpha_dot)
            stability_model.phugoid = Approximations.phugoid(
                conditions.freestream.gravity, conditions.freestream.velocity,
                aero.drag_coefficient, aero.lift_coefficient)

            # Dynamic Stability Full Linearized Methods
            if aero.has_key(
                    'cy_beta'
            ) and dynamic_stability.cl_p != 0 and dynamic_stability.cl_beta != 0:
                theta = conditions.frames.wind.body_rotations[:, 1]
                dynamic_stability.cy_beta = aero.cy_beta
                dynamic_stability.cl_psi = Supporting_Functions.cy_psi(
                    aero.lift_coefficient, theta)
                dynamic_stability.cL_u = 0
                dynamic_stability.cz_u = Supporting_Functions.cz_u(
                    aero.lift_coefficient, velocity, dynamic_stability.cL_u)
                dynamic_stability.cz_alpha_dot = Supporting_Functions.cz_alphadot(
                    static_stability.cm_alpha,
                    geometry.wings['horizontal_stabilizer'].ep_alpha)
                dynamic_stability.cz_q = Supporting_Functions.cz_q(
                    static_stability.cm_alpha)
                dynamic_stability.cx_u = Supporting_Functions.cx_u(
                    aero.drag_coefficient)
                dynamic_stability.cx_alpha = Supporting_Functions.cx_alpha(
                    aero.lift_coefficient, conditions.lift_curve_slope)

                lateral_directional = Full_Linearized_Equations.lateral_directional(
                    velocity, static_stability.cn_beta, Sref, density, Span,
                    configuration.mass_properties.moments_of_inertia.tensor[2]
                    [2], dynamic_stability.cn_r,
                    configuration.mass_properties.Moments_Of_Inertia.tensor[0]
                    [0], dynamic_stability.cl_p,
                    configuration.mass_properties.moments_of_inertia.tensor[0]
                    [2], dynamic_stability.cl_r, dynamic_stability.cl_beta,
                    dynamic_stability.cn_p, dynamic_stability.cy_phi,
                    dynamic_stability.cy_psi, dynamic_stability.cy_beta,
                    conditions.weights.total_mass)
                longitudinal = Full_Linearized_Equations.longitudinal(
                    velocity, density, Sref, mac, dynamic_stability.cm_q,
                    dynamic_stability.cz_alpha, conditions.weights.total_mass,
                    static_stability.cm_alpha,
                    configuration.mass_properties.moments_of_inertia.tensor[1]
                    [1], dynamic_stability.cm_alpha_dot,
                    dynamic_stability.cz_u, dynamic_stability.cz_alpha_dot,
                    dynamic_stability.cz_q, -aero.lift_coefficient, theta,
                    dynamic_stability.cx_u, dynamic_stability.cx_alpha)
                stability_model.dutch_roll.natural_frequency = lateral_directional.dutch_natural_frequency
                stability_model.dutch_roll.damping_ratio = lateral_directional.dutch_damping_ratio
                stability_model.spiral_tau = lateral_directional.spiral_tau
                stability_model.roll_tau = lateral_directional.roll_tau
                stability_model.short_period.natural_frequency = longitudinal.short_natural_frequency
                stability_model.short_period.damping_ratio = longitudinal.short_damping_ratio
                stability_model.phugoid.natural_frequency = longitudinal.phugoid_natural_frequency
                stability_model.phugoid.damping_ratio = longitudinal.phugoid_damping_ratio

        # pack results
        results = Data()
        results.static = static_stability
        results.dynamic = dynamic_stability

        return results
示例#2
0
def main():

    # Taken from Blakelock
    
    #Lateral/Directional Inputs
    velocity = 440 * (Units['ft/sec']) # Flight Velocity
    Cn_Beta = 0.096 # Yawing moment coefficient due to sideslip
    S_gross_w = 2400 * (Units['ft**2']) # Wing reference area
    density = 0.002378 * (Units['slugs/ft**3']) # Sea level density
    span = 130 * Units.ft # Span of the aircraft
    mass = 5900 * Units.slugs # mass of the aircraft
    I_x = 1.995 * 10**6 * (Units['slugs*ft**2']) # Moment of Inertia in x-axis
    I_z = 4.2 * 10**6 * (Units['slugs*ft**2']) # Moment of Inertia in z-axis
    Cn_r = -0.107 # Yawing moment coefficient due to yawing velocity
    Cl_p = -0.38 #  Rolling moment coefficient due to the rolling velocity
    Cy_phi = 0.344 # Side force coefficient due to aircraft roll
    Cl_Beta = -0.057 # Rolling moment coefficient due to to sideslip
    Cl_r = 0.086 # Rolling moment coefficient due to the yawing velocity (usually evaluated analytically)
    J_xz = 0 # Assumed
    Cn_p = -0.0228
    Cy_psi = 0
    Cy_Beta = -0.6
    mass = 5900 * Units.slugs # mass of the aircraft
    
       
    dutch_roll=Approximations.dutch_roll(velocity, Cn_Beta, S_gross_w, density, span, I_z, Cn_r)
    roll_tau = Approximations.roll(I_x, S_gross_w, density, velocity, span, Cl_p)
    spiral_tau = Approximations.spiral(mass, velocity, density, S_gross_w, Cl_p, Cn_Beta, Cy_phi, Cl_Beta, Cn_r, Cl_r)
    lateral_directional = Full_Linearized_Equations.lateral_directional(velocity, Cn_Beta, S_gross_w, density, span, I_z, Cn_r, I_x, Cl_p, J_xz, Cl_r, Cl_Beta, Cn_p, Cy_phi, Cy_psi, Cy_Beta, mass)
        
    # Longitudinal Inputs
    mass= 5800 * Units.slugs # mass of the aircraft
    velocity = 600 * (Units['ft/sec']) # Flight Velocity
    mac = 20.2 * Units.ft # mean aerodynamic chord
    Cm_q = -11.4 # Change in pitching moment coefficient due to pitching velocity
    CL = 0.74 # Coefficient of Lift
    CD = 0.044 # Coefficient of Drag
    CL_alpha = 4.42 # Change in aircraft lift due to change in angle of attack
    Cz_alpha = -4.46
    SM = -0.14 # static margin
    Cm_alpha = SM * CL_alpha
    Cm_alpha_dot = -3.27
    Iy = 2.62 * 10**6 * (Units['slugs*ft**2']) # Moment of Inertia in y-axis
    density = 0.000585 * (Units['slugs/ft**3']) # 40,000 ft density
    g = 9.8 # gravitational constant
    Cz_u = -2*CL # change in Z force with respect to change in forward velocity
    Cm_alpha_dot = -3.27
    Cz_q = -3.94
    Cw = -CL 
    Theta = 0
    Cx_u = -2*CD
    Cx_alpha = 0.392
    Cz_alpha_dot = -1.13
    
    short_period = Approximations.short_period(velocity, density, S_gross_w, mac, Cm_q, Cz_alpha, mass, Cm_alpha, Iy, Cm_alpha_dot)
    phugoid = Approximations.phugoid(g, velocity, CD, CL)
    longitudinal = Full_Linearized_Equations.longitudinal(velocity, density, S_gross_w, mac, Cm_q, Cz_alpha, mass, Cm_alpha, Iy, Cm_alpha_dot, Cz_u, Cz_alpha_dot, Cz_q, Cw, Theta, Cx_u, Cx_alpha)
    
    # Expected Values
    Blakelock = Data()
    Blakelock.longitudinal_short_zeta = 0.352
    Blakelock.longitudinal_short_w_n = 1.145
    Blakelock.longitudinal_phugoid_zeta = 0.032
    Blakelock.longitudinal_phugoid_w_n = 0.073
    Blakelock.short_period_short_w_n = 1.15
    Blakelock.short_period_short_zeta = 0.35
    Blakelock.phugoid_phugoid_w_n = 0.0765
    Blakelock.phugoid_phugoid_zeta = 0.042
    Blakelock.lateral_directional_dutch_w_n = 1.345
    Blakelock.lateral_directional_dutch_zeta = 0.14
    Blakelock.lateral_directional_spiral_tau = 1/0.004
    Blakelock.lateral_directional_roll_tau = -1/2.09
    Blakelock.dutch_roll_dutch_w_n = 1.28
    Blakelock.dutch_roll_dutch_zeta = 0.114
    Blakelock.spiral_tau = 1./0.0042
    Blakelock.roll_tau = -0.493
    
    # Calculating error percentage
    error = Data()
    error.longitudinal_short_zeta = (Blakelock.longitudinal_short_zeta - longitudinal.short_damping_ratio) / Blakelock.longitudinal_short_zeta
    error.longitudinal_short_w_n = (Blakelock.longitudinal_short_w_n - longitudinal.short_natural_frequency) / Blakelock.longitudinal_short_w_n
    error.longitudinal_phugoid_zeta = (Blakelock.longitudinal_phugoid_zeta - longitudinal.phugoid_damping_ratio) / Blakelock.longitudinal_phugoid_zeta
    error.longitudinal_phugoid_w_n = (Blakelock.longitudinal_phugoid_w_n - longitudinal.phugoid_natural_frequency) / Blakelock.longitudinal_phugoid_w_n
    error.short_period_w_n = (Blakelock.short_period_short_w_n - short_period.natural_frequency) / Blakelock.short_period_short_w_n
    error.short_period_short_zeta = (Blakelock.short_period_short_zeta - short_period.damping_ratio) / Blakelock.short_period_short_zeta
    error.phugoid_phugoid_w_n = (Blakelock.phugoid_phugoid_w_n - phugoid.natural_frequency) / Blakelock.phugoid_phugoid_w_n
    error.phugoid_phugoid_zeta = (Blakelock.phugoid_phugoid_zeta - phugoid.damping_ratio) / Blakelock.phugoid_phugoid_zeta
    error.lateral_directional_dutch_w_n = (Blakelock.lateral_directional_dutch_w_n - lateral_directional.dutch_natural_frequency) / Blakelock.lateral_directional_dutch_w_n
    error.lateral_directional_dutch_zeta = (Blakelock.lateral_directional_dutch_zeta - lateral_directional.dutch_damping_ratio) / Blakelock.lateral_directional_dutch_zeta                              
    error.lateral_directional_spiral_tau = (Blakelock.lateral_directional_spiral_tau - lateral_directional.spiral_tau) / Blakelock.lateral_directional_spiral_tau
    error.lateral_directional_roll_tau = (Blakelock.lateral_directional_roll_tau - lateral_directional.roll_tau) / Blakelock.lateral_directional_roll_tau
    error.dutch_roll_dutch_w_n = (Blakelock.dutch_roll_dutch_w_n - dutch_roll.natural_frequency) / Blakelock.dutch_roll_dutch_w_n
    error.dutch_roll_dutch_zeta = (Blakelock.dutch_roll_dutch_zeta - dutch_roll.damping_ratio) / Blakelock.dutch_roll_dutch_zeta
    error.spiral_tau = (Blakelock.spiral_tau - spiral_tau) / Blakelock.spiral_tau                               
    error.roll_tau = (Blakelock.roll_tau - roll_tau) / Blakelock.roll_tau
    
    print  error
    
    for k,v in error.items():
        assert(np.abs(v)<0.08)
        
        
    return
示例#3
0
    def __call__(self,conditions):
            """ process vehicle to setup geometry, condititon and configuration
                
                Inputs:
                    conditions - DataDict() of aerodynamic conditions
                    results - DataDict() of 
                    
                Outputs:

                    
                Assumptions:

                    
            """
            
            # unpack
            configuration = self.configuration
            geometry      = self.geometry
            q             = conditions.freestream.dynamic_pressure
            Sref          = geometry.reference_area    
            mach          = conditions.freestream.mach_number
            velocity      = conditions.freestream.velocity
            density       = conditions.freestream.density
            Span          = geometry.Wings['Main Wing'].span
            mac           = geometry.Wings['Main Wing'].chord_mac
            aero          = conditions.aerodynamics
            
            # Calculate CL_alpha 
            if not conditions.has_key('lift_curve_slope'):
                conditions.lift_curve_slope = (datcom(geometry.Wings['Main Wing'],mach))
            
            # Calculate change in downwash with respect to change in angle of attack
            for surf in geometry.Wings:
                e = surf.e
                sref = surf.sref
                span = (surf.ar * sref ) ** 0.5
                surf.CL_alpha = datcom(surf,mach)
                surf.ep_alpha = Supporting_Functions.ep_alpha(surf.CL_alpha, sref, span, e)
            
            # Static Stability Methods
            aero.cm_alpha = taw_cmalpha(geometry,mach,conditions,configuration)
            aero.cn_beta = taw_cnbeta(geometry,conditions,configuration)
            
            if np.count_nonzero(configuration.mass_props.I_cg) > 0:         
                # Dynamic Stability Approximation Methods
                if not aero.has_key('cn_r'):  
                    cDw = aero.drag_breakdown.parasite['Main Wing'].parasite_drag_coefficient # Might not be the correct value
                    l_v = geometry.Wings['Vertical Stabilizer'].origin[0] + geometry.Wings['Vertical Stabilizer'].aero_center[0] - geometry.Wings['Main Wing'].origin[0] - geometry.Wings['Main Wing'].aero_center[0]
                    aero.cn_r = Supporting_Functions.cn_r(cDw, geometry.Wings['Vertical Stabilizer'].sref, Sref, l_v, span, geometry.Wings['Vertical Stabilizer'].eta, geometry.Wings['Vertical Stabilizer'].CL_alpha)
                if not aero.has_key('cl_p'):
                    aero.cl_p = 0 # Need to see if there is a low fidelity way to calculate cl_p
                    
                if not aero.has_key('cl_beta'):
                    aero.cl_beta = 0 # Need to see if there is a low fidelity way to calculate cl_beta
                
                l_t = geometry.Wings['Horizontal Stabilizer'].origin[0] + geometry.Wings['Horizontal Stabilizer'].aero_center[0] - geometry.Wings['Main Wing'].origin[0] - geometry.Wings['Main Wing'].aero_center[0] #Need to check this is the length of the horizontal tail moment arm       
                
                if not aero.has_key('cm_q'):
                    aero.cm_q = Supporting_Functions.cm_q(conditions.lift_curve_slope, l_t,mac) # Need to check Cm_i versus Cm_alpha
                
                if not aero.has_key('cm_alpha_dot'):
                    aero.cm_alpha_dot = Supporting_Functions.cm_alphadot(aero.cm_alpha, geometry.Wings['Horizontal Stabilizer'].ep_alpha, l_t, mac) # Need to check Cm_i versus Cm_alpha
                    
                if not aero.has_key('cz_alpha'):
                    aero.cz_alpha = Supporting_Functions.cz_alpha(aero.drag_coefficient,conditions.lift_curve_slope)                   
                
                conditions.dutch_roll = Approximations.dutch_roll(velocity, aero.cn_beta, Sref, density, Span, configuration.mass_props.I_cg[2][2], aero.cn_r)
                
                if aero.cl_p != 0:                 
                    roll_tau = Approximations.roll(configuration.mass_props.I_cg[2][2], Sref, density, velocity, Span, aero.cl_p)
                    if aero.cl_beta != 0:
                        aero.cy_phi = Supporting_Functions.cy_phi(aero.lift_coefficient)
                        aero.cl_r = Supporting_Functions.cl_r( aero.lift_coefficient) # Will need to be changed
                        spiral_tau = Approximations.spiral(conditions.weights.total_mass, velocity, density, Sref, aero.cl_p, aero.cn_beta, aero.cy_phi, aero.cl_beta, aero.cn_r, aero.cl_r)
                conditions.short_period = Approximations.short_period(velocity, density, Sref, mac, aero.cm_q, aero.cz_alpha, conditions.weights.total_mass, aero.cm_alpha, configuration.mass_props.I_cg[1][1], aero.cm_alpha_dot)
                conditions.phugoid = Approximations.phugoid(conditions.freestream.gravity, conditions.freestream.velocity, aero.drag_coefficient, aero.lift_coefficient)
                
                # Dynamic Stability Full Linearized Methods
                if aero.has_key('cy_beta') and aero.cl_p != 0 and aero.cl_beta != 0:
                    if not aero.has_key('cy_psi'):
                        theta = conditions.frames.wind.body_rotations[:,1]
                        aero.cl_psi = Supporting_Functions.cy_psi(aero.lift_coefficient, theta)                     
                    if not aero.has_key('cz_u'):
                        if not aero.has_key('cL_u'):
                            aero.cL_u = 0
                        aero.cz_u = Supporting_Functions.cz_u(aero.lift_coefficient,velocity,aero.cL_u)
                    if not aero.has_key('cz_alpha_dot'):
                        aero.cz_alpha_dot = Supporting_Functions.cz_alphadot(aero.cm_alpha, geometry.Wings['Horizontal Stabilizer'].ep_alpha)
                    if not aero.has_key('cz_q'):
                        aero.cz_q = Supporting_Functions.cz_q(aero.cm_alpha)
                    if not aero.has_key('cx_u'):
                        aero.cx_u = Supporting_Functions.cx_u(aero.drag_coefficient)
                    if not aero.has_key('cx_alpha'):
                        aero.cx_alpha = Supporting_Functions.cx_alpha(aero.lift_coefficient, conditions.lift_curve_slope)
                
                    lateral_directional = Full_Linearized_Equations.lateral_directional(velocity, aero.cn_beta , Sref, density, Span, configuration.mass_props.I_cg[2][2], aero.cn_r, configuration.mass_props.I_cg[0][0], aero.cl_p, configuration.mass_props.I_cg[0][2], aero.cl_r, aero.cl_beta, aero.cn_p, aero.cy_phi, aero.cy_psi, aero.cy_beta, conditions.weights.total_mass)
                    longitudinal = Full_Linearized_Equations.longitudinal(velocity, density, Sref, mac, aero.cm_q, aero.cz_alpha, conditions.weights.total_mass, aero.cm_alpha, configuration.mass_props.I_cg[1][1], aero.cm_alpha_dot, aero.cz_u, aero.cz_alpha_dot, aero.cz_q, -aero.lift_coefficient, theta, aero.cx_u, aero.cx_alpha)
            
            return 
示例#4
0
    def __call__(self, conditions):
        """ Process vehicle to setup geometry, condititon and configuration

        Assumptions:
        None

        Source:
        N/A

        Inputs:
        conditions - DataDict() of aerodynamic conditions
        results    - DataDict() of moment coeffients and stability and body axis derivatives

        Outputs:
        None

        Properties Used:
        self.geometry
        """

        # unpack
        configuration = self.configuration
        geometry = self.geometry

        q = conditions.freestream.dynamic_pressure
        Sref = geometry.reference_area
        mach = conditions.freestream.mach_number
        velocity = conditions.freestream.velocity
        density = conditions.freestream.density
        Span = geometry.wings['main_wing'].spans.projected
        mac = geometry.wings['main_wing'].chords.mean_aerodynamic
        aero = conditions.aerodynamics

        # set up data structures
        stability = Data()
        stability.static = Data()
        stability.dynamic = Data()

        # Calculate CL_alpha
        conditions.lift_curve_slope = datcom(geometry.wings['main_wing'], mach)

        # Calculate change in downwash with respect to change in angle of attack
        for surf in geometry.wings:
            sref = surf.areas.reference
            span = (surf.aspect_ratio * sref)**0.5
            surf.CL_alpha = datcom(surf, mach)
            surf.ep_alpha = Supporting_Functions.ep_alpha(
                surf.CL_alpha, sref, span)

        # Static Stability Methods
        stability.static.Cm_alpha, stability.static.Cm0, stability.static.CM = taw_cmalpha(
            geometry, mach, conditions, configuration)

        if 'vertical_stabilizer' in geometry.wings:
            stability.static.Cn_beta = taw_cnbeta(geometry, conditions,
                                                  configuration)
        else:
            stability.static.Cn_beta = np.zeros_like(mach)

        # calculate the static margin
        stability.static.static_margin = -stability.static.Cm_alpha / conditions.lift_curve_slope

        # Dynamic Stability
        if np.count_nonzero(
                configuration.mass_properties.moments_of_inertia.tensor) > 0:
            # Dynamic Stability Approximation Methods - valid for non-zero I tensor

            # Derivative of yawing moment with respect to the rate of yaw
            cDw = aero.drag_breakdown.parasite[
                'main_wing'].parasite_drag_coefficient  # Might not be the correct value
            l_v = geometry.wings['vertical_stabilizer'].origin[
                0] + geometry.wings['vertical_stabilizer'].aerodynamic_center[
                    0] - geometry.wings['main_wing'].origin[
                        0] - geometry.wings['main_wing'].aerodynamic_center[0]
            stability.static.Cn_r = Supporting_Functions.cn_r(
                cDw, geometry.wings['vertical_stabilizer'].areas.reference,
                Sref, l_v, span,
                geometry.wings['vertical_stabilizer'].dynamic_pressure_ratio,
                geometry.wings['vertical_stabilizer'].CL_alpha)

            # Derivative of rolling moment with respect to roll rate
            stability.static.Cl_p = Supporting_Functions.cl_p(
                conditions.lift_curve_slope, geometry)

            # Derivative of roll rate with respect to sideslip (dihedral effect)
            if 'dihedral' in geometry.wings['main_wing']:
                stability.static.Cl_beta = Supporting_Functions.cl_beta(
                    geometry, stability.static.Cl_p)
            else:
                stability.static.Cl_beta = np.zeros(1)

            stability.static.Cy_beta = 0

            # Derivative of pitching moment with respect to pitch rate
            l_t = geometry.wings['horizontal_stabilizer'].origin[
                0] + geometry.wings['horizontal_stabilizer'].aerodynamic_center[
                    0] - geometry.wings['main_wing'].origin[
                        0] - geometry.wings['main_wing'].aerodynamic_center[
                            0]  #Need to check this is the length of the horizontal tail moment arm
            stability.static.Cm_q = Supporting_Functions.cm_q(
                conditions.lift_curve_slope, l_t,
                mac)  # Need to check Cm_i versus Cm_alpha

            # Derivative of pitching rate with respect to d(alpha)/d(t)
            stability.static.Cm_alpha_dot = Supporting_Functions.cm_alphadot(
                stability.static.Cm_alpha,
                geometry.wings['horizontal_stabilizer'].ep_alpha, l_t,
                mac)  # Need to check Cm_i versus Cm_alpha

            # Derivative of Z-axis force with respect to angle of attack
            stability.static.Cz_alpha = Supporting_Functions.cz_alpha(
                aero.drag_coefficient, conditions.lift_curve_slope)

            dutch_roll = Approximations.dutch_roll(
                velocity, stability.static.Cn_beta, Sref, density, Span,
                configuration.mass_properties.moments_of_inertia.tensor[2][2],
                stability.static.Cn_r)
            stability.dynamic.dutchRollFreqHz = dutch_roll.natural_frequency
            stability.dynamic.dutchRollDamping = dutch_roll.damping_ratio

            if stability.static.Cl_p.all() != 0:
                stability.dynamic.rollSubsistenceTimeConstant = Approximations.roll(
                    configuration.mass_properties.moments_of_inertia.tensor[2]
                    [2], Sref, density, velocity, Span, stability.static.Cl_p)
                stability.static.Cy_phi = Supporting_Functions.cy_phi(
                    aero.lift_coefficient)
                stability.static.Cl_r = Supporting_Functions.cl_r(
                    aero.lift_coefficient)  # Will need to be changed
                stability.dynamic.spiralSubsistenceTimeConstant = Approximations.spiral(conditions.weights.total_mass, velocity, density, Sref, stability.static.Cl_p, stability.static.Cn_beta, stability.static.Cy_phi,\
                                                                            stability.static.Cl_beta, stability.static.Cn_r, stability.static.Cl_r)

            short_period_res                               = Approximations.short_period(velocity, density, Sref, mac, stability.static.Cm_q, stability.static.Cz_alpha, conditions.weights.total_mass, stability.static.Cm_alpha,\
                                                            configuration.mass_properties.moments_of_inertia.tensor[1][1], stability.static.Cm_alpha_dot)
            stability.dynamic.shortPeriodFreqHz = short_period_res.natural_frequency
            stability.dynamic.shortPeriodDamp = short_period_res.damping_ratio

            phugoid_res = Approximations.phugoid(
                conditions.freestream.gravity, conditions.freestream.velocity,
                aero.drag_coefficient, aero.lift_coefficient)
            stability.dynamic.phugoidFreqHz = phugoid_res.natural_frequency
            stability.dynamic.phugoidDamp = phugoid_res.damping_ratio

            # Dynamic Stability Full Linearized Methods
            if stability.static.Cy_beta != 0 and stability.static.Cl_p.all(
            ) != 0 and stability.static.Cl_beta.all() != 0:
                theta = conditions.frames.wind.body_rotations[:, 1]
                stability.static.Cy_psi = Supporting_Functions.cy_psi(
                    aero.lift_coefficient, theta)
                stability.static.CL_u = 0
                stability.static.Cz_u = Supporting_Functions.cz_u(
                    aero.lift_coefficient, velocity, stability.static.cL_u)
                stability.static.Cz_alpha_dot = Supporting_Functions.cz_alphadot(
                    stability.static.Cm_alpha,
                    geometry.wings['horizontal_stabilizer'].ep_alpha)
                stability.static.Cz_q = Supporting_Functions.cz_q(
                    stability.static.Cm_alpha)
                stability.static.Cx_u = Supporting_Functions.cx_u(
                    aero.drag_coefficient)
                stability.static.Cx_alpha = Supporting_Functions.cx_alpha(
                    aero.lift_coefficient, conditions.lift_curve_slope)

                lateral_directional = Full_Linearized_Equations.lateral_directional(velocity, stability.static.cn_beta , Sref, density, Span, configuration.mass_properties.moments_of_inertia.tensor[2][2], stability.static.Cn_r,\
                                    configuration.mass_properties.moments_of_inertia.tensor[0][0], stability.static.Cl_p, configuration.mass_properties.moments_of_inertia.tensor[0][2], stability.static.Cl_r, stability.static.Cl_beta,\
                                    stability.static.Cn_p, stability.static.Cy_phi, stability.static.Cy_psi, stability.static.Cy_beta, conditions.weights.total_mass)
                longitudinal        = Full_Linearized_Equations.longitudinal(velocity, density, Sref, mac, stability.static.Cm_q, stability.static.Cz_alpha, conditions.weights.total_mass, stability.static.Cm_alpha, \
                                    configuration.mass_properties.moments_of_inertia.tensor[1][1], stability.static.Cm_alpha_dot, stability.static.Cz_u, stability.static.Cz_alpha_dot, stability.static.Cz_q, -aero.lift_coefficient,\
                                    theta, stability.static.Cx_u, stability.static.Cx_alpha)
                stability.dynamic.dutchRollFreqHz = lateral_directional.dutch_natural_frequency
                stability.dynamic.dutchRollDamping = lateral_directional.dutch_damping_ratio
                stability.dynamic.spiralSubsistenceTimeConstant = lateral_directional.spiral_tau
                stability.dynamic.rollSubsistenceTimeConstant = lateral_directional.roll_tau
                stability.dynamic.shortPeriodFreqHz = longitudinal.short_natural_frequency
                stability.dynamic.shortPeriodDamp = longitudinal.short_damping_ratio
                stability.dynamic.phugoidFreqHz = longitudinal.phugoid_natural_frequency
                stability.dynamic.phugoidDamp = longitudinal.phugoid_damping_ratio

        # pack results
        results = Data()
        results = stability

        return results
    def __call__(self,conditions):
        """ process vehicle to setup geometry, condititon and configuration
            
            Inputs:
                conditions - DataDict() of aerodynamic conditions
                results - DataDict() of 
                
            Outputs:

                
            Assumptions:

                
        """
        
        # unpack
        configuration   = self.configuration
        geometry        = self.geometry
        stability_model = self.stability_model
        
        q             = conditions.freestream.dynamic_pressure
        Sref          = geometry.reference_area    
        mach          = conditions.freestream.mach_number
        velocity      = conditions.freestream.velocity
        density       = conditions.freestream.density
        Span          = geometry.wings['main_wing'].spans.projected
        mac           = geometry.wings['main_wing'].chords.mean_aerodynamic
        aero          = conditions.aerodynamics
        
        # set up data structures
        static_stability = Data()
        dynamic_stability = Data()
        
        # Calculate CL_alpha 
        if not conditions.has_key('lift_curve_slope'):
            conditions.lift_curve_slope = datcom(geometry.wings['main_wing'],mach)
        
        # Calculate change in downwash with respect to change in angle of attack
        for surf in geometry.wings:
            sref = surf.areas.reference
            span = (surf.aspect_ratio * sref ) ** 0.5
            surf.CL_alpha = datcom(surf,mach)
            surf.ep_alpha = Supporting_Functions.ep_alpha(surf.CL_alpha, sref, span)
        
        # Static Stability Methods
        static_stability.cm_alpha = taw_cmalpha(geometry,mach,conditions,configuration)
        static_stability.cn_beta = taw_cnbeta(geometry,conditions,configuration)
        
        # Dynamic Stability
        if np.count_nonzero(configuration.mass_properties.moments_of_inertia.tensor) > 0:    
            # Dynamic Stability Approximation Methods - valid for non-zero I tensor
            
            # Derivative of yawing moment with respect to the rate of yaw
            cDw = aero.drag_breakdown.parasite['main_wing'].parasite_drag_coefficient # Might not be the correct value
            l_v = geometry.wings['vertical_stabilizer'].origin[0] + geometry.wings['vertical_stabilizer'].aerodynamic_center[0] - geometry.wings['main_wing'].origin[0] - geometry.wings['main_wing'].aerodynamic_center[0]
            dynamic_stability.cn_r = Supporting_Functions.cn_r(cDw, geometry.wings['vertical_stabilizer'].areas.reference, Sref, l_v, span, geometry.wings['vertical_stabilizer'].dynamic_pressure_ratio, geometry.wings['vertical_stabilizer'].CL_alpha)
            
            # Derivative of rolling moment with respect to roll rate
            dynamic_stability.cl_p = 0 # Need to see if there is a low fidelity way to calculate cl_p
            
            # Derivative of roll rate with respect to sideslip (dihedral effect)
            dynamic_stability.cl_beta = 0 # Need to see if there is a low fidelity way to calculate cl_beta
            
            # Derivative of pitching moment with respect to pitch rate
            l_t = geometry.wings['horizontal_stabilizer'].origin[0] + geometry.wings['horizontal_stabilizer'].aerodynamic_center[0] - geometry.wings['main_wing'].origin[0] - geometry.wings['main_wing'].aerodynamic_center[0] #Need to check this is the length of the horizontal tail moment arm       
            dynamic_stability.cm_q = Supporting_Functions.cm_q(conditions.lift_curve_slope, l_t,mac) # Need to check Cm_i versus Cm_alpha
            
            # Derivative of pitching rate with respect to d(alpha)/d(t)
            dynamic_stability.cm_alpha_dot = Supporting_Functions.cm_alphadot(static_stability.cm_alpha, geometry.wings['horizontal_stabilizer'].ep_alpha, l_t, mac) # Need to check Cm_i versus Cm_alpha
              
            # Derivative of Z-axis force with respect to angle of attack  
            dynamic_stability.cz_alpha = Supporting_Functions.cz_alpha(aero.drag_coefficient,conditions.lift_curve_slope)                   
            
            
            stability_model.dutch_roll = Approximations.dutch_roll(velocity, static_stability.cn_beta, Sref, density, Span, configuration.mass_properties.moments_of_inertia.tensor[2][2], dynamic_stability.cn_r)
            
            if dynamic_stability.cl_p != 0:                 
                stability_model.roll_tau = Approximations.roll(configuration.mass_properties.momen[2][2], Sref, density, velocity, Span, dynamic_stability.cl_p)
                dynamic_stability.cy_phi = Supporting_Functions.cy_phi(aero.lift_coefficient)
                dynamic_stability.cl_r = Supporting_Functions.cl_r( aero.lift_coefficient) # Will need to be changed
                stability_model.spiral_tau = Approximations.spiral(conditions.weights.total_mass, velocity, density, Sref, dynamic_stability.cl_p, static_stability.cn_beta, dynamic_stability.cy_phi, dynamic_stability.cl_beta, dynamic_stability.cn_r, dynamic_stability.cl_r)
            stability_model.short_period = Approximations.short_period(velocity, density, Sref, mac, dynamic_stability.cm_q, dynamic_stability.cz_alpha, conditions.weights.total_mass, static_stability.cm_alpha, configuration.mass_properties.moments_of_inertia.tensor[1][1], dynamic_stability.cm_alpha_dot)
            stability_model.phugoid = Approximations.phugoid(conditions.freestream.gravity, conditions.freestream.velocity, aero.drag_coefficient, aero.lift_coefficient)
            
            # Dynamic Stability Full Linearized Methods
            if aero.has_key('cy_beta') and dynamic_stability.cl_p != 0 and dynamic_stability.cl_beta != 0:
                theta = conditions.frames.wind.body_rotations[:,1]
                dynamic_stability.cy_beta = aero.cy_beta
                dynamic_stability.cl_psi = Supporting_Functions.cy_psi(aero.lift_coefficient, theta)                     
                dynamic_stability.cL_u = 0
                dynamic_stability.cz_u = Supporting_Functions.cz_u(aero.lift_coefficient,velocity,dynamic_stability.cL_u)
                dynamic_stability.cz_alpha_dot = Supporting_Functions.cz_alphadot(static_stability.cm_alpha, geometry.wings['horizontal_stabilizer'].ep_alpha)
                dynamic_stability.cz_q = Supporting_Functions.cz_q(static_stability.cm_alpha)
                dynamic_stability.cx_u = Supporting_Functions.cx_u(aero.drag_coefficient)
                dynamic_stability.cx_alpha = Supporting_Functions.cx_alpha(aero.lift_coefficient, conditions.lift_curve_slope)
            
                lateral_directional = Full_Linearized_Equations.lateral_directional(velocity, static_stability.cn_beta , Sref, density, Span, configuration.mass_properties.moments_of_inertia.tensor[2][2], dynamic_stability.cn_r, configuration.mass_properties.Moments_Of_Inertia.tensor[0][0], dynamic_stability.cl_p, configuration.mass_properties.moments_of_inertia.tensor[0][2], dynamic_stability.cl_r, dynamic_stability.cl_beta, dynamic_stability.cn_p, dynamic_stability.cy_phi, dynamic_stability.cy_psi, dynamic_stability.cy_beta, conditions.weights.total_mass)
                longitudinal = Full_Linearized_Equations.longitudinal(velocity, density, Sref, mac, dynamic_stability.cm_q, dynamic_stability.cz_alpha, conditions.weights.total_mass, static_stability.cm_alpha, configuration.mass_properties.moments_of_inertia.tensor[1][1], dynamic_stability.cm_alpha_dot, dynamic_stability.cz_u, dynamic_stability.cz_alpha_dot, dynamic_stability.cz_q, -aero.lift_coefficient, theta, dynamic_stability.cx_u, dynamic_stability.cx_alpha)                    
                stability_model.dutch_roll.natural_frequency = lateral_directional.dutch_natural_frequency
                stability_model.dutch_roll.damping_ratio = lateral_directional.dutch_damping_ratio
                stability_model.spiral_tau = lateral_directional.spiral_tau
                stability_model.roll_tau = lateral_directional.roll_tau
                stability_model.short_period.natural_frequency = longitudinal.short_natural_frequency
                stability_model.short_period.damping_ratio = longitudinal.short_damping_ratio
                stability_model.phugoid.natural_frequency = longitudinal.phugoid_natural_frequency
                stability_model.phugoid.damping_ratio = longitudinal.phugoid_damping_ratio
        
        # pack results
        results = Data()
        results.static  = static_stability
        results.dynamic = dynamic_stability
        
        return results
示例#6
0
    def __call__(self, conditions):
        """ process vehicle to setup geometry, condititon and configuration
                
                Inputs:
                    conditions - DataDict() of aerodynamic conditions
                    results - DataDict() of 
                    
                Outputs:

                    
                Assumptions:

                    
            """

        # unpack
        configuration = self.configuration
        geometry = self.geometry
        stability_model = self.stability_model
        q = conditions.freestream.dynamic_pressure
        Sref = geometry.reference_area
        mach = conditions.freestream.mach_number
        velocity = conditions.freestream.velocity
        density = conditions.freestream.density
        Span = geometry.wings['Main Wing'].spans.projected
        mac = geometry.wings['Main Wing'].chords.mean_aerodynamic
        aero = conditions.aerodynamics

        # Calculate CL_alpha
        if not conditions.has_key('lift_curve_slope'):
            conditions.lift_curve_slope = datcom(geometry.wings['Main Wing'],
                                                 mach)

        # Calculate change in downwash with respect to change in angle of attack
        for surf in geometry.wings:
            e = surf.span_efficiency
            sref = surf.areas.reference
            span = (surf.aspect_ratio * sref)**0.5
            surf.CL_alpha = datcom(surf, mach)
            surf.ep_alpha = Supporting_Functions.ep_alpha(
                surf.CL_alpha, sref, span, e)

        # Static Stability Methods
        aero.cm_alpha = taw_cmalpha(geometry, mach, conditions, configuration)
        aero.cn_beta = taw_cnbeta(geometry, conditions, configuration)

        if np.count_nonzero(
                configuration.mass_properties.moments_of_inertia.tensor) > 0:
            # Dynamic Stability Approximation Methods
            if not aero.has_key('cn_r'):
                cDw = aero.drag_breakdown.parasite[
                    'Main Wing'].parasite_drag_coefficient  # Might not be the correct value
                l_v = geometry.wings['Vertical Stabilizer'].origin[
                    0] + geometry.wings[
                        'Vertical Stabilizer'].aerodynamic_center[
                            0] - geometry.wings['Main Wing'].origin[
                                0] - geometry.wings[
                                    'Main Wing'].aerodynamic_center[0]
                aero.cn_r = Supporting_Functions.cn_r(
                    cDw, geometry.wings['Vertical Stabilizer'].areas.reference,
                    Sref, l_v, span, geometry.wings['Vertical Stabilizer'].eta,
                    geometry.wings['Vertical Stabilizer'].CL_alpha)
            if not aero.has_key('cl_p'):
                aero.cl_p = 0  # Need to see if there is a low fidelity way to calculate cl_p

            if not aero.has_key('cl_beta'):
                aero.cl_beta = 0  # Need to see if there is a low fidelity way to calculate cl_beta

                l_t = geometry.wings['Horizontal Stabilizer'].origin[
                    0] + geometry.wings['Horizontal Stabilizer'].aerodynamic_center[
                        0] - geometry.wings['Main Wing'].origin[
                            0] - geometry.wings['Main Wing'].aerodynamic_center[
                                0]  #Need to check this is the length of the horizontal tail moment arm

            if not aero.has_key('cm_q'):
                aero.cm_q = Supporting_Functions.cm_q(
                    conditions.lift_curve_slope, l_t,
                    mac)  # Need to check Cm_i versus Cm_alpha

            if not aero.has_key('cm_alpha_dot'):
                aero.cm_alpha_dot = Supporting_Functions.cm_alphadot(
                    aero.cm_alpha,
                    geometry.wings['Horizontal Stabilizer'].ep_alpha, l_t,
                    mac)  # Need to check Cm_i versus Cm_alpha

            if not aero.has_key('cz_alpha'):
                aero.cz_alpha = Supporting_Functions.cz_alpha(
                    aero.drag_coefficient, conditions.lift_curve_slope)

            stability_model.dutch_roll = Approximations.dutch_roll(
                velocity, aero.cn_beta, Sref, density, Span,
                configuration.mass_properties.moments_of_inertia.tensor[2][2],
                aero.cn_r)

            if aero.cl_p != 0:
                stability_model.roll_tau = Approximations.roll(
                    configuration.mass_properties.momen[2][2], Sref, density,
                    velocity, Span, aero.cl_p)
                if aero.cl_beta != 0:
                    aero.cy_phi = Supporting_Functions.cy_phi(
                        aero.lift_coefficient)
                    aero.cl_r = Supporting_Functions.cl_r(
                        aero.lift_coefficient)  # Will need to be changed
                    stability_model.spiral_tau = Approximations.spiral(
                        conditions.weights.total_mass, velocity, density, Sref,
                        aero.cl_p, aero.cn_beta, aero.cy_phi, aero.cl_beta,
                        aero.cn_r, aero.cl_r)
            stability_model.short_period = Approximations.short_period(
                velocity, density, Sref, mac, aero.cm_q, aero.cz_alpha,
                conditions.weights.total_mass, aero.cm_alpha,
                configuration.mass_properties.moments_of_inertia.tensor[1][1],
                aero.cm_alpha_dot)
            stability_model.phugoid = Approximations.phugoid(
                conditions.freestream.gravity, conditions.freestream.velocity,
                aero.drag_coefficient, aero.lift_coefficient)

            # Dynamic Stability Full Linearized Methods
            if aero.has_key(
                    'cy_beta') and aero.cl_p != 0 and aero.cl_beta != 0:
                if not aero.has_key('cy_psi'):
                    theta = conditions.frames.wind.body_rotations[:, 1]
                    aero.cl_psi = Supporting_Functions.cy_psi(
                        aero.lift_coefficient, theta)
                if not aero.has_key('cz_u'):
                    if not aero.has_key('cL_u'):
                        aero.cL_u = 0
                    aero.cz_u = Supporting_Functions.cz_u(
                        aero.lift_coefficient, velocity, aero.cL_u)
                if not aero.has_key('cz_alpha_dot'):
                    aero.cz_alpha_dot = Supporting_Functions.cz_alphadot(
                        aero.cm_alpha,
                        geometry.wings['Horizontal Stabilizer'].ep_alpha)
                if not aero.has_key('cz_q'):
                    aero.cz_q = Supporting_Functions.cz_q(aero.cm_alpha)
                if not aero.has_key('cx_u'):
                    aero.cx_u = Supporting_Functions.cx_u(
                        aero.drag_coefficient)
                if not aero.has_key('cx_alpha'):
                    aero.cx_alpha = Supporting_Functions.cx_alpha(
                        aero.lift_coefficient, conditions.lift_curve_slope)

                lateral_directional = Full_Linearized_Equations.lateral_directional(
                    velocity, aero.cn_beta, Sref, density, Span,
                    configuration.mass_properties.moments_of_inertia.tensor[2]
                    [2], aero.cn_r,
                    configuration.mass_properties.Moments_Of_Inertia.tensor[0]
                    [0], aero.cl_p,
                    configuration.mass_properties.moments_of_inertia.tensor[0]
                    [2], aero.cl_r, aero.cl_beta, aero.cn_p, aero.cy_phi,
                    aero.cy_psi, aero.cy_beta, conditions.weights.total_mass)
                longitudinal = Full_Linearized_Equations.longitudinal(
                    velocity, density, Sref, mac, aero.cm_q, aero.cz_alpha,
                    conditions.weights.total_mass, aero.cm_alpha,
                    configuration.mass_properties.moments_of_inertia.tensor[1]
                    [1], aero.cm_alpha_dot, aero.cz_u, aero.cz_alpha_dot,
                    aero.cz_q, -aero.lift_coefficient, theta, aero.cx_u,
                    aero.cx_alpha)
                stability_model.dutch_roll.natural_frequency = lateral_directional.dutch_natural_frequency
                stability_model.dutch_roll.damping_ratio = lateral_directional.dutch_damping_ratio
                stability_model.spiral_tau = lateral_directional.spiral_tau
                stability_model.roll_tau = lateral_directional.roll_tau
                stability_model.short_period.natural_frequency = longitudinal.short_natural_frequency
                stability_model.short_period.damping_ratio = longitudinal.short_damping_ratio
                stability_model.phugoid.natural_frequency = longitudinal.phugoid_natural_frequency
                stability_model.phugoid.damping_ratio = longitudinal.phugoid_damping_ratio

        return