def main(): #initialize the problem nexus = Nexus() vehicle = vehicle_setup() nexus.vehicle_configurations = configs_setup(vehicle) nexus.analyses = Analyses.setup(nexus.vehicle_configurations) nexus.missions = Missions.setup(nexus.analyses) #problem = Data() #nexus.optimization_problem = problem nexus.procedure = setup() nexus.sizing_loop = Sizing_Loop() nexus.total_number_of_iterations = 0 evaluate_problem(nexus) results = nexus.results err = nexus.sizing_loop.norm_error err_true = 0.00975078 #for 1E-2 tol error = abs((err-err_true)/err) print 'error = ', error assert(error<1e-5), 'sizing loop regression failed' #output=nexus._really_evaluate() #run; use optimization setup without inputs return
def main(): vehicle = vehicle_setup() configs = configs_setup(vehicle) analyses = mission_B737.analyses_setup(configs) mission = mission_setup(configs,analyses) configs.finalize() analyses.finalize() results = mission.evaluate() results = results.merged() plot_results(results) distance_regression = 4317710.33719722 distance_calc = results.conditions.frames.inertial.position_vector[-1,0] error_distance = abs((distance_regression - distance_calc )/distance_regression) assert error_distance < 1e-6 error_weight = abs(mission.target_landing_weight - results.conditions.weights.total_mass[-1,0]) print('landing weight error' , error_weight) assert error_weight < 1e-6 return
def main(): vehicle = vehicle_setup() configs = configs_setup(vehicle) analyses = mission_B737.analyses_setup(configs) mission = mission_setup(configs, analyses) configs.finalize() analyses.finalize() results = mission.evaluate() results = results.merged() plot_results(results) distance_regression = 4317710.33719722 distance_calc = results.conditions.frames.inertial.position_vector[-1, 0] error_distance = abs( (distance_regression - distance_calc) / distance_regression) assert error_distance < 1e-6 error_weight = abs(mission.target_landing_weight - results.conditions.weights.total_mass[-1, 0]) print('landing weight error', error_weight) assert error_weight < 1e-6 return
def main(): # vehicle data vehicle = vehicle_setup() configs = configs_setup(vehicle) # vehicle analyses configs_analyses = analyses_setup(configs) aerodynamics = SUAVE.Analyses.Aerodynamics.AVL() stability = SUAVE.Analyses.Stability.AVL() aerodynamics.geometry = copy.deepcopy(configs.cruise) stability.geometry = copy.deepcopy(configs.cruise) aerodynamics.process.compute.lift.inviscid.training_file = 'base_data_aerodynamics.txt' stability.training_file = 'base_data_stability.txt' configs_analyses.cruise.append(aerodynamics) configs_analyses.cruise.append(stability) # mission analyses mission = mission_setup(configs_analyses) missions_analyses = missions_setup(mission) analyses = SUAVE.Analyses.Analysis.Container() analyses.configs = configs_analyses analyses.missions = missions_analyses simple_sizing(configs, analyses) configs.finalize() analyses.finalize() # mission analysis mission = analyses.missions.base results = mission.evaluate() # lift coefficient check lift_coefficient = results.conditions.cruise.aerodynamics.lift_coefficient[ 0] lift_coefficient_true = 0.59571034 print lift_coefficient diff_CL = np.abs(lift_coefficient - lift_coefficient_true) print 'CL difference' print diff_CL assert np.abs((lift_coefficient - lift_coefficient_true) / lift_coefficient_true) < 1e-6 # moment coefficient check moment_coefficient = results.conditions.cruise.stability.static.CM[0][0] moment_coefficient_true = -0.62167644 print moment_coefficient diff_CM = np.abs(moment_coefficient - moment_coefficient_true) print 'CM difference' print diff_CM assert np.abs((moment_coefficient - moment_coefficient_true) / moment_coefficient_true) < 1e-6 return
def main(): # Setup for converging on weight vehicle = vehicle_setup() configs = configs_setup(vehicle) analyses = mission_B737.analyses_setup(configs) mission = mission_setup(configs, analyses) configs.finalize() analyses.finalize() results = mission.evaluate() results = results.merged() plot_results(results) distance_regression = 3804806.720225211 distance_calc = results.conditions.frames.inertial.position_vector[-1, 0] print('distance_calc = ', distance_calc) error_distance = abs( (distance_regression - distance_calc) / distance_regression) assert error_distance < 1e-6 error_weight = abs(mission.target_landing_weight - results.conditions.weights.total_mass[-1, 0]) print('landing weight error', error_weight) assert error_weight < 1e-6 # Setup for converging on SOC, using the stopped rotor vehicle vehicle_SR, analyses_SR = full_setup_SR() analyses_SR.finalize() mission_SR = analyses_SR.mission results_SR = mission_SR.evaluate() results_SR = results_SR.merged() distance_regression_SR = 101649.83535243798 distance_calc_SR = results_SR.conditions.frames.inertial.position_vector[ -1, 0] print('distance_calc_SR = ', distance_calc_SR) error_distance_SR = abs( (distance_regression_SR - distance_calc_SR) / distance_regression_SR) assert error_distance_SR < 1e-6 error_soc = abs( mission_SR.target_state_of_charge - results_SR.conditions.propulsion.battery_state_of_charge[-1, 0]) print('landing state of charge error', error_soc) assert error_soc < 1e-6 return
def main(): #initialize the problem nexus = Nexus() vehicle = vehicle_setup() nexus.vehicle_configurations = configs_setup(vehicle) nexus.analyses = Analyses.setup(nexus.vehicle_configurations) nexus.missions = Missions.setup(nexus.analyses) problem = Data() problem_inputs = np.array([ ['dummy', 1., (.1, 10.), 1., ' continuous', Units.less], ['dummy2', 2., (.1, 10.), 1., ' continuous', Units.less], ]) #create dummy inputs for optimization to test io problem.inputs = problem_inputs nexus.optimization_problem = problem nexus.procedure = setup() sizing_loop = Sizing_Loop() sizing_loop.output_filename = 'sizing_outputs.txt' nexus.sizing_loop = sizing_loop #create a fake array of data to test outputs write_sizing_outputs(sizing_loop, np.array([6.]), [5., 5.]) write_sizing_outputs(sizing_loop, np.array([12.]), [4., 1.]) write_sizing_outputs(sizing_loop, np.array([11.]), [1., 3.]) nexus.total_number_of_iterations = 0 evaluate_problem(nexus) results = nexus.results err = nexus.sizing_loop.norm_error err_true = 0.0008433474527249522 #for 1E-2 tol error = abs((err - err_true) / err_true) data_inputs, data_outputs, read_success = read_sizing_residuals( sizing_loop, problem.inputs) check_read_res = -0.06803060191281879 error_res = (data_outputs[1][0] - check_read_res) / check_read_res #remove files for later os.remove('sizing_outputs.txt') os.remove('y_err_values.txt') print('error = ', error) print('error_res = ', error_res) assert (error < 1e-4), 'sizing loop regression failed' assert (error_res < 1e-4), 'sizing loop io failed' return
def full_setup(): # vehicle data vehicle = vehicle_setup() configs = configs_setup(vehicle) # vehicle analyses configs_analyses = analyses_setup(configs) # mission analyses mission = mission_setup(configs_analyses) missions_analyses = missions_setup(mission) analyses = SUAVE.Analyses.Analysis.Container() analyses.configs = configs_analyses analyses.missions = missions_analyses return configs, analyses
def main(): vehicle = vehicle_setup() configs = 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 problem nexus = Nexus() vehicle = vehicle_setup() nexus.vehicle_configurations = configs_setup(vehicle) nexus.analyses = Analyses.setup(nexus.vehicle_configurations) nexus.missions = Missions.setup(nexus.analyses) nexus.procedure = setup() nexus.sizing_loop = Sizing_Loop() nexus.total_number_of_iterations = 0 evaluate_problem(nexus) results = nexus.results err = nexus.sizing_loop.norm_error err_true = 0.0096907307307155348 #for 1E-2 tol error = abs((err_true - err) / err_true) print 'error = ', error assert (error < 1e-6), 'sizing loop regression failed' return
def main(): vehicle = vehicle_setup() configs = 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 problem nexus = Nexus() vehicle = vehicle_setup() nexus.vehicle_configurations = configs_setup(vehicle) nexus.analyses = Analyses.setup(nexus.vehicle_configurations) nexus.missions = Missions.setup(nexus.analyses) nexus.procedure = setup() nexus.sizing_loop = Sizing_Loop() nexus.total_number_of_iterations = 0 evaluate_problem(nexus) results = nexus.results err = nexus.sizing_loop.norm_error err_true = 0.0096907307307155348#for 1E-2 tol error = abs((err_true-err)/err_true) print 'error = ', error assert(error<1e-6), 'sizing loop regression failed' return
def main(): # vehicle data vehicle = vehicle_setup() configs = configs_setup(vehicle) # vehicle analyses configs_analyses = analyses_setup(configs) # append AVL aerodynamic analysis aerodynamics = SUAVE.Analyses.Aerodynamics.AVL() aerodynamics.process.compute.lift.inviscid.regression_flag = True aerodynamics.process.compute.lift.inviscid.keep_files = True aerodynamics.geometry = copy.deepcopy(configs.cruise) aerodynamics.process.compute.lift.inviscid.training_file = 'cruise_data_aerodynamics.txt' configs_analyses.cruise.append(aerodynamics) # append AVL stability analysis stability = SUAVE.Analyses.Stability.AVL() stability.regression_flag = True stability.keep_files = True stability.geometry = copy.deepcopy(configs.cruise) stability.training_file = 'cruise_data_stability.txt' configs_analyses.cruise.append(stability) # ------------------------------------------------------------------ # Initialize the Mission # ------------------------------------------------------------------ mission = SUAVE.Analyses.Mission.Sequential_Segments() mission.tag = 'the_mission' #airport airport = SUAVE.Attributes.Airports.Airport() airport.altitude = 0.0 * Units.ft airport.delta_isa = 0.0 airport.atmosphere = SUAVE.Attributes.Atmospheres.Earth.US_Standard_1976() mission.airport = airport # unpack Segments module Segments = SUAVE.Analyses.Mission.Segments # base segment base_segment = Segments.Segment() # ------------------------------------------------------------------ # Cruise Segment: constant speed, constant altitude # ------------------------------------------------------------------ segment = Segments.Cruise.Constant_Speed_Constant_Altitude(base_segment) segment.tag = "cruise" segment.analyses.extend( configs_analyses.cruise ) segment.air_speed = 230. * Units['m/s'] segment.distance = 4000. * Units.km segment.altitude = 10.668 * Units.km segment.state.numerics.number_control_points = 4 # add to mission mission.append_segment(segment) missions_analyses = missions_setup(mission) analyses = SUAVE.Analyses.Analysis.Container() analyses.configs = configs_analyses analyses.missions = missions_analyses simple_sizing(configs, analyses) configs.finalize() analyses.finalize() # mission analysis mission = analyses.missions.base results = mission.evaluate() # lift coefficient check lift_coefficient = results.segments.cruise.conditions.aerodynamics.lift_coefficient[0][0] lift_coefficient_true = 0.6118979131570086 print(lift_coefficient) diff_CL = np.abs(lift_coefficient - lift_coefficient_true) print('CL difference') print(diff_CL) assert np.abs((lift_coefficient - lift_coefficient_true)/lift_coefficient_true) < 1e-6 # moment coefficient check moment_coefficient = results.segments.cruise.conditions.stability.static.CM[0][0] moment_coefficient_true = -0.6267104237340391 print(moment_coefficient) diff_CM = np.abs(moment_coefficient - moment_coefficient_true) print('CM difference') print(diff_CM) assert np.abs((moment_coefficient - moment_coefficient_true)/moment_coefficient_true) < 1e-6 return
def setup(): nexus = Nexus() problem = Data() nexus.optimization_problem = problem # ------------------------------------------------------------------- # Inputs # ------------------------------------------------------------------- # [ tag , initial, [lb,ub], scaling, units ] problem.inputs = np.array([ ['wing_area', 124.8, (70., 200.), 124.8, Units.meter**2], ['wing_aspect_ratio', 10.18, (5., 20.), 10.18, Units.less], ['wing_sweep', 25., (0., 35.), 25., Units.degrees], ['wing_thickness', 0.105, (0.07, 0.20), 0.105, Units.less], ['design_thrust', 52700., (10000., 70000.), 52700., Units.N], ['MTOW', 79090., (20000., 100000.), 79090., Units.kg], ['MZFW_ratio', 0.77, (0.6, 0.99), 0.77, Units.less], ['flap_takeoff_angle', 10., (0., 20.), 10., Units.degrees], ['flap_landing_angle', 40., (0., 50.), 40., Units.degrees], ['short_field_TOW', 64030., (20000., 100000.), 64030., Units.kg], ['design_TOW', 68520., (20000., 100000.), 68520., Units.kg], ['noise_takeoff_speed_increase', 10.0, (10., 20.), 10.0, Units.knots], ['noise_cutback_altitude', 304.8, (240., 400.), 304.8, Units.meter], ]) # ------------------------------------------------------------------- # Objective # ------------------------------------------------------------------- problem.objective = np.array([ ['noise_cumulative_margin', 17, Units.less], ]) # ------------------------------------------------------------------- # Constraints # ------------------------------------------------------------------- # [ tag, sense, edge, scaling, units ] problem.constraints = np.array([ ['MZFW consistency', '>', 0., 10, Units.less], ['design_range_fuel_margin', '>', 0., 10, Units.less], ['short_field_fuel_margin', '>', 0., 10, Units.less], ['max_range_fuel_margin', '>', 0., 10, Units.less], ['wing_span', '<', 35.9664, 35.9664, Units.less], ['noise_flyover_margin', '>', 0., 10., Units.less], ['noise_sideline_margin', '>', 0., 10., Units.less], ['noise_approach_margin', '>', 0., 10., Units.less], ['takeoff_field_length', '<', 1985., 1985., Units.meters], ['landing_field_length', '<', 1385., 1385., Units.meters], ['2nd_segment_climb_max_range', '>', 0.024, 0.024, Units.less], ['2nd_segment_climb_short_field', '>', 0.024, 0.024, Units.less], ['max_throttle', '<', 1., 1., Units.less], ['short_takeoff_field_length', '<', 1330., 1330., Units.meters], ['noise_cumulative_margin', '>', 10., 10., Units.less], ]) # ------------------------------------------------------------------- # Aliases # ------------------------------------------------------------------- problem.aliases = [ [ 'wing_area', [ 'vehicle_configurations.*.wings.main_wing.areas.reference', 'vehicle_configurations.*.reference_area' ] ], [ 'wing_aspect_ratio', 'vehicle_configurations.*.wings.main_wing.aspect_ratio' ], [ 'wing_incidence', 'vehicle_configurations.*.wings.main_wing.twists.root' ], [ 'wing_tip_twist', 'vehicle_configurations.*.wings.main_wing.twists.tip' ], [ 'wing_sweep', 'vehicle_configurations.*.wings.main_wing.sweeps.quarter_chord' ], [ 'wing_thickness', 'vehicle_configurations.*.wings.main_wing.thickness_to_chord' ], ['wing_taper', 'vehicle_configurations.*.wings.main_wing.taper'], [ 'wing_location', 'vehicle_configurations.*.wings.main_wing.origin[0]' ], [ 'horizontal_tail_area', 'vehicle_configurations.*.wings.horizontal_stabilizer.areas.reference' ], [ 'horizontal_tail_aspect_ratio', 'vehicle_configurations.*.wings.horizontal_stabilizer.aspect_ratio' ], [ 'vertical_tail_area', 'vehicle_configurations.*.wings.vertical_stabilizer.areas.reference' ], [ 'vertical_tail_aspect_ratio', 'vehicle_configurations.*.wings.vertical_stabilizer.aspect_ratio' ], [ 'design_thrust', 'vehicle_configurations.*.propulsors.turbofan.thrust.total_design' ], [ 'MTOW', [ 'vehicle_configurations.*.mass_properties.takeoff', 'vehicle_configurations.*.mass_properties.max_takeoff' ] ], ['design_TOW', 'vehicle_configurations.base.mass_properties.takeoff'], [ 'short_field_TOW', 'vehicle_configurations.short_field_takeoff.mass_properties.takeoff' ], [ 'flap_takeoff_angle', [ 'vehicle_configurations.takeoff.wings.main_wing.control_surfaces.flap.deflection', 'vehicle_configurations.short_field_takeoff.wings.main_wing.control_surfaces.flap.deflection' ] ], [ 'flap_landing_angle', 'vehicle_configurations.landing.wings.main_wing.control_surfaces.flap.deflection' ], [ 'slat_takeoff_angle', [ 'vehicle_configurations.takeoff.wings.main_wing.control_surfaces.slat.deflection', 'vehicle_configurations.short_field_takeoff.wings.main_wing.control_surfaces.slat.deflection' ] ], [ 'slat_landing_angle', 'vehicle_configurations.landing.wings.main_wing.control_surfaces.slat.deflection' ], [ 'wing_span', 'vehicle_configurations.base.wings.main_wing.spans.projected' ], ['noise_approach_margin', 'summary.noise_approach_margin'], ['noise_sideline_margin', 'summary.noise_sideline_margin'], ['noise_flyover_margin', 'summary.noise_flyover_margin'], ['static_stability', 'summary.static_stability'], [ 'vertical_tail_volume_coefficient', 'summary.vertical_tail_volume_coefficient' ], [ 'horizontal_tail_volume_coefficient', 'summary.horizontal_tail_volume_coefficient' ], ['wing_max_cl_norm', 'summary.maximum_cl_norm'], ['design_range_fuel_margin', 'summary.design_range_fuel_margin'], ['takeoff_field_length', 'summary.takeoff_field_length'], ['landing_field_length', 'summary.landing_field_length'], ['short_takeoff_field_length', 'summary.short_takeoff_field_length'], [ '2nd_segment_climb_max_range', 'summary.second_segment_climb_gradient_takeoff' ], [ '2nd_segment_climb_short_field', 'summary.second_segment_climb_gradient_short_field' ], ['max_throttle', 'summary.max_throttle'], ['short_field_fuel_margin', 'summary.short_field_fuel_margin'], ['max_range_fuel_margin', 'summary.max_range_fuel_margin'], ['max_range', 'missions.max_range_distance'], ['MZFW consistency', 'summary.MZFW_consistency'], ['MZFW_ratio', 'MZFW_ratio'], ['noise_takeoff_speed_increase', 'noise_V2_increase'], [ 'noise_cutback_altitude', 'missions.takeoff.segments.climb.altitude_end' ], ['noise_cumulative_margin', 'summary.noise_margin'], ['weighted_sum_objective', 'summary.weighted_sum_objective'], ] # ------------------------------------------------------------------- # Vehicles # ------------------------------------------------------------------- vehicle = vehicle_setup() nexus.vehicle_configurations = configs_setup(vehicle) # ------------------------------------------------------------------- # Analyses # ------------------------------------------------------------------- nexus.analyses = Analyses.setup(nexus.vehicle_configurations) # ------------------------------------------------------------------- # Missions # ------------------------------------------------------------------- nexus.missions = Missions.setup(nexus.analyses) # ------------------------------------------------------------------- # Procedure # ------------------------------------------------------------------- nexus.procedure = Procedure.setup() # ------------------------------------------------------------------- # Summary # ------------------------------------------------------------------- nexus.summary = Data() return nexus
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
def main(): vehicle = vehicle_setup() # Create the vehicle for testing 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 aerodynamics = SUAVE.Analyses.Aerodynamics.Supersonic_Zero() aerodynamics.geometry = vehicle aerodynamics.settings.drag_coefficient_increment = 0.0000 vehicle.aerodynamics_model = aerodynamics vehicle.aerodynamics_model.initialize() test_num = 11 # Length of arrays used in this test # -------------------------------------------------------------------- # Test Lift Surrogate # -------------------------------------------------------------------- AoA = np.linspace(-.174, .174, test_num)[:, None] # +- 10 degrees # 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) AoA = AoA.reshape(test_num, 1) Mc = Mc.reshape(test_num, 1) rho = np.linspace(0.3, 1.3, test_num) random.shuffle(rho) rho = rho.reshape(test_num, 1) mu = np.linspace(5 * 10**-6, 20 * 10**-6, test_num) random.shuffle(mu) mu = mu.reshape(test_num, 1) T = np.linspace(200, 300, test_num) random.shuffle(T) T = T.reshape(test_num, 1) pressure = np.linspace(10**5, 10**6, test_num) pressure = pressure.reshape(test_num, 1) 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 = AoA # -------------------------------------------------------------------- # 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 # Truth value 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_r = lift_r.reshape(test_num, 1) lift_test = np.abs((lift - lift_r) / lift) print '\nCompute Lift Test Results\n' print lift_test assert (np.max(lift_test) < 1e-4), 'Supersonic 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 print cd_c print cd_i print cd_m print cd_m_fuse_base print cd_m_fuse_up print cd_m_nac_base print cd_m_ctrl print cd_p_fuse print cd_p_wing print cd_tot # Truth values (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() cd_c_r = cd_c_r.reshape(test_num, 1) cd_i_r = cd_i_r.reshape(test_num, 1) cd_m_r = cd_m_r.reshape(test_num, 1) cd_m_fuse_base_r = cd_m_fuse_base_r.reshape(test_num, 1) cd_m_fuse_up_r = cd_m_fuse_up_r.reshape(test_num, 1) cd_m_nac_base_r = cd_m_nac_base_r.reshape(test_num, 1) cd_m_ctrl_r = cd_m_ctrl_r.reshape(test_num, 1) cd_p_fuse_r = cd_p_fuse_r.reshape(test_num, 1) cd_p_wing_r = cd_p_wing_r.reshape(test_num, 1) cd_tot_r = cd_tot_r.reshape(test_num, 1) 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) # 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), 'Supersonic Aero regression test failed at ' + i
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'
def main(): vehicle = vehicle_setup() weight = Tube_Wing.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 #includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 12977.803363592691 #includes cargo #22177.6377131 #without cargo actual.empty = 38688.08848390731 actual.wing = 6649.709658738429 actual.fuselage = 6642.061164271899 actual.propulsion = 6838.185174956626 actual.landing_gear = 3160.632 actual.systems = 13479.10479056802 actual.wt_furnish = 6431.80372889 actual.horizontal_tail = 1037.7414196819743 actual.vertical_tail = 629.0387683502595 actual.rudder = 251.61550734010382 # error calculations error = Data() error.payload = (actual.payload - weight.payload) / actual.payload error.pax = (actual.pax - weight.pax) / actual.pax error.bag = (actual.bag - weight.bag) / actual.bag error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - weight.fuselage) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion) / actual.propulsion error.landing_gear = (actual.landing_gear - weight.landing_gear) / actual.landing_gear error.systems = (actual.systems - weight.systems) / actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish) / actual.wt_furnish error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail) / actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail) / actual.vertical_tail error.rudder = (actual.rudder - weight.rudder) / actual.rudder print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in list(error.items()): assert (np.abs(v) < 1E-6) #General Aviation weights; note that values are taken from Raymer, #but there is a huge spread among the GA designs, so individual components #differ a good deal from the actual design vehicle = vehicle_setup_general_aviation() GTOW = vehicle.mass_properties.max_takeoff weight = General_Aviation.empty(vehicle) weight.fuel = vehicle.fuel.mass_properties.mass actual = Data() actual.bag = 0. actual.empty = 618.485310343 actual.fuel = 144.69596603 actual.wing = 124.673093906 actual.fuselage = 119.522072873 actual.propulsion = 194.477769922 #includes power plant and propeller, does not include fuel system actual.landing_gear = 44.8033840543 + 5.27975390045 actual.furnishing = 37.8341395817 actual.electrical = 36.7532226254 actual.control_systems = 14.8331955546 actual.fuel_systems = 15.6859717453 actual.systems = 108.096549345 error = Data() error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - weight.fuselage) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion) / actual.propulsion error.landing_gear = (actual.landing_gear - (weight.landing_gear_main + weight.landing_gear_nose)) / actual.landing_gear error.furnishing = (actual.furnishing - weight.systems_breakdown.furnish) / actual.furnishing error.electrical = (actual.electrical - weight.systems_breakdown.electrical ) / actual.electrical error.control_systems = ( actual.control_systems - weight.systems_breakdown.control_systems) / actual.control_systems error.fuel_systems = ( actual.fuel_systems - weight.systems_breakdown.fuel_system) / actual.fuel_systems error.systems = (actual.systems - weight.systems) / actual.systems print('actual.systems=', actual.systems) print('General Aviation Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in list(error.items()): assert (np.abs(v) < 1e-6) # BWB WEIGHTS vehicle = bwb_setup() weight = BWB.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 #includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 24860.343951919327 actual.empty = 26805.547895580676 actual.wing = 6576.679767012152 actual.fuselage = 1.0 actual.propulsion = 1413.8593105126783 actual.landing_gear = 3160.632 actual.systems = 15654.376818055844 actual.wt_furnish = 8205.349895589 # error calculations error = Data() error.payload = (actual.payload - weight.payload) / actual.payload error.pax = (actual.pax - weight.pax) / actual.pax error.bag = (actual.bag - weight.bag) / actual.bag error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - (weight.fuselage + 1.0)) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion) / actual.propulsion error.systems = (actual.systems - weight.systems) / actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish) / actual.wt_furnish print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in list(error.items()): assert (np.abs(v) < 1E-6) # Human Powered Aircraft vehicle = hp_setup() weight = HP.empty(vehicle) # regression values actual = Data() actual.empty = 138.02737768459374 actual.wing = 89.86286881794777 actual.fuselage = 1.0 actual.horizontal_tail = 31.749272074174737 actual.vertical_tail = 16.415236792471237 # error calculations error = Data() error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - (weight.fuselage + 1.0)) / actual.fuselage error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail) / actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail) / actual.vertical_tail print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in list(error.items()): assert (np.abs(v) < 1E-6) 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.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
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
def main(): vehicle = vehicle_setup() weight = Tube_Wing.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 #includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 12990.957450008464 #includes cargo #22177.6377131 #without cargo actual.empty = 38674.934397491539 actual.wing = 6649.7096587384294 actual.fuselage = 6642.0611642718986 actual.propulsion = 6838.1851749566231 actual.landing_gear = 3160.632 actual.systems = 13479.10479056802 actual.wt_furnish = 6431.80372889 actual.horizontal_tail = 1024.5873332662029 actual.vertical_tail = 629.03876835025949 actual.rudder = 251.61550734010382 # error calculations error = Data() error.payload = (actual.payload - weight.payload)/actual.payload error.pax = (actual.pax - weight.pax)/actual.pax error.bag = (actual.bag - weight.bag)/actual.bag error.fuel = (actual.fuel - weight.fuel)/actual.fuel error.empty = (actual.empty - weight.empty)/actual.empty error.wing = (actual.wing - weight.wing)/actual.wing error.fuselage = (actual.fuselage - weight.fuselage)/actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion)/actual.propulsion error.landing_gear = (actual.landing_gear - weight.landing_gear)/actual.landing_gear error.systems = (actual.systems - weight.systems)/actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish)/actual.wt_furnish error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail)/actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail)/actual.vertical_tail error.rudder = (actual.rudder - weight.rudder)/actual.rudder print 'Results (kg)' print weight print 'Relative Errors' print error for k,v in error.items(): assert(np.abs(v)<1E-6) #General Aviation weights; note that values are taken from Raymer, #but there is a huge spread among the GA designs, so individual components #differ a good deal from the actual design vehicle = vehicle_setup_general_aviation() GTOW = vehicle.mass_properties.max_takeoff weight = General_Aviation.empty(vehicle) weight.fuel = vehicle.fuel.mass_properties.mass actual = Data() actual.bag = 0. actual.empty = 618.485310343 actual.fuel = 144.69596603 actual.wing = 124.673093906 actual.fuselage = 119.522072873 actual.propulsion = 194.477769922 #includes power plant and propeller, does not include fuel system actual.landing_gear = 44.8033840543+5.27975390045 actual.furnishing = 37.8341395817 actual.electrical = 36.7532226254 actual.control_systems = 14.8331955546 actual.fuel_systems = 15.6859717453 actual.systems = 108.096549345 error = Data() error.fuel = (actual.fuel - weight.fuel)/actual.fuel error.empty = (actual.empty - weight.empty)/actual.empty error.wing = (actual.wing - weight.wing)/actual.wing error.fuselage = (actual.fuselage - weight.fuselage)/actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion)/actual.propulsion error.landing_gear = (actual.landing_gear - (weight.landing_gear_main+weight.landing_gear_nose))/actual.landing_gear error.furnishing = (actual.furnishing-weight.systems_breakdown.furnish)/actual.furnishing error.electrical = (actual.electrical-weight.systems_breakdown.electrical)/actual.electrical error.control_systems = (actual.control_systems-weight.systems_breakdown.control_systems)/actual.control_systems error.fuel_systems = (actual.fuel_systems-weight.systems_breakdown.fuel_system)/actual.fuel_systems error.systems = (actual.systems - weight.systems)/actual.systems print 'actual.systems=', actual.systems print 'General Aviation Results (kg)' print weight print 'Relative Errors' print error for k,v in error.items(): assert(np.abs(v)<1e-6) 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.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'
def main(): vehicle = vehicle_setup() # Create the vehicle for testing 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 aerodynamics = SUAVE.Analyses.Aerodynamics.Supersonic_Zero() aerodynamics.geometry = vehicle aerodynamics.settings.drag_coefficient_increment = 0.0000 vehicle.aerodynamics_model = aerodynamics vehicle.aerodynamics_model.initialize() test_num = 11 # Length of arrays used in this test # -------------------------------------------------------------------- # Test Lift Surrogate # -------------------------------------------------------------------- AoA = np.linspace(-.174,.174,test_num)[:,None] # +- 10 degrees # 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) AoA = AoA.reshape(test_num,1) Mc = Mc.reshape(test_num,1) rho = np.linspace(0.3,1.3,test_num) random.shuffle(rho) rho = rho.reshape(test_num,1) mu = np.linspace(5*10**-6,20*10**-6,test_num) random.shuffle(mu) mu = mu.reshape(test_num,1) T = np.linspace(200,300,test_num) random.shuffle(T) T = T.reshape(test_num,1) pressure = np.linspace(10**5,10**6,test_num) pressure = pressure.reshape(test_num,1) 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 = AoA # -------------------------------------------------------------------- # 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 # Truth value 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_r = lift_r.reshape(test_num,1) lift_test = np.abs((lift-lift_r)/lift) print('\nCompute Lift Test Results\n') print(lift_test) assert(np.max(lift_test)<1e-4), 'Supersonic 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 print(cd_c) print(cd_i) print(cd_m) print(cd_m_fuse_base) print(cd_m_fuse_up) print(cd_m_nac_base) print(cd_m_ctrl) print(cd_p_fuse) print(cd_p_wing) print(cd_tot) # Truth values (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() cd_c_r = cd_c_r.reshape(test_num,1) cd_i_r = cd_i_r.reshape(test_num,1) cd_m_r = cd_m_r.reshape(test_num,1) cd_m_fuse_base_r = cd_m_fuse_base_r.reshape(test_num,1) cd_m_fuse_up_r = cd_m_fuse_up_r.reshape(test_num,1) cd_m_nac_base_r = cd_m_nac_base_r.reshape(test_num,1) cd_m_ctrl_r = cd_m_ctrl_r.reshape(test_num,1) cd_p_fuse_r = cd_p_fuse_r.reshape(test_num,1) cd_p_wing_r = cd_p_wing_r.reshape(test_num,1) cd_tot_r = cd_tot_r.reshape(test_num,1) 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) # 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 list(drag_tests.items()): assert(np.max(tests)<1e-4),'Supersonic Aero regression test failed at ' + i
if __name__ == '__main__': #(conditions, configuration, geometry, test_num) = main() main() print('Supersonic 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.Supersonic_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
def setup(): nexus = Nexus() problem = Data() nexus.optimization_problem = problem # ------------------------------------------------------------------- # Inputs # ------------------------------------------------------------------- # [ tag , initial, [lb,ub], scaling, units ] problem.inputs = np.array([ [ 'wing_area' , 124.8 , ( 70. , 200. ) , 124.8 , Units.meter**2], [ 'wing_aspect_ratio' , 10.18, ( 5. , 20. ) , 10.18, Units.less], [ 'wing_sweep' , 25. , ( 0. , 35. ) , 25. , Units.degrees], [ 'wing_thickness' , 0.105 , ( 0.07 , 0.20 ) , 0.105, Units.less], [ 'design_thrust' , 52700. , ( 10000. , 70000. ) , 52700. , Units.N], [ 'MTOW' , 79090. , ( 20000. ,100000. ) , 79090. , Units.kg], [ 'MZFW_ratio' , 0.77 , ( 0.6 , 0.99 ) , 0.77 , Units.less], [ 'flap_takeoff_angle' , 10. , ( 0. , 20. ) , 10. , Units.degrees], [ 'flap_landing_angle' , 40. , ( 0. , 50. ) , 40. , Units.degrees], [ 'short_field_TOW' , 64030. , ( 20000. ,100000. ) , 64030. , Units.kg], [ 'design_TOW' , 68520. , ( 20000. ,100000. ) , 68520. , Units.kg], [ 'noise_takeoff_speed_increase' , 10.0 , ( 10. , 20. ) , 10.0 , Units.knots], [ 'noise_cutback_altitude' , 304.8 , ( 240. , 400. ) , 304.8 , Units.meter], ]) # ------------------------------------------------------------------- # Objective # ------------------------------------------------------------------- problem.objective = np.array([ [ 'noise_cumulative_margin', 17, Units.less ], ]) # ------------------------------------------------------------------- # Constraints # ------------------------------------------------------------------- # [ tag, sense, edge, scaling, units ] problem.constraints = np.array([ [ 'MZFW consistency' , '>' , 0. , 10 , Units.less], [ 'design_range_fuel_margin' , '>', 0., 10, Units.less], [ 'short_field_fuel_margin' , '>' , 0. , 10, Units.less], [ 'max_range_fuel_margin' , '>' , 0. , 10, Units.less], [ 'wing_span' , '<', 35.9664, 35.9664, Units.less], [ 'noise_flyover_margin' , '>', 0. , 10., Units.less], [ 'noise_sideline_margin' , '>', 0. , 10. , Units.less], [ 'noise_approach_margin' , '>', 0., 10., Units.less], [ 'takeoff_field_length' , '<', 1985., 1985., Units.meters], [ 'landing_field_length' , '<', 1385., 1385., Units.meters], [ '2nd_segment_climb_max_range' , '>', 0.024, 0.024, Units.less], [ '2nd_segment_climb_short_field' , '>', 0.024, 0.024, Units.less], [ 'max_throttle' , '<', 1., 1., Units.less], [ 'short_takeoff_field_length' , '<', 1330., 1330., Units.meters], [ 'noise_cumulative_margin' , '>', 10., 10., Units.less], ]) # ------------------------------------------------------------------- # Aliases # ------------------------------------------------------------------- problem.aliases = [ [ 'wing_area' , ['vehicle_configurations.*.wings.main_wing.areas.reference', 'vehicle_configurations.*.reference_area' ]], [ 'wing_aspect_ratio' , 'vehicle_configurations.*.wings.main_wing.aspect_ratio' ], [ 'wing_incidence' , 'vehicle_configurations.*.wings.main_wing.twists.root' ], [ 'wing_tip_twist' , 'vehicle_configurations.*.wings.main_wing.twists.tip' ], [ 'wing_sweep' , 'vehicle_configurations.*.wings.main_wing.sweeps.quarter_chord' ], [ 'wing_thickness' , 'vehicle_configurations.*.wings.main_wing.thickness_to_chord' ], [ 'wing_taper' , 'vehicle_configurations.*.wings.main_wing.taper' ], [ 'wing_location' , 'vehicle_configurations.*.wings.main_wing.origin[0]' ], [ 'horizontal_tail_area' , 'vehicle_configurations.*.wings.horizontal_stabilizer.areas.reference'], [ 'horizontal_tail_aspect_ratio' , 'vehicle_configurations.*.wings.horizontal_stabilizer.aspect_ratio' ], [ 'vertical_tail_area' , 'vehicle_configurations.*.wings.vertical_stabilizer.areas.reference' ], [ 'vertical_tail_aspect_ratio' , 'vehicle_configurations.*.wings.vertical_stabilizer.aspect_ratio' ], [ 'design_thrust' , 'vehicle_configurations.*.propulsors.turbofan.thrust.total_design' ], [ 'MTOW' , ['vehicle_configurations.*.mass_properties.takeoff' , 'vehicle_configurations.*.mass_properties.max_takeoff' ]], [ 'design_TOW' , 'vehicle_configurations.base.mass_properties.takeoff' ], [ 'short_field_TOW' , 'vehicle_configurations.short_field_takeoff.mass_properties.takeoff' ], [ 'flap_takeoff_angle' , ['vehicle_configurations.takeoff.wings.main_wing.flaps.angle', 'vehicle_configurations.short_field_takeoff.wings.main_wing.flaps.angle']], [ 'flap_landing_angle' , 'vehicle_configurations.landing.wings.main_wing.flaps.angle' ], [ 'slat_takeoff_angle' , ['vehicle_configurations.takeoff.wings.main_wing.slats.angle', 'vehicle_configurations.short_field_takeoff.wings.main_wing.slats.angle']], [ 'slat_landing_angle' , 'vehicle_configurations.landing.wings.main_wing.slats.angle' ], [ 'wing_span' , 'vehicle_configurations.base.wings.main_wing.spans.projected' ], [ 'noise_approach_margin' , 'summary.noise_approach_margin' ], [ 'noise_sideline_margin' , 'summary.noise_sideline_margin' ], [ 'noise_flyover_margin' , 'summary.noise_flyover_margin' ], [ 'static_stability' , 'summary.static_stability' ], [ 'vertical_tail_volume_coefficient' , 'summary.vertical_tail_volume_coefficient' ], [ 'horizontal_tail_volume_coefficient', 'summary.horizontal_tail_volume_coefficient' ], [ 'wing_max_cl_norm' , 'summary.maximum_cl_norm' ], [ 'design_range_fuel_margin' , 'summary.design_range_fuel_margin' ], [ 'takeoff_field_length' , 'summary.takeoff_field_length' ], [ 'landing_field_length' , 'summary.landing_field_length' ], [ 'short_takeoff_field_length' , 'summary.short_takeoff_field_length' ], [ '2nd_segment_climb_max_range' , 'summary.second_segment_climb_gradient_takeoff' ], [ '2nd_segment_climb_short_field' , 'summary.second_segment_climb_gradient_short_field' ], [ 'max_throttle' , 'summary.max_throttle' ], [ 'short_field_fuel_margin' , 'summary.short_field_fuel_margin' ], [ 'max_range_fuel_margin' , 'summary.max_range_fuel_margin' ], [ 'max_range' , 'missions.max_range_distance' ], [ 'MZFW consistency' , 'summary.MZFW_consistency' ], [ 'MZFW_ratio' , 'MZFW_ratio' ], [ 'noise_takeoff_speed_increase' , 'noise_V2_increase' ], [ 'noise_cutback_altitude' , 'missions.takeoff.segments.climb.altitude_end' ], [ 'noise_cumulative_margin' , 'summary.noise_margin' ], [ 'weighted_sum_objective' , 'summary.weighted_sum_objective' ], ] # ------------------------------------------------------------------- # Vehicles # ------------------------------------------------------------------- vehicle = vehicle_setup() nexus.vehicle_configurations = configs_setup(vehicle) # ------------------------------------------------------------------- # Analyses # ------------------------------------------------------------------- nexus.analyses = Analyses.setup(nexus.vehicle_configurations) # ------------------------------------------------------------------- # Missions # ------------------------------------------------------------------- nexus.missions = Missions.setup(nexus.analyses) # ------------------------------------------------------------------- # Procedure # ------------------------------------------------------------------- nexus.procedure = Procedure.setup() # ------------------------------------------------------------------- # Summary # ------------------------------------------------------------------- nexus.summary = Data() return nexus
def main(): # vehicle data vehicle = vehicle_setup() configs = configs_setup(vehicle) # vehicle analyses configs_analyses = analyses_setup(configs) # append AVL aerodynamic analysis aerodynamics = SUAVE.Analyses.Aerodynamics.AVL() aerodynamics.process.compute.lift.inviscid.regression_flag = True aerodynamics.process.compute.lift.inviscid.keep_files = True aerodynamics.geometry = copy.deepcopy(configs.cruise) aerodynamics.process.compute.lift.inviscid.training_file = 'cruise_data_aerodynamics.txt' configs_analyses.cruise.append(aerodynamics) # append AVL stability analysis stability = SUAVE.Analyses.Stability.AVL() stability.regression_flag = True stability.keep_files = True stability.geometry = copy.deepcopy(configs.cruise) stability.training_file = 'cruise_data_stability.txt' configs_analyses.cruise.append(stability) # mission analyses mission = mission_setup(configs_analyses) missions_analyses = missions_setup(mission) analyses = SUAVE.Analyses.Analysis.Container() analyses.configs = configs_analyses analyses.missions = missions_analyses simple_sizing(configs, analyses) configs.finalize() analyses.finalize() # mission analysis mission = analyses.missions.base results = mission.evaluate() # lift coefficient check lift_coefficient = results.conditions.cruise.aerodynamics.lift_coefficient[0] lift_coefficient_true = 0.59495841 print lift_coefficient diff_CL = np.abs(lift_coefficient - lift_coefficient_true) print 'CL difference' print diff_CL assert np.abs((lift_coefficient - lift_coefficient_true)/lift_coefficient_true) < 1e-3 # moment coefficient check moment_coefficient = results.conditions.cruise.stability.static.CM[0][0] moment_coefficient_true = -0.620326644 print moment_coefficient diff_CM = np.abs(moment_coefficient - moment_coefficient_true) print 'CM difference' print diff_CM assert np.abs((moment_coefficient - moment_coefficient_true)/moment_coefficient_true) < 1e-3 return
def main(): vehicle = vehicle_setup() weight = Tube_Wing.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 #includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 12977.803363592691 #includes cargo #22177.6377131 #without cargo actual.empty = 38688.08848390731 actual.wing = 6649.709658738429 actual.fuselage = 6642.061164271899 actual.propulsion = 6838.185174956626 actual.landing_gear = 3160.632 actual.systems = 13479.10479056802 actual.wt_furnish = 6431.80372889 actual.horizontal_tail = 1037.7414196819743 actual.vertical_tail = 629.0387683502595 actual.rudder = 251.61550734010382 # error calculations error = Data() error.payload = (actual.payload - weight.payload)/actual.payload error.pax = (actual.pax - weight.pax)/actual.pax error.bag = (actual.bag - weight.bag)/actual.bag error.fuel = (actual.fuel - weight.fuel)/actual.fuel error.empty = (actual.empty - weight.empty)/actual.empty error.wing = (actual.wing - weight.wing)/actual.wing error.fuselage = (actual.fuselage - weight.fuselage)/actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion)/actual.propulsion error.landing_gear = (actual.landing_gear - weight.landing_gear)/actual.landing_gear error.systems = (actual.systems - weight.systems)/actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish)/actual.wt_furnish error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail)/actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail)/actual.vertical_tail error.rudder = (actual.rudder - weight.rudder)/actual.rudder print('Results (kg)') print(weight) print('Relative Errors') print(error) for k,v in list(error.items()): assert(np.abs(v)<1E-6) #General Aviation weights; note that values are taken from Raymer, #but there is a huge spread among the GA designs, so individual components #differ a good deal from the actual design vehicle = vehicle_setup_general_aviation() GTOW = vehicle.mass_properties.max_takeoff weight = General_Aviation.empty(vehicle) weight.fuel = vehicle.fuel.mass_properties.mass actual = Data() actual.bag = 0. actual.empty = 618.485310343 actual.fuel = 144.69596603 actual.wing = 124.673093906 actual.fuselage = 119.522072873 actual.propulsion = 194.477769922 #includes power plant and propeller, does not include fuel system actual.landing_gear = 44.8033840543+5.27975390045 actual.furnishing = 37.8341395817 actual.electrical = 36.7532226254 actual.control_systems = 14.8331955546 actual.fuel_systems = 15.6859717453 actual.systems = 108.096549345 error = Data() error.fuel = (actual.fuel - weight.fuel)/actual.fuel error.empty = (actual.empty - weight.empty)/actual.empty error.wing = (actual.wing - weight.wing)/actual.wing error.fuselage = (actual.fuselage - weight.fuselage)/actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion)/actual.propulsion error.landing_gear = (actual.landing_gear - (weight.landing_gear_main+weight.landing_gear_nose))/actual.landing_gear error.furnishing = (actual.furnishing-weight.systems_breakdown.furnish)/actual.furnishing error.electrical = (actual.electrical-weight.systems_breakdown.electrical)/actual.electrical error.control_systems = (actual.control_systems-weight.systems_breakdown.control_systems)/actual.control_systems error.fuel_systems = (actual.fuel_systems-weight.systems_breakdown.fuel_system)/actual.fuel_systems error.systems = (actual.systems - weight.systems)/actual.systems print('actual.systems=', actual.systems) print('General Aviation Results (kg)') print(weight) print('Relative Errors') print(error) for k,v in list(error.items()): assert(np.abs(v)<1e-6) # BWB WEIGHTS vehicle = bwb_setup() weight = BWB.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 #includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 24860.343951919327 actual.empty = 26805.547895580676 actual.wing = 6576.679767012152 actual.fuselage = 1.0 actual.propulsion = 1413.8593105126783 actual.landing_gear = 3160.632 actual.systems = 15654.376818055844 actual.wt_furnish = 8205.349895589 # error calculations error = Data() error.payload = (actual.payload - weight.payload)/actual.payload error.pax = (actual.pax - weight.pax)/actual.pax error.bag = (actual.bag - weight.bag)/actual.bag error.fuel = (actual.fuel - weight.fuel)/actual.fuel error.empty = (actual.empty - weight.empty)/actual.empty error.wing = (actual.wing - weight.wing)/actual.wing error.fuselage = (actual.fuselage - (weight.fuselage+1.0))/actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion)/actual.propulsion error.systems = (actual.systems - weight.systems)/actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish)/actual.wt_furnish print('Results (kg)') print(weight) print('Relative Errors') print(error) for k,v in list(error.items()): assert(np.abs(v)<1E-6) # Human Powered Aircraft vehicle = hp_setup() weight = HP.empty(vehicle) # regression values actual = Data() actual.empty = 138.02737768459374 actual.wing = 89.86286881794777 actual.fuselage = 1.0 actual.horizontal_tail = 31.749272074174737 actual.vertical_tail = 16.415236792471237 # error calculations error = Data() error.empty = (actual.empty - weight.empty)/actual.empty error.wing = (actual.wing - weight.wing)/actual.wing error.fuselage = (actual.fuselage - (weight.fuselage+1.0))/actual.fuselage error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail)/actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail)/actual.vertical_tail print('Results (kg)') print(weight) print('Relative Errors') print(error) for k,v in list(error.items()): assert(np.abs(v)<1E-6) 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.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'
def main(): # vehicle data vehicle = vehicle_setup() configs = configs_setup(vehicle) # vehicle analyses configs_analyses = analyses_setup(configs) run_new_regression = False # append AVL aerodynamic analysis aerodynamics = SUAVE.Analyses.Aerodynamics.AVL() aerodynamics.settings.number_spanwise_vortices = 30 aerodynamics.settings.keep_files = True aerodynamics.geometry = copy.deepcopy(configs.cruise) configs_analyses.cruise.append(aerodynamics) # append AVL stability analysis stability = SUAVE.Analyses.Stability.AVL() stability.settings.number_spanwise_vortices = 30 stability.settings.keep_files = True stability.geometry = copy.deepcopy(configs.cruise) if run_new_regression: # append AVL aerodynamic analysis aerodynamics.settings.regression_flag = False aerodynamics.process.compute.lift.inviscid.settings.filenames.avl_bin_name = 'CHANGE/TO/AVL/PATH' aerodynamics.settings.save_regression_results = True stability.settings.regression_flag = False stability.settings.save_regression_results = True stability.settings.filenames.avl_bin_name = 'CHANGE/TO/AVL/PATH' else: aerodynamics.settings.regression_flag = True aerodynamics.settings.save_regression_results = False aerodynamics.settings.training_file = 'cruise_aero_data.txt' stability.settings.regression_flag = True stability.settings.save_regression_results = False stability.training_file = 'cruise_stability_data.txt' configs_analyses.cruise.append(aerodynamics) configs_analyses.cruise.append(stability) # ------------------------------------------------------------------ # Initialize the Mission # ------------------------------------------------------------------ mission = SUAVE.Analyses.Mission.Sequential_Segments() mission.tag = 'the_mission' #airport airport = SUAVE.Attributes.Airports.Airport() airport.altitude = 0.0 * Units.ft airport.delta_isa = 0.0 airport.atmosphere = SUAVE.Attributes.Atmospheres.Earth.US_Standard_1976() mission.airport = airport # unpack Segments module Segments = SUAVE.Analyses.Mission.Segments # base segment base_segment = Segments.Segment() # ------------------------------------------------------------------ # Cruise Segment: constant speed, constant altitude # ------------------------------------------------------------------ segment = Segments.Cruise.Constant_Speed_Constant_Altitude(base_segment) segment.tag = "cruise" segment.analyses.extend(configs_analyses.cruise) segment.air_speed = 230. * Units['m/s'] segment.distance = 4000. * Units.km segment.altitude = 10.668 * Units.km segment.state.numerics.number_control_points = 4 # add to mission mission.append_segment(segment) missions_analyses = missions_setup(mission) analyses = SUAVE.Analyses.Analysis.Container() analyses.configs = configs_analyses analyses.missions = missions_analyses simple_sizing(configs, analyses) configs.finalize() analyses.finalize() # mission analysis mission = analyses.missions.base results = mission.evaluate() # lift coefficient check lift_coefficient = results.segments.cruise.conditions.aerodynamics.lift_coefficient[ 0][0] lift_coefficient_true = 0.6124936427552575 print(lift_coefficient) diff_CL = np.abs(lift_coefficient - lift_coefficient_true) print('CL difference') print(diff_CL) assert np.abs((lift_coefficient - lift_coefficient_true) / lift_coefficient_true) < 1e-6 # moment coefficient check moment_coefficient = results.segments.cruise.conditions.stability.static.CM[ 0][0] moment_coefficient_true = -0.5764235338199974 print(moment_coefficient) diff_CM = np.abs(moment_coefficient - moment_coefficient_true) print('CM difference') print(diff_CM) assert np.abs((moment_coefficient - moment_coefficient_true) / moment_coefficient_true) < 1e-6 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.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'
if __name__ == '__main__': #(conditions, configuration, geometry, test_num) = main() main() print 'Supersonic 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.Supersonic_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
def main(): vehicle = vehicle_setup() weight = Transport.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 # includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 16504.32206450931 # includes cargo #22177.6377131 #without cargo actual.empty = 35161.56978299069 actual.wing = 3461.869204335895 actual.fuselage = 6700.709511002648 actual.propulsion = 6838.185174956626 actual.landing_gear = 3160.632 actual.systems = 13390.723085494214 actual.wt_furnish = 6431.803728889001 actual.horizontal_tail = 728.7965315109458 actual.vertical_tail = 880.6542756903633 actual.rudder = 251.61550734010382 actual.nose_gear = 316.06320000000005 actual.main_gear = 2844.5688 # error calculations error = Data() error.payload = (actual.payload - weight.payload) / actual.payload error.pax = (actual.pax - weight.pax) / actual.pax error.bag = (actual.bag - weight.bag) / actual.bag error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - weight.fuselage) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion) / actual.propulsion error.nose_gear = (actual.nose_gear - weight.nose_gear) / actual.nose_gear error.main_gear = (actual.main_gear - weight.main_gear) / actual.main_gear error.systems = (actual.systems - weight.systems) / actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish) / actual.wt_furnish error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail) / actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail) / actual.vertical_tail error.rudder = (actual.rudder - weight.rudder) / actual.rudder print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in list(error.items()): assert (np.abs(v) < 1E-6) #General Aviation weights; note that values are taken from Raymer, #but there is a huge spread among the GA designs, so individual components #differ a good deal from the actual design vehicle = vehicle_setup_general_aviation() GTOW = vehicle.mass_properties.max_takeoff weight = General_Aviation.empty(vehicle) weight.fuel = vehicle.fuel.mass_properties.mass actual = Data() actual.bag = 0. actual.empty = 720.1834370409678 actual.fuel = 144.69596603 actual.wing = 152.25407206578896 actual.fuselage = 126.7421108234472 actual.propulsion = 224.40728553408732 actual.landing_gear = 67.81320006645151 actual.furnishing = 37.8341395817 actual.electrical = 41.28649399649684 actual.control_systems = 20.51671046011007 actual.fuel_systems = 20.173688786768366 actual.systems = 122.8010526627288 error = Data() error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - weight.fuselage) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion) / actual.propulsion error.landing_gear = (actual.landing_gear - (weight.landing_gear_main + weight.landing_gear_nose)) / actual.landing_gear error.furnishing = (actual.furnishing - weight.systems_breakdown.furnish) / actual.furnishing error.electrical = (actual.electrical - weight.systems_breakdown.electrical ) / actual.electrical error.control_systems = ( actual.control_systems - weight.systems_breakdown.control_systems) / actual.control_systems error.fuel_systems = ( actual.fuel_systems - weight.systems_breakdown.fuel_system) / actual.fuel_systems error.systems = (actual.systems - weight.systems) / actual.systems print('actual.systems=', actual.systems) print('General Aviation Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in list(error.items()): assert (np.abs(v) < 1e-6) # BWB WEIGHTS vehicle = bwb_setup() weight = BWB.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 #includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 26119.117465169547 actual.empty = 25546.774382330455 actual.wing = 5317.906253761935 actual.fuselage = 1.0 actual.propulsion = 1413.8593105126783 actual.landing_gear = 3160.632 actual.systems = 15654.376818055844 actual.wt_furnish = 8205.349895589 # error calculations error = Data() error.payload = (actual.payload - weight.payload) / actual.payload error.pax = (actual.pax - weight.pax) / actual.pax error.bag = (actual.bag - weight.bag) / actual.bag error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - (weight.fuselage + 1.0)) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion) / actual.propulsion error.systems = (actual.systems - weight.systems) / actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish) / actual.wt_furnish print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in list(error.items()): assert (np.abs(v) < 1E-6) # Human Powered Aircraft vehicle = hp_setup() weight = HP.empty(vehicle) # regression values actual = Data() actual.empty = 143.59737768459374 actual.wing = 95.43286881794776 actual.fuselage = 1.0 actual.horizontal_tail = 31.749272074174737 actual.vertical_tail = 16.415236792471237 # error calculations error = Data() error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - (weight.fuselage + 1.0)) / actual.fuselage error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail) / actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail) / actual.vertical_tail print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in list(error.items()): assert (np.abs(v) < 1E-6) return
def main(): # Transport Weights vehicle = vehicle_setup() method_types = [ 'SUAVE', 'New SUAVE', 'FLOPS Simple', 'FLOPS Complex', 'Raymer' ] for method_type in method_types: print('Testing Method: ' + method_type) if 'FLOPS' in method_type: settings = Data() settings.FLOPS = Data() settings.FLOPS.aeroelastic_tailoring_factor = 0. settings.FLOPS.strut_braced_wing_factor = 0. settings.FLOPS.composite_utilization_factor = 0.5 settings.FLOPS.variable_sweep_factor = 1. elif 'Raymer' in method_type: settings = Data() settings.Raymer = Data() settings.Raymer.fuselage_mounted_landing_gear_factor = 1. else: settings = None weight = Common.empty_weight(vehicle, settings=settings, method_type=method_type) #save_results(weight, 'weights_'+method_type.replace(' ','_')+'.res') old_weight = load_results('weights_' + method_type.replace(' ', '_') + '.res') check_list = [ 'payload_breakdown.total', 'payload_breakdown.passengers', 'payload_breakdown.baggage', 'structures.wing', 'structures.fuselage', 'propulsion_breakdown.total', 'structures.nose_landing_gear', 'structures.main_landing_gear', 'systems_breakdown.total', 'systems_breakdown.furnish', 'structures.horizontal_tail', 'structures.vertical_tail', 'empty', 'fuel' ] # do the check for k in check_list: print(k) old_val = old_weight.deep_get(k) new_val = weight.deep_get(k) err = (new_val - old_val) / old_val print('Error:', err) assert np.abs(err) < 1e-6, 'Check Failed : %s' % k print('') #General Aviation weights; note that values are taken from Raymer, #but there is a huge spread among the GA designs, so individual components #differ a good deal from the actual design vehicle = vehicle_setup_general_aviation() weight = General_Aviation.empty(vehicle) weight.fuel = vehicle.fuel.mass_properties.mass actual = Data() actual.bag = 0. actual.empty = 700.0097482541994 actual.fuel = 48.417662245800784 actual.wing = 152.25407206578896 actual.fuselage = 126.7421108234472 actual.propulsion = 224.40728553408732 actual.landing_gear = 67.81320006645151 actual.furnishing = 37.8341395817 actual.electrical = 41.28649399649684 actual.control_systems = 20.51671046011007 actual.fuel_systems = 20.173688786768366 actual.systems = 102.62736387596043 error = Data() error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.structures.wing) / actual.wing error.fuselage = (actual.fuselage - weight.structures.fuselage) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion_breakdown.total) / actual.propulsion error.landing_gear = ( actual.landing_gear - (weight.structures.main_landing_gear + weight.structures.nose_landing_gear)) / actual.landing_gear error.furnishing = (actual.furnishing - weight.systems_breakdown.furnish) / actual.furnishing error.electrical = (actual.electrical - weight.systems_breakdown.electrical ) / actual.electrical error.control_systems = ( actual.control_systems - weight.systems_breakdown.control_systems) / actual.control_systems error.fuel_systems = ( actual.fuel_systems - weight.propulsion_breakdown.fuel_system) / actual.fuel_systems error.systems = (actual.systems - weight.systems_breakdown.total) / actual.systems print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in error.items(): assert (np.abs(v) < 1E-6) # BWB WEIGHTS vehicle = bwb_setup() weight = BWB.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 #includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 23361.42500371662 actual.empty = 24417.180232883387 actual.wing = 7272.740220314861 actual.fuselage = 1.0 actual.propulsion = 1413.8593105126783 actual.landing_gear = 3160.632 actual.systems = 12569.948702055846 actual.wt_furnish = 8205.349895589 # error calculations error = Data() error.payload = (actual.payload - weight.payload_breakdown.total) / actual.payload error.pax = (actual.pax - weight.payload_breakdown.passengers) / actual.pax error.bag = (actual.bag - weight.payload_breakdown.baggage) / actual.bag error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.structures.wing) / actual.wing error.fuselage = (actual.fuselage - (weight.structures.fuselage + 1.0)) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion_breakdown.total) / actual.propulsion error.systems = (actual.systems - weight.systems_breakdown.total) / actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish) / actual.wt_furnish print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in error.items(): assert (np.abs(v) < 1E-6) # Human Powered Aircraft vehicle = hp_setup() weight = HP.empty(vehicle) # regression values actual = Data() actual.empty = 143.59737768459374 actual.wing = 95.43286881794776 actual.fuselage = 1.0 actual.horizontal_tail = 31.749272074174737 actual.vertical_tail = 16.415236792471237 # error calculations error = Data() error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - (weight.fuselage + 1.0)) / actual.fuselage error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail) / actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail) / actual.vertical_tail print('Results (kg)') print(weight) print('Relative Errors') print(error) for k, v in error.items(): assert (np.abs(v) < 1E-6) 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] 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
def main(): vehicle = vehicle_setup() weight = Tube_Wing.empty(vehicle) # regression values actual = Data() actual.payload = 27349.9081525 #includes cargo #17349.9081525 #without cargo actual.pax = 15036.587065500002 actual.bag = 2313.3210870000003 actual.fuel = 12990.957450008464 #includes cargo #22177.6377131 #without cargo actual.empty = 38674.934397491539 actual.wing = 6649.7096587384294 actual.fuselage = 6642.0611642718986 actual.propulsion = 6838.1851749566231 actual.landing_gear = 3160.632 actual.systems = 13479.10479056802 actual.wt_furnish = 6431.80372889 actual.horizontal_tail = 1024.5873332662029 actual.vertical_tail = 629.03876835025949 actual.rudder = 251.61550734010382 # error calculations error = Data() error.payload = (actual.payload - weight.payload) / actual.payload error.pax = (actual.pax - weight.pax) / actual.pax error.bag = (actual.bag - weight.bag) / actual.bag error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - weight.fuselage) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion) / actual.propulsion error.landing_gear = (actual.landing_gear - weight.landing_gear) / actual.landing_gear error.systems = (actual.systems - weight.systems) / actual.systems error.wt_furnish = (actual.wt_furnish - weight.systems_breakdown.furnish) / actual.wt_furnish error.horizontal_tail = (actual.horizontal_tail - weight.horizontal_tail) / actual.horizontal_tail error.vertical_tail = (actual.vertical_tail - weight.vertical_tail) / actual.vertical_tail error.rudder = (actual.rudder - weight.rudder) / actual.rudder print 'Results (kg)' print weight print 'Relative Errors' print error for k, v in error.items(): assert (np.abs(v) < 1E-6) #General Aviation weights; note that values are taken from Raymer, #but there is a huge spread among the GA designs, so individual components #differ a good deal from the actual design vehicle = vehicle_setup_general_aviation() GTOW = vehicle.mass_properties.max_takeoff weight = General_Aviation.empty(vehicle) weight.fuel = vehicle.fuel.mass_properties.mass actual = Data() actual.bag = 0. actual.empty = 618.485310343 actual.fuel = 144.69596603 actual.wing = 124.673093906 actual.fuselage = 119.522072873 actual.propulsion = 194.477769922 #includes power plant and propeller, does not include fuel system actual.landing_gear = 44.8033840543 + 5.27975390045 actual.furnishing = 37.8341395817 actual.electrical = 36.7532226254 actual.control_systems = 14.8331955546 actual.fuel_systems = 15.6859717453 actual.systems = 108.096549345 error = Data() error.fuel = (actual.fuel - weight.fuel) / actual.fuel error.empty = (actual.empty - weight.empty) / actual.empty error.wing = (actual.wing - weight.wing) / actual.wing error.fuselage = (actual.fuselage - weight.fuselage) / actual.fuselage error.propulsion = (actual.propulsion - weight.propulsion) / actual.propulsion error.landing_gear = (actual.landing_gear - (weight.landing_gear_main + weight.landing_gear_nose)) / actual.landing_gear error.furnishing = (actual.furnishing - weight.systems_breakdown.furnish) / actual.furnishing error.electrical = (actual.electrical - weight.systems_breakdown.electrical ) / actual.electrical error.control_systems = ( actual.control_systems - weight.systems_breakdown.control_systems) / actual.control_systems error.fuel_systems = ( actual.fuel_systems - weight.systems_breakdown.fuel_system) / actual.fuel_systems error.systems = (actual.systems - weight.systems) / actual.systems print 'actual.systems=', actual.systems print 'General Aviation Results (kg)' print weight print 'Relative Errors' print error for k, v in error.items(): assert (np.abs(v) < 1e-6) return