Exemplo n.º 1
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.process.compute.lift.inviscid_wings = SUAVE.Analyses.Aerodynamics.Lifting_Line()
    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 pre-run random order for values
    # --------------------------------------------------------------------

    Mc = np.array([[0.9  ],
       [0.475],
       [0.05 ],
       [0.39 ],
       [0.815],
       [0.645],
       [0.305],
       [0.22 ],
       [0.56 ],
       [0.73 ],
       [0.135]])
    
    rho = np.array([[0.8],
           [1. ],
           [0.5],
           [1.1],
           [0.4],
           [1.3],
           [0.6],
           [0.3],
           [0.9],
           [0.7],
           [1.2]])
    
    mu = np.array([[1.85e-05],
           [1.55e-05],
           [1.40e-05],
           [1.10e-05],
           [2.00e-05],
           [8.00e-06],
           [6.50e-06],
           [9.50e-06],
           [1.70e-05],
           [1.25e-05],
           [5.00e-06]])
    
    T = np.array([[270.],
           [250.],
           [280.],
           [260.],
           [240.],
           [200.],
           [290.],
           [230.],
           [210.],
           [300.],
           [220.]])
    
    pressure = np.array([[ 100000.],
           [ 190000.],
           [ 280000.],
           [ 370000.],
           [ 460000.],
           [ 550000.],
           [ 640000.],
           [ 730000.],
           [ 820000.],
           [ 910000.],
           [1000000.]])
    
    re = np.array([[12819987.97468646],
           [ 9713525.47464844],
           [  599012.59815633],
           [12606549.94372309],
           [ 5062187.10214493],
           [29714816.00808047],
           [ 9611290.40694227],
           [ 2112171.68320523],
           [ 8612638.72342302],
           [14194381.78364854],
           [ 9633881.90543247]])    
      
    
    air = Air()
    a   = air.compute_speed_of_sound(T,pressure)
    re  = rho*a*Mc/mu

    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.freestream.reynolds_number = re
    
    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 
    CL = results.lift.total
    CD = results.drag.total
    
    # --------------------------------------------------------------------
    # Test compute Lift
    # --------------------------------------------------------------------
    
    #compute_aircraft_lift(conditions, configuration, geometry) 
    
    lift = state.conditions.aerodynamics.lift_coefficient
    lift_r = np.array([-2.92026278,-1.13251873,-0.72118981,-0.48215461,
                       -0.28934217, 0.14217826, 0.40422306, 0.67788365,
                       1.13167945, 1.77614421, 1.50398138])[:,None]

           
    print('lift = ', lift)
    
    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'    
Exemplo n.º 2
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]
    
    air = Air()
    a = air.compute_speed_of_sound(T,pressure)
    
    re = rho*a*Mc/mu

    
    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.freestream.reynolds_number = re
    
    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.17277359, -0.77516232, -0.41769607, -0.16530511, 0.19456498, 0.49425496, \
                        0.67481247, 0.93041268, 1.41531217, 2.1033578, 1.71822138])[:,None]
    
    print 'lift = ', lift
    
    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['turbofan']
    # 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
   
    print 'cd_m =', cd_m
    
   
    (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)
    for ii,cd in enumerate(drag_tests.cd_c):
        if np.isnan(cd):
            drag_tests.cd_c[ii] = np.abs((cd_c[ii]-cd_c_r[ii])/np.min(cd_c[cd_c!=0]))
    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 'cd_tot=', cd_tot
   
    for i, tests in drag_tests.items(): 
       
        assert(np.max(tests)<1e-4),'Aero regression test failed at ' + i
Exemplo n.º 3
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 pre-run random order for values
    # --------------------------------------------------------------------

    Mc = np.array([[0.9], [0.475], [0.05], [0.39], [0.815], [0.645], [0.305],
                   [0.22], [0.56], [0.73], [0.135]])

    rho = np.array([[0.8], [1.], [0.5], [1.1], [0.4], [1.3], [0.6], [0.3],
                    [0.9], [0.7], [1.2]])

    mu = np.array([[1.85e-05], [1.55e-05], [1.40e-05], [1.10e-05], [2.00e-05],
                   [8.00e-06], [6.50e-06], [9.50e-06], [1.70e-05], [1.25e-05],
                   [5.00e-06]])

    T = np.array([[270.], [250.], [280.], [260.], [240.], [200.], [290.],
                  [230.], [210.], [300.], [220.]])

    pressure = np.array([[100000.], [190000.], [280000.], [370000.], [460000.],
                         [550000.], [640000.], [730000.], [820000.], [910000.],
                         [1000000.]])

    re = np.array([[12819987.97468646], [9713525.47464844], [599012.59815633],
                   [12606549.94372309],
                   [5062187.10214493], [29714816.00808047], [9611290.40694227],
                   [2112171.68320523], [8612638.72342302], [14194381.78364854],
                   [9633881.90543247]])

    air = Air()
    a = air.compute_speed_of_sound(T, pressure)

    re = rho * a * Mc / mu

    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.freestream.reynolds_number = re

    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([
        -1.21776694, -0.48854139, -0.43529644, -0.34913149, -0.20409426,
        0.11639443, 0.35889527, 0.58542263, 0.88028747, 1.24354956, 1.26293499
    ])[:, None]

    print('lift = ', lift)

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

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

    assert (np.max(lift_test) <
            1e-6), '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['turbofan']
    # 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

    print('cd_m =', cd_m)

    (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)
    for ii, cd in enumerate(drag_tests.cd_c):
        if np.isnan(cd):
            drag_tests.cd_c[ii] = np.abs(
                (cd_c[ii] - cd_c_r[ii]) / np.min(cd_c[cd_c != 0]))
    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('cd_tot=', cd_tot)

    for i, tests in list(drag_tests.items()):

        assert (np.max(tests) < 1e-4), 'Aero regression test failed at ' + i
Exemplo n.º 4
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.process.compute.lift.inviscid_wings = SUAVE.Analyses.Aerodynamics.Lifting_Line()
    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 pre-run random order for values
    # --------------------------------------------------------------------

    Mc = np.array([[0.9  ],
       [0.475],
       [0.05 ],
       [0.39 ],
       [0.815],
       [0.645],
       [0.305],
       [0.22 ],
       [0.56 ],
       [0.73 ],
       [0.135]])
    
    rho = np.array([[0.8],
           [1. ],
           [0.5],
           [1.1],
           [0.4],
           [1.3],
           [0.6],
           [0.3],
           [0.9],
           [0.7],
           [1.2]])
    
    mu = np.array([[1.85e-05],
           [1.55e-05],
           [1.40e-05],
           [1.10e-05],
           [2.00e-05],
           [8.00e-06],
           [6.50e-06],
           [9.50e-06],
           [1.70e-05],
           [1.25e-05],
           [5.00e-06]])
    
    T = np.array([[270.],
           [250.],
           [280.],
           [260.],
           [240.],
           [200.],
           [290.],
           [230.],
           [210.],
           [300.],
           [220.]])
    
    pressure = np.array([[ 100000.],
           [ 190000.],
           [ 280000.],
           [ 370000.],
           [ 460000.],
           [ 550000.],
           [ 640000.],
           [ 730000.],
           [ 820000.],
           [ 910000.],
           [1000000.]])
    
    re = np.array([[12819987.97468646],
           [ 9713525.47464844],
           [  599012.59815633],
           [12606549.94372309],
           [ 5062187.10214493],
           [29714816.00808047],
           [ 9611290.40694227],
           [ 2112171.68320523],
           [ 8612638.72342302],
           [14194381.78364854],
           [ 9633881.90543247]])    
      
    
    air = Air()
    a   = air.compute_speed_of_sound(T,pressure)
    re  = rho*a*Mc/mu

    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.freestream.reynolds_number = re
    
    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 
    CL = results.lift.total
    CD = results.drag.total
    
    # --------------------------------------------------------------------
    # Test compute Lift
    # --------------------------------------------------------------------
    
    #compute_aircraft_lift(conditions, configuration, geometry) 
    
    lift = state.conditions.aerodynamics.lift_coefficient
    lift_r = np.array([-2.84689226, -1.06501674, -0.63426096, -0.35809118, -0.04487569,
        0.36343181, 0.61055156, 0.90742419, 1.43504496,  2.18401103,  1.81298486])[:,None]
    
    print('lift = ', lift)
    
    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'    
Exemplo n.º 5
0
def main():

    # initialize the vehicle
    vehicle = vehicle_setup()

    # initalize the aero model
    aerodynamics = SUAVE.Analyses.Aerodynamics.Supersonic_Zero()
    aerodynamics.geometry = vehicle
    aerodynamics.settings.drag_coefficient_increment = 0.0000
    aerodynamics.settings.span_efficiency = 0.95
    aerodynamics.settings.wave_drag_type = 'Sears-Haack'
    aerodynamics.settings.volume_wave_drag_scaling = 2.3  # calibrated to Concorde results

    aerodynamics.initialize()

    #no of test points
    test_num = 3

    #specify the angle of attack
    angle_of_attacks = np.linspace(-.0174, .0174 * 3,
                                   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 pre-run random order for values
    # --------------------------------------------------------------------

    Mc = np.array([[1.03], [1.5], [2.0]])

    rho = np.array([[0.16], [0.16], [0.16]])

    mu = np.array([[1.42e-05], [1.42e-05], [1.42e-05]])

    T = np.array([[217.], [217.], [217.]])

    pressure = np.array([[10000.], [10000.], [10000.]])

    re = np.array([[6.0e6], [6.0e6], [6.0e6]])

    air = Air()
    a = air.compute_speed_of_sound(T, pressure)

    re = rho * a * Mc / mu

    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.freestream.reynolds_number = re

    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

    # load older results
    #save_results(polar)
    old_polar = load_results()

    # check the results
    check_results(polar, old_polar)

    return
Exemplo n.º 6
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]

    air = Air()
    a = air.compute_speed_of_sound(T, pressure)

    re = rho * a * Mc / mu

    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.freestream.reynolds_number = re

    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.17753919,
        -0.7768714,
        -0.41862788,
        -0.16569318,
        0.1949377,
        0.49528782,
        0.67624325,
        0.93239723,
        1.41834084,
        2.1078681,
        1.72191103,
    ])[:, None]

    print 'lift = ', lift

    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['turbofan']
    # 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

    print 'cd_m =', cd_m

    (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 'cd_tot=', cd_tot

    for i, tests in drag_tests.items():

        assert (np.max(tests) < 1e-4), 'Aero regression test failed at ' + i
Exemplo n.º 7
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.settings.number_spanwise_vortices  = 5
    aerodynamics.settings.number_chordwise_vortices = 2
    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 pre-run random order for values
    # --------------------------------------------------------------------

    Mc = np.array([[0.9  ],
       [0.475],
       [0.05 ],
       [0.39 ],
       [0.815],
       [0.645],
       [0.305],
       [0.22 ],
       [0.56 ],
       [0.73 ],
       [0.135]])
    
    rho = np.array([[0.8],
           [1. ],
           [0.5],
           [1.1],
           [0.4],
           [1.3],
           [0.6],
           [0.3],
           [0.9],
           [0.7],
           [1.2]])
    
    mu = np.array([[1.85e-05],
           [1.55e-05],
           [1.40e-05],
           [1.10e-05],
           [2.00e-05],
           [8.00e-06],
           [6.50e-06],
           [9.50e-06],
           [1.70e-05],
           [1.25e-05],
           [5.00e-06]])
    
    T = np.array([[270.],
           [250.],
           [280.],
           [260.],
           [240.],
           [200.],
           [290.],
           [230.],
           [210.],
           [300.],
           [220.]])
    
    pressure = np.array([[ 100000.],
           [ 190000.],
           [ 280000.],
           [ 370000.],
           [ 460000.],
           [ 550000.],
           [ 640000.],
           [ 730000.],
           [ 820000.],
           [ 910000.],
           [1000000.]])
    
    re = np.array([[12819987.97468646],
           [ 9713525.47464844],
           [  599012.59815633],
           [12606549.94372309],
           [ 5062187.10214493],
           [29714816.00808047],
           [ 9611290.40694227],
           [ 2112171.68320523],
           [ 8612638.72342302],
           [14194381.78364854],
           [ 9633881.90543247]])    
    
    air = Air()
    a = air.compute_speed_of_sound(T,pressure)
    
    re = rho*a*Mc/mu

    
    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.freestream.reynolds_number = re
    
    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
    
    print('lift = \n', lift)
    print('\nCompute Lift Test Results\n')
    #print 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['turbofan']
    # 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
   
    print('cd_m =\n', cd_m)
    
    #drag_tests = Data()
    ## 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)
    
    print('\nCompute Drag Test Results\n')    
    print('cd_tot=', cd_tot)
    
    # --------------------------------------------------------------------
    # Process All Results 
    # --------------------------------------------------------------------
    results            = make_results_object(lift, cd_c, cd_i, cd_m, cd_p_fuse, cd_p_wing, cd_tot)
    
    save_results(results, SAVE=False)
    results_regression = load_results()
    
    test_results(results, results_regression)
    
    #return conditions, configuration, geometry, test_num
    return
Exemplo n.º 8
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.process.compute.lift.inviscid_wings = SUAVE.Analyses.Aerodynamics.Lifting_Line()
    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)
    rho = np.linspace(0.3,1.3,test_num)
    mu  = np.linspace(5*10**-6,20*10**-6,test_num)
    T   = np.linspace(200,300,test_num)
    pressure = np.linspace(10**5,10**6,test_num)
    
    random.shuffle(Mc)
    random.shuffle(rho)
    random.shuffle(mu)
    random.shuffle(T)
    
    # Changed after to preserve seed for initial testing
    Mc  = Mc[:,None]
    rho = rho[:,None]
    mu  = mu[:,None]
    T   = T[:,None]
    pressure = pressure[:,None]
    
    air = Air()
    a   = air.compute_speed_of_sound(T,pressure)
    re  = rho*a*Mc/mu

    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.freestream.reynolds_number = re
    
    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 
    CL = results.lift.total
    CD = results.drag.total
    
    # --------------------------------------------------------------------
    # Test compute Lift
    # --------------------------------------------------------------------
    
    #compute_aircraft_lift(conditions, configuration, geometry) 
    
    lift = state.conditions.aerodynamics.lift_coefficient
    lift_r = np.array([-2.84689226, -1.06501674, -0.63426096, -0.35809118, -0.04487569,
        0.36343181, 0.61055156, 0.90742419, 1.43504496,  2.18401103,  1.81298486])[:,None]
    
    print 'lift = ', lift
    
    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'    
Exemplo n.º 9
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.process.compute.lift.inviscid_wings = SUAVE.Analyses.Aerodynamics.Lifting_Line(
    )
    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)
    rho = np.linspace(0.3, 1.3, test_num)
    mu = np.linspace(5 * 10**-6, 20 * 10**-6, test_num)
    T = np.linspace(200, 300, test_num)
    pressure = np.linspace(10**5, 10**6, test_num)

    random.shuffle(Mc)
    random.shuffle(rho)
    random.shuffle(mu)
    random.shuffle(T)

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

    air = Air()
    a = air.compute_speed_of_sound(T, pressure)
    re = rho * a * Mc / mu

    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.freestream.reynolds_number = re

    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
    CL = results.lift.total
    CD = results.drag.total

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

    #compute_aircraft_lift(conditions, configuration, geometry)

    lift = state.conditions.aerodynamics.lift_coefficient
    lift_r = np.array([
        -2.84689226, -1.06501674, -0.63426096, -0.35809118, -0.04487569,
        0.36343181, 0.61055156, 0.90742419, 1.43504496, 2.18401103, 1.81298486
    ])[:, None]

    print 'lift = ', lift

    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'