def main():
    
    vehicle  = mission_B737.vehicle_setup()
    configs  = mission_B737.configs_setup(vehicle)
    analyses = mission_B737.analyses_setup(configs)
    mission  = mission_setup(configs,analyses)
    
    vehicle.mass_properties.takeoff = 70000 * Units.kg
    
    configs.finalize()
    analyses.finalize()
    
    results = mission.evaluate()
    results = results.merged()
    
    plot_results(results)
    
    error = mission.target_landing_weight - results.conditions.weights.total_mass[-1,0]
    print 'landing weight error' , error
    assert error < 1.
    
    return
Beispiel #2
0
def main():

    vehicle = mission_B737.vehicle_setup()
    configs = mission_B737.configs_setup(vehicle)
    analyses = mission_B737.analyses_setup(configs)
    mission = mission_setup(configs, analyses)

    vehicle.mass_properties.takeoff = 70000 * Units.kg

    configs.finalize()
    analyses.finalize()

    results = mission.evaluate()
    results = results.merged()

    plot_results(results)

    error = abs(mission.target_landing_weight -
                results.conditions.weights.total_mass[-1, 0])
    print 'landing weight error', error
    assert error < 1.

    return
def main():
    
    # initialize the vehicle
    vehicle = vehicle_setup() 
    for wing in vehicle.wings:
        wing.areas.wetted   = 2.0 * wing.areas.reference
        wing.areas.exposed  = 0.8 * wing.areas.wetted
        wing.areas.affected = 0.6 * wing.areas.wetted  
        
        
    # initalize the aero model
    aerodynamics = SUAVE.Analyses.Aerodynamics.Fidelity_Zero()
    aerodynamics.geometry = vehicle
        
    aerodynamics.initialize()    
    
    
    #no of test points
    test_num = 11
    
    #specify the angle of attack
    angle_of_attacks = np.linspace(-.174,.174,test_num)[:,None] #* Units.deg
    
    
    # Cruise conditions (except Mach number)
    state = SUAVE.Analyses.Mission.Segments.Conditions.State()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics()
    
    
    state.expand_rows(test_num)    
        
    # --------------------------------------------------------------------
    # Initialize variables needed for CL and CD calculations
    # Use a seeded random order for values
    # --------------------------------------------------------------------
    
    random.seed(1)
    Mc = np.linspace(0.05,0.9,test_num)
    random.shuffle(Mc)
    rho = np.linspace(0.3,1.3,test_num)
    random.shuffle(rho)
    mu = np.linspace(5*10**-6,20*10**-6,test_num)
    random.shuffle(mu)
    T = np.linspace(200,300,test_num)
    random.shuffle(T)
    pressure = np.linspace(10**5,10**6,test_num)
    
    # Changed after to preserve seed for initial testing
    Mc = Mc[:,None]
    rho = rho[:,None]
    mu = mu[:,None]
    T = T[:,None]
    pressure = pressure[:,None]

    
    state.conditions.freestream.mach_number = Mc
    state.conditions.freestream.density = rho
    state.conditions.freestream.dynamic_viscosity = mu
    state.conditions.freestream.temperature = T
    state.conditions.freestream.pressure = pressure
    
    state.conditions.aerodynamics.angle_of_attack = angle_of_attacks   
    
    
    # --------------------------------------------------------------------
    # Surrogate
    # --------------------------------------------------------------------    
    
            
    #call the aero model        
    results = aerodynamics.evaluate(state)
    
    #build a polar for the markup aero
    polar = Data()    
    CL = results.lift.total
    CD = results.drag.total
    polar.lift = CL
    polar.drag = CD    
    
    
    # --------------------------------------------------------------------
    # Test compute Lift
    # --------------------------------------------------------------------
    
    
    
    #compute_aircraft_lift(conditions, configuration, geometry) 
    
    lift = state.conditions.aerodynamics.lift_coefficient
    lift_r = np.array([-2.42489437, -0.90696416, -0.53991953, -0.3044834 ,  -0.03710598,
                       0.31061936 ,  0.52106899,  0.77407765,  1.22389024,  1.86240501,
                       1.54587835])[:,None]
    
    lift_test = np.abs((lift-lift_r)/lift)
    
    print '\nCompute Lift Test Results\n'
    #print lift_test
        
    assert(np.max(lift_test)<1e-4), 'Aero regression failed at compute lift test'    
    
    
    # --------------------------------------------------------------------
    # Test compute drag 
    # --------------------------------------------------------------------
    
    #compute_aircraft_drag(conditions, configuration, geometry)
    
    # Pull calculated values
    drag_breakdown = state.conditions.aerodynamics.drag_breakdown
    
    # Only one wing is evaluated since they rely on the same function
    cd_c           = drag_breakdown.compressible['main_wing'].compressibility_drag
    cd_i           = drag_breakdown.induced.total
    cd_m           = drag_breakdown.miscellaneous.total
    # cd_m_fuse_base = drag_breakdown.miscellaneous.fuselage_base
    # cd_m_fuse_up   = drag_breakdown.miscellaneous.fuselage_upsweep
    # cd_m_nac_base  = drag_breakdown.miscellaneous.nacelle_base['turbo_fan']
    # cd_m_ctrl      = drag_breakdown.miscellaneous.control_gaps
    cd_p_fuse      = drag_breakdown.parasite['fuselage'].parasite_drag_coefficient
    cd_p_wing      = drag_breakdown.parasite['main_wing'].parasite_drag_coefficient
    cd_tot         = drag_breakdown.total
    
    
    (cd_c_r, cd_i_r, cd_m_r, cd_m_fuse_base_r, cd_m_fuse_up_r, cd_m_nac_base_r, cd_m_ctrl_r, cd_p_fuse_r, cd_p_wing_r, cd_tot_r) = reg_values()
    
    drag_tests = Data()
    drag_tests.cd_c = np.abs((cd_c-cd_c_r)/cd_c)
    drag_tests.cd_i = np.abs((cd_i-cd_i_r)/cd_i)
    drag_tests.cd_m = np.abs((cd_m-cd_m_r)/cd_m)
    ## Commented lines represent values not set by current drag functions, but to be recreated in the future
    # Line below is not normalized since regression values are 0, insert commented line if this changes
    # drag_tests.cd_m_fuse_base = np.abs((cd_m_fuse_base-cd_m_fuse_base_r)) # np.abs((cd_m_fuse_base-cd_m_fuse_base_r)/cd_m_fuse_base)
    # drag_tests.cd_m_fuse_up   = np.abs((cd_m_fuse_up - cd_m_fuse_up_r)/cd_m_fuse_up)
    # drag_tests.cd_m_ctrl      = np.abs((cd_m_ctrl - cd_m_ctrl_r)/cd_m_ctrl)
    drag_tests.cd_p_fuse      = np.abs((cd_p_fuse - cd_p_fuse_r)/cd_p_fuse)
    drag_tests.cd_p_wing      = np.abs((cd_p_wing - cd_p_wing_r)/cd_p_wing)
    drag_tests.cd_tot         = np.abs((cd_tot - cd_tot_r)/cd_tot)
    
    print '\nCompute Drag Test Results\n'
    #print drag_tests
    
    for i, tests in drag_tests.items():
        assert(np.max(tests)<1e-4),'Aero regression test failed at ' + i
if __name__ == '__main__':
    #(conditions, configuration, geometry, test_num) = main()
    main()
    
    print 'Aero regression test passed!'
    
    ## --------------------------------------------------------------------
    ## Drag Polar
    ## --------------------------------------------------------------------  
    
    # --------------------------------------------------------------------
    # Drag Polar
    # --------------------------------------------------------------------
    
    # initialize the vehicle
    vehicle = vehicle_setup() 
    for wing in vehicle.wings:
        wing.areas.wetted   = 2.0 * wing.areas.reference
        wing.areas.exposed  = 0.8 * wing.areas.wetted
        wing.areas.affected = 0.6 * wing.areas.wetted  
        
        
    # initalize the aero model
    aerodynamics = SUAVE.Analyses.Aerodynamics.Fidelity_Zero()
    aerodynamics.geometry = vehicle
    
    ## modify inviscid wings - linear model
    #inviscid_wings = SUAVE.Analyses.Aerodynamics.Linear_Lift()
    #inviscid_wings.settings.slope_correction_coefficient = 1.04
    #inviscid_wings.settings.zero_lift_coefficient = 2.*np.pi* 3.1 * Units.deg    
    #aerodynamics.process.compute.lift.inviscid_wings = inviscid_wings
Beispiel #5
0
def main():

    # initialize the vehicle
    vehicle = vehicle_setup()
    for wing in vehicle.wings:
        wing.areas.wetted = 2.0 * wing.areas.reference
        wing.areas.exposed = 0.8 * wing.areas.wetted
        wing.areas.affected = 0.6 * wing.areas.wetted

    # initalize the aero model
    aerodynamics = SUAVE.Analyses.Aerodynamics.Fidelity_Zero()
    aerodynamics.geometry = vehicle

    aerodynamics.initialize()

    #no of test points
    test_num = 11

    #specify the angle of attack
    angle_of_attacks = np.linspace(-.174, .174, test_num)[:,
                                                          None]  #* Units.deg

    # Cruise conditions (except Mach number)
    state = SUAVE.Analyses.Mission.Segments.Conditions.State()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics(
    )

    state.expand_rows(test_num)

    # --------------------------------------------------------------------
    # Initialize variables needed for CL and CD calculations
    # Use a seeded random order for values
    # --------------------------------------------------------------------

    random.seed(1)
    Mc = np.linspace(0.05, 0.9, test_num)
    random.shuffle(Mc)
    rho = np.linspace(0.3, 1.3, test_num)
    random.shuffle(rho)
    mu = np.linspace(5 * 10**-6, 20 * 10**-6, test_num)
    random.shuffle(mu)
    T = np.linspace(200, 300, test_num)
    random.shuffle(T)
    pressure = np.linspace(10**5, 10**6, test_num)

    # Changed after to preserve seed for initial testing
    Mc = Mc[:, None]
    rho = rho[:, None]
    mu = mu[:, None]
    T = T[:, None]
    pressure = pressure[:, None]

    state.conditions.freestream.mach_number = Mc
    state.conditions.freestream.density = rho
    state.conditions.freestream.dynamic_viscosity = mu
    state.conditions.freestream.temperature = T
    state.conditions.freestream.pressure = pressure

    state.conditions.aerodynamics.angle_of_attack = angle_of_attacks

    # --------------------------------------------------------------------
    # Surrogate
    # --------------------------------------------------------------------

    #call the aero model
    results = aerodynamics.evaluate(state)

    #build a polar for the markup aero
    polar = Data()
    CL = results.lift.total
    CD = results.drag.total
    polar.lift = CL
    polar.drag = CD

    # --------------------------------------------------------------------
    # Test compute Lift
    # --------------------------------------------------------------------

    #compute_aircraft_lift(conditions, configuration, geometry)

    lift = state.conditions.aerodynamics.lift_coefficient
    lift_r = np.array([
        -2.42489437, -0.90696416, -0.53991953, -0.3044834, -0.03710598,
        0.31061936, 0.52106899, 0.77407765, 1.22389024, 1.86240501, 1.54587835
    ])[:, None]

    lift_test = np.abs((lift - lift_r) / lift)

    print '\nCompute Lift Test Results\n'
    #print lift_test

    assert (np.max(lift_test) <
            1e-4), 'Aero regression failed at compute lift test'

    # --------------------------------------------------------------------
    # Test compute drag
    # --------------------------------------------------------------------

    #compute_aircraft_drag(conditions, configuration, geometry)

    # Pull calculated values
    drag_breakdown = state.conditions.aerodynamics.drag_breakdown

    # Only one wing is evaluated since they rely on the same function
    cd_c = drag_breakdown.compressible['main_wing'].compressibility_drag
    cd_i = drag_breakdown.induced.total
    cd_m = drag_breakdown.miscellaneous.total
    # cd_m_fuse_base = drag_breakdown.miscellaneous.fuselage_base
    # cd_m_fuse_up   = drag_breakdown.miscellaneous.fuselage_upsweep
    # cd_m_nac_base  = drag_breakdown.miscellaneous.nacelle_base['turbo_fan']
    # cd_m_ctrl      = drag_breakdown.miscellaneous.control_gaps
    cd_p_fuse = drag_breakdown.parasite['fuselage'].parasite_drag_coefficient
    cd_p_wing = drag_breakdown.parasite['main_wing'].parasite_drag_coefficient
    cd_tot = drag_breakdown.total

    (cd_c_r, cd_i_r, cd_m_r, cd_m_fuse_base_r, cd_m_fuse_up_r, cd_m_nac_base_r,
     cd_m_ctrl_r, cd_p_fuse_r, cd_p_wing_r, cd_tot_r) = reg_values()

    drag_tests = Data()
    drag_tests.cd_c = np.abs((cd_c - cd_c_r) / cd_c)
    drag_tests.cd_i = np.abs((cd_i - cd_i_r) / cd_i)
    drag_tests.cd_m = np.abs((cd_m - cd_m_r) / cd_m)
    ## Commented lines represent values not set by current drag functions, but to be recreated in the future
    # Line below is not normalized since regression values are 0, insert commented line if this changes
    # drag_tests.cd_m_fuse_base = np.abs((cd_m_fuse_base-cd_m_fuse_base_r)) # np.abs((cd_m_fuse_base-cd_m_fuse_base_r)/cd_m_fuse_base)
    # drag_tests.cd_m_fuse_up   = np.abs((cd_m_fuse_up - cd_m_fuse_up_r)/cd_m_fuse_up)
    # drag_tests.cd_m_ctrl      = np.abs((cd_m_ctrl - cd_m_ctrl_r)/cd_m_ctrl)
    drag_tests.cd_p_fuse = np.abs((cd_p_fuse - cd_p_fuse_r) / cd_p_fuse)
    drag_tests.cd_p_wing = np.abs((cd_p_wing - cd_p_wing_r) / cd_p_wing)
    drag_tests.cd_tot = np.abs((cd_tot - cd_tot_r) / cd_tot)

    print '\nCompute Drag Test Results\n'
    #print drag_tests

    for i, tests in drag_tests.items():
        assert (np.max(tests) < 1e-4), 'Aero regression test failed at ' + i
Beispiel #6
0
if __name__ == '__main__':
    #(conditions, configuration, geometry, test_num) = main()
    main()

    print 'Aero regression test passed!'

    ## --------------------------------------------------------------------
    ## Drag Polar
    ## --------------------------------------------------------------------

    # --------------------------------------------------------------------
    # Drag Polar
    # --------------------------------------------------------------------

    # initialize the vehicle
    vehicle = vehicle_setup()
    for wing in vehicle.wings:
        wing.areas.wetted = 2.0 * wing.areas.reference
        wing.areas.exposed = 0.8 * wing.areas.wetted
        wing.areas.affected = 0.6 * wing.areas.wetted

    # initalize the aero model
    aerodynamics = SUAVE.Analyses.Aerodynamics.Fidelity_Zero()
    aerodynamics.geometry = vehicle

    ## modify inviscid wings - linear model
    #inviscid_wings = SUAVE.Analyses.Aerodynamics.Linear_Lift()
    #inviscid_wings.settings.slope_correction_coefficient = 1.04
    #inviscid_wings.settings.zero_lift_coefficient = 2.*np.pi* 3.1 * Units.deg
    #aerodynamics.process.compute.lift.inviscid_wings = inviscid_wings