コード例 #1
0
ファイル: mission_B737.py プロジェクト: ZMurphyy/SUAVE
def main():

    configs, analyses = full_setup()

    simple_sizing(configs, analyses)
    configs.finalize()
    analyses.finalize()

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    # load older results
    #save_results(results)
    old_results = load_results()

    # plt the old results
    plot_mission(results)
    plot_mission(old_results, 'k-')
    #plt.show(block=True)

    # check the results
    check_results(results, old_results)

    # print weights breakdown
    print_weight_breakdown(configs.cruise)

    # ------------------------------------------------------------------
    #   Vehicle Definition Complete
    # ------------------------------------------------------------------

    # plot vehicle
    plot_vehicle(configs.base, plot_control_points=True)
    return
コード例 #2
0
def main():

    configs, analyses = full_setup()

    simple_sizing(configs)

    configs.finalize()
    analyses.finalize()

    # weight analysis
    weights = analyses.configs.base.weights
    breakdown = weights.evaluate()      

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    # print weight breakdown
    print_weight_breakdown(configs.base,filename = 'weight_breakdown.dat')

    # print engine data into file
    print_engine_data(configs.base,filename = 'B737_engine_data.dat')

    # print parasite drag data into file
    # define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6     
    print_parasite_drag(ref_condition,configs.cruise,analyses,'B737_parasite_drag.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,analyses,filename = 'B737_compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(results,filename='B737_mission_breakdown.dat')

    # load older results
    #save_results(results)
    old_results = load_results()   

    # plt the old results
    plot_mission(results)
    plot_mission(old_results,'k-')

    # check the results
    check_results(results,old_results)

##	# print some results, for check agaist Aviation paper
##    end_segment = results.segments[-1]
##    time     = end_segment.conditions.frames.inertial.time[-1,0] / Units.min
##    distance = end_segment.conditions.frames.inertial.position_vector[-1,0] / Units.nautical_miles
##    mass_end     = end_segment.conditions.weights.total_mass[-1,0]
##    mass_begin   = results.segments[0].conditions.weights.total_mass[0,0]
##    fuelburn = (mass_begin- mass_end) / Units.lbs
##    
##    print 'Time: {:5.0f} min , Distance: {:5.0f} nm ; FuelBurn: {:5.0f} lbs'.format(time,distance,fuelburn)

    return
コード例 #3
0
ファイル: mission_B737.py プロジェクト: nevesgeovana/TCC
def main():

    configs, analyses = full_setup()

    simple_sizing(configs)

    configs.finalize()
    analyses.finalize()

    # weight analysis
    weights = analyses.configs.base.weights
    breakdown = weights.evaluate()      

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    # print weight breakdown
    print_weight_breakdown(configs.base,filename = 'weight_breakdown.dat')

    # print engine data into file
    print_engine_data(configs.base,filename = 'B737_engine_data.dat')

    # print parasite drag data into file
    # define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6     
    print_parasite_drag(ref_condition,configs.cruise,analyses,'B737_parasite_drag.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,analyses,filename = 'B737_compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(results,filename='B737_mission_breakdown.dat')

    # load older results
    #save_results(results)
    old_results = load_results()   

    # plt the old results
    plot_mission(results)
    plot_mission(old_results,'k-')

    # check the results
    check_results(results,old_results)

##	# print some results, for check agaist Aviation paper
##    end_segment = results.segments[-1]
##    time     = end_segment.conditions.frames.inertial.time[-1,0] / Units.min
##    distance = end_segment.conditions.frames.inertial.position_vector[-1,0] / Units.nautical_miles
##    mass_end     = end_segment.conditions.weights.total_mass[-1,0]
##    mass_begin   = results.segments[0].conditions.weights.total_mass[0,0]
##    fuelburn = (mass_begin- mass_end) / Units.lbs
##    
##    print 'Time: {:5.0f} min , Distance: {:5.0f} nm ; FuelBurn: {:5.0f} lbs'.format(time,distance,fuelburn)

    return
コード例 #4
0
ファイル: mission_B737.py プロジェクト: nevesgeovana/TCC
def main():

    configs, analyses = full_setup()

    simple_sizing(configs)

    configs.finalize()
    analyses.finalize()

    # weight analysis
    weights = analyses.configs.base.weights
    breakdown = weights.evaluate()

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    # print weight breakdown
    print_weight_breakdown(configs.base, filename='weight_breakdown.dat')

    # print engine data into file
    print_engine_data(configs.base, filename='B737_engine_data.dat')

    # print parasite drag data into file
    # define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6
    print_parasite_drag(ref_condition, configs.cruise, analyses,
                        'B737_parasite_drag.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,
                        analyses,
                        filename='B737_compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(results, filename='B737_mission_breakdown.dat')

    # load older results
    #save_results(results)
    old_results = load_results()

    # plt the old results
    plot_mission(results)
    plot_mission(old_results, 'k-')

    # check the results
    check_results(results, old_results)

    return
コード例 #5
0
ファイル: E170_draft.py プロジェクト: nevesgeovana/TCC
def main():

    configs, analyses = full_setup()

    simple_sizing(configs)

    configs.finalize()
    analyses.finalize()

    # weight analysis
    weights = analyses.configs.base.weights
    breakdown = weights.evaluate()

    weights.vehicle.mass_properties.center_of_gravity = SUAVE.Methods.Center_of_Gravity.compute_aircraft_center_of_gravity(weights.vehicle, nose_load_fraction=.06)

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    CM = results.conditions.cruise.stability.static.CM[0][0]
    cm0 = results.conditions.cruise.stability.static.cm0[0][0]
    cm_alpha = results.conditions.cruise.stability.static.cm_alpha[0][0]
    cn_beta = results.conditions.cruise.stability.static.cn_beta[0][0]
    static_margin = results.conditions.cruise.stability.static.static_margin[0][0]

    # print weight breakdown
    print_weight_breakdown(configs.base,filename = 'E170_weight_breakdown.dat')

    # print engine data into file
    print_engine_data(configs.base,filename = 'E170_engine_data.dat')

    # print parasite drag data into file
    # define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6     
    print_parasite_drag(ref_condition,configs.cruise,analyses,'E170_parasite_drag.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,analyses,filename = 'E170_compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(results,filename='E170_mission_breakdown.dat')

    # plt the old results
    plot_mission(results)

    return
コード例 #6
0
def main():

    configs, analyses = full_setup()

    simple_sizing(configs)

    configs.finalize()
    analyses.finalize()

    # weight analysis
    weights = analyses.configs.base.weights
    breakdown = weights.evaluate()      

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    # print weight breakdown
    print_weight_breakdown(configs.base,filename = 'weight_breakdown.dat')

    # print engine data into file
    print_engine_data(configs.base,filename = 'B737_engine_data.dat')

    # print parasite drag data into file
        # define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6     
    print_parasite_drag(ref_condition,configs.cruise,analyses,'B737_parasite_drag.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,analyses,filename = 'B737_compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(results,filename='B737_mission_breakdown.dat')

    # load older results
    #save_results(results)
    old_results = load_results()   

    # plt the old results
    plot_mission(results)
    plot_mission(old_results,'k-')

    # check the results
    check_results(results,old_results)

    return
コード例 #7
0
def post_process(nexus):
    # Unpack data
    vehicle = nexus.vehicle_configurations.base
    configs = nexus.vehicle_configurations
    results = nexus.results
    summary = nexus.summary
    missions = nexus.missions

    # pretty_print(results)

    # Static stability calculations
    CMA = -10.
    for segment in results.base.segments.values():
        max_CMA = np.max(segment.conditions.stability.static.cm_alpha[:, 0])
        # lamda with a min/max?
        if max_CMA > CMA:
            CMA = max_CMA

    # Dynamics stability calculations
    dyn_stab = np.zeros(6)
    # j=0
    # for element in results.base.segments.conditions.stability.dynamic.values():
    #
    #     max = np.max(element[:, 0])
    #     min = np.min(element[:, 0])
    #     avg = np.mean(element[:, 0])
    #



    # for derivative in

    # stability data structure:


    # stability
    #     static
    #         cm_alpha
    #         cn_beta
    #
    #
    #     dynamic
    #         cn_r
    #         cl_p
    #         0
    #         cl_beta
    #         0
    #         cm_q
    #         cm_alpha_dot
    #         cz_alpha


    #
    # summary.static_stability = CMA
    #
    results = evaluate_field_length(configs, nexus.analyses, missions.base, results)
    #
    summary.field_length_takeoff = results.field_length.takeoff
    # print summary.field_length_takeoff
    summary.field_length_landing = results.field_length.landing
    # print summary.field_length_landing
    #
    # #
    # pretty_print(nexus)
    # throttle in design mission
    max_throttle = 0
    min_throttle = 0
    for segment in results.base.segments.values():
        max_segment_throttle = np.max(segment.conditions.propulsion.throttle[:, 0])
        min_segment_throttle = np.min(segment.conditions.propulsion.throttle[:, 0])
        if max_segment_throttle > max_throttle:
            max_throttle = max_segment_throttle
        if min_segment_throttle < min_throttle:
            min_throttle = min_segment_throttle

    summary.max_throttle = max_throttle
    summary.min_throttle = min_throttle

    # short_w_n, short_zeta, phugoid_w_n, phugoid_zeta = longitudinal(velocity, density, S_gross_w, mac, Cm_q, Cz_alpha, mass, Cm_alpha, Iy, Cm_alpha_dot, Cz_u, Cz_alpha_dot, Cz_q, Cw, Theta, Cx_u, Cx_alpha):


    # Fuel margin and base fuel calculations

    vehicle.mass_properties.operating_empty += 10e3 # FIXME hardcoded wing mass correction # area scaling?

    operating_empty = vehicle.mass_properties.operating_empty
    payload = vehicle.mass_properties.payload  # TODO fuel margin makes little sense when ejecting aerosol
    design_landing_weight = results.base.segments[-1].conditions.weights.total_mass[-1]
    design_takeoff_weight = vehicle.mass_properties.takeoff
    max_takeoff_weight = nexus.vehicle_configurations.takeoff.mass_properties.max_takeoff
    zero_fuel_weight = payload + operating_empty

    # pretty_print(nexus.vehicle_configurations)


    for i in range(1, len(results.base.segments)): # make fuel burn and sprayer continuous
        # print i
        results.base.segments[i].conditions.weights.fuel_burn[:, 0] += \
            results.base.segments[i - 1].conditions.weights.fuel_burn[-1]
        results.base.segments[i].conditions.weights.spray[:, 0] += \
            results.base.segments[i - 1].conditions.weights.spray[-1]

    summary.op_empty = operating_empty
    summary.max_zero_fuel_margin = (design_landing_weight - operating_empty) / operating_empty # used to be (design_landing_weight - zero_fuel_weight) / zero_fuel_weight changed because of aerosol ejection
    summary.base_mission_fuelburn = results.base.segments[-1].conditions.weights.fuel_burn[-1]  # esults.base.segments[i].conditions.weights.fuel_burn0#results.base.segments.conditions.weights.fuel_burn                         #design_takeoff_weight - results.base.segments['descent_3'].conditions.weights.total_mass[-1] # - results.base.segments['cruise'].conditions.sprayer_rate
    summary.base_mission_sprayed = results.base.segments[-1].conditions.weights.spray[-1]

    summary.cruise_range = 0#missions.base.segments.cruise_2.distance # assume we're flying straight
    summary.empty_range = results.base.segments['cruise_outgoing'].conditions.frames.inertial.position_vector[:, 0][-1]/1000.
    summary.mission_range = results.base.segments['cruise_final'].conditions.frames.inertial.position_vector[:, 0][-1]/1000. # Assuming mission ends at cruise altitude
    summary.spray_range = summary.mission_range - summary.empty_range

    summary.total_range = results.base.segments[-1].conditions.frames.inertial.position_vector[:, 0][-1]/1000.



    summary.main_mission_time = (results.base.segments['descent_final'].conditions.frames.inertial.time[-1] -
                                 results.base.segments[0].conditions.frames.inertial.time[0])
    summary.total_mission_time = (results.base.segments[-1].conditions.frames.inertial.time[-1] -
                                  results.base.segments[0].conditions.frames.inertial.time[0])

    summary.MTOW_delta = zero_fuel_weight + summary.base_mission_fuelburn - vehicle.mass_properties.takeoff

    # summary.engine_weight =

    # print results.base.segments.keys()
    # print summary.engine_weight

    print "zero fuel weight: ", zero_fuel_weight, "kg  i.e. (", payload, "+", operating_empty, ")"
    print "MTOW selected: ", vehicle.mass_properties.takeoff, "kg, MTOW calculated: ", zero_fuel_weight + summary.base_mission_fuelburn
    # FIXME Fuel burn doesn't change when the operating empty weight changes!
    print "Max/Min throttle: ", summary.max_throttle, ", ", summary.min_throttle
    print "Take-off field length: ", summary.field_length_takeoff[0], "m"
    print "Landing field length: ", summary.field_length_landing[0], "m"
    print "Mission Range (must be at least 7000km): ", summary.mission_range, " km"
    print "Non-spraying range (must be at least 3500km): ", summary.empty_range, " km"
    print "Spraying Range (must be at least 3500km): ", summary.spray_range, " km"
    print "Total Range: ", summary.total_range, " km", "(+",summary.total_range-summary.mission_range,")"
    print "Mission time: ", summary.main_mission_time[0] * Units['s'] / Units.h, "hours (main) +", \
        (summary.total_mission_time - summary.main_mission_time)[0] * Units['s'] / Units.h, "hours (diversion)"
    summary.nothing = 0.0
    print 'Fuel burn: ', summary.base_mission_fuelburn, " Fuel margin: ", summary.max_zero_fuel_margin
    # print 'fuel margin=', problem.all_constraints()

    gt_engine = nexus.vehicle_configurations.base.propulsors.turbofan



    # print thrust
    # FIXME move that to printing/results section
    print "Turbofan thrust:", gt_engine.sealevel_static_thrust, " x ", int(
        gt_engine.number_of_engines), "engines (tot: ", gt_engine.sealevel_static_thrust * gt_engine.number_of_engines, " N)"
    print "Thrust required: ", gt_engine.design_thrust, "N"

    print "Estimated engine length: ", gt_engine.engine_length, ", diameter: ", gt_engine.nacelle_diameter, ", wetted area: ", gt_engine.areas.wetted

    #FXI

    print "Aerosol released: ", summary.base_mission_sprayed[0], " kg\n\n"

    # print vehicle.wings.main_wing.chords.root, vehicle.wings.main_wing.spans.projected, vehicle.wings.main_wing.areas.reference

    # print "cruise range: ",problem.summary.cruise_range/1000., " km"


    hf = vehicle.fuselages.fuselage.heights.at_wing_root_quarter_chord
    wf = vehicle.fuselages.fuselage.width
    Lf = vehicle.fuselages.fuselage.lengths.total
    Sw = vehicle.wings.main_wing.areas.reference
    cw = vehicle.wings.main_wing.chords.mean_aerodynamic
    b = vehicle.wings.main_wing.spans.projected
    Sh = vehicle.wings.horizontal_stabilizer.areas.reference
    Sv = vehicle.wings.vertical_stabilizer.areas.reference
    lh = vehicle.wings.horizontal_stabilizer.origin[0] + vehicle.wings.horizontal_stabilizer.aerodynamic_center[0] - \
         vehicle.mass_properties.center_of_gravity[0]
    lv = vehicle.wings.vertical_stabilizer.origin[0] + vehicle.wings.vertical_stabilizer.aerodynamic_center[0] - \
         vehicle.mass_properties.center_of_gravity[0]

    # when you run want to output results to a file
    unscaled_inputs = nexus.optimization_problem.inputs[:, 1]  # use optimization problem inputs here
    input_scaling = nexus.optimization_problem.inputs[:, 3]
    scaled_inputs = unscaled_inputs / input_scaling
    problem_inputs = []

    # SEGMENTS: need to loop it and add all segments
    output_array_segments = np.zeros(4).reshape(4,1)
    for i in range(1, len(results.base.segments)):
        # print results.base.segments[i].conditions.aerodynamics.lift_coefficient[:, 0]
        # print results.base.segments[i].conditions.aerodynamics.angle_of_attack[:, 0] / Units.deg
        # print results.base.segments[i].conditions.freestream.dynamic_viscosity[:,0]
        # print results.base.segments[i].conditions.freestream.density[:,0]
        output_array_i = np.vstack((results.base.segments[i].conditions.aerodynamics.lift_coefficient[:, 0],
        results.base.segments[i].conditions.aerodynamics.angle_of_attack[:, 0] / Units.deg,
        results.base.segments[i].conditions.freestream.dynamic_viscosity[:,0],
        results.base.segments[i].conditions.freestream.density[:,0]))
        output_array_segments = np.hstack((output_array_segments,output_array_i))

    output_segment_indices = ["CL","alpha","dynamic_visc","air_density"]

    # print output_array_segments[segment_output_indexes.index("CL")]

    output_array = np.array([
        vehicle.wings.main_wing.aspect_ratio,
        vehicle.wings.main_wing.areas.reference,
        vehicle.wings.main_wing.sweep,
        vehicle.wings.main_wing.taper,
        vehicle.wings.main_wing.chords.root,
        vehicle.wings.main_wing.spans.projected,
        vehicle.fuselages.fuselage.effective_diameter,
        vehicle.fuselages.fuselage.lengths.total,
        vehicle.wings.main_wing.chords.mean_aerodynamic,
        2.*vehicle.fuselages.fuselage.origin[1],

        configs.takeoff.maximum_lift_coefficient,
        configs.landing.maximum_lift_coefficient,
        vehicle.maximum_lift_coefficient,
        missions.base.segments['descent_final'].air_speed,
        missions.base.segments['cruise_1'].air_speed,

        gt_engine.number_of_engines,
        gt_engine.mass_properties.mass/gt_engine.number_of_engines,      #PER ENGINE
        gt_engine.mass_properties.mass/1.6/gt_engine.number_of_engines,  #PER ENGINE DRY WEIGHT
        gt_engine.nacelle_diameter,

        summary.base_mission_fuelburn,
        zero_fuel_weight + summary.base_mission_fuelburn,
        operating_empty,
        design_landing_weight,
        vehicle.weight_breakdown.wing,
        vehicle.weight_breakdown.fuselage,
        vehicle.weight_breakdown.landing_gear,
        payload,

        820., #Fuel density

        vehicle.wings.horizontal_stabilizer.sweep,
        vehicle.wings.horizontal_stabilizer.spans.projected,
        vehicle.wings.horizontal_stabilizer.chords.root,

        vehicle.wings.vertical_stabilizer.sweep,
        vehicle.wings.vertical_stabilizer.taper,
        vehicle.wings.vertical_stabilizer.chords.root

        # QUESTIONABLE: CL_alpha, CM_alpha, Lift distribution, CM_delta, CL_delta
        ])

    output_indices = ["A",
               "S",
               "sweep",
               "taper",
               "c_r",
               "b",
               "d_fus",
               "l_fus",
               "c_mac",
               "y_fuselages",
               "CL_max_TO",
               "CL_max_landing",
               "CL_max_clean",
               "v_landing",
               "v_cr",
               "N_engines",
               "m_engine_wet",
               "m_engine_dry",
               "d_engine",
               "m_fuel",
               "MTOW",
               "OEW",
               "m_landing",
               "m_wing",
               "m_fus",
               "m_landing_gear",
               "m_payload",
               "rho_fuel",
               "sweep_h",
               "b_h",
               "c_r_h",
               "sweep_v",
               "taper_v",
               "c_r_v"
               ]

    # print output_array[output_indexes.index("c_r_v")]
    # print output_array[-1]

    # print vehicle.weight_breakdown
    np.save(output_folder+"output_array.npy",output_array)
    np.save(output_folder+"output_indices.npy",output_indices)
    np.save(output_folder+"output_array_segments.npy",output_array_segments)
    np.save(output_folder+"output_segment_indices.npy",output_segment_indices)

    for value in unscaled_inputs:
        problem_inputs.append(value)

    file_out = open(output_folder+'results.txt', 'ab')

    file_out.write('fuel weight = ')
    file_out.write(str(summary.base_mission_fuelburn))

    file_out.write(', inputs = ')
    file_out.write(str(problem_inputs))

    file_out.write('\n')
    file_out.close()

    print_weight_breakdown(nexus.vehicle_configurations.base, filename=output_folder + 'weight_breakdown.dat')
    #
    # # print engine data into file
    print_engine_data(nexus.vehicle_configurations.base, filename=output_folder + 'engine_data.dat')
    #
    # # print parasite drag data into file
    # # define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.7  # FIXME
    ref_condition.reynolds_number = 7e6  # FIXME
    Analyses = Data()
    Analyses.configs = nexus.analyses

    print_parasite_drag(ref_condition, nexus.vehicle_configurations.cruise, Analyses,
                        filename=output_folder + 'parasite_drag.dat')
    #
    # print compressibility drag data into file

    # print Analyses
    print_compress_drag(nexus.vehicle_configurations.cruise, Analyses, filename=output_folder + 'compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(nexus.results.base,
                            filename=output_folder + 'mission_breakdown.dat')  # FIXME fuel weight adds aerosol = wrong!!!!!

    return nexus
コード例 #8
0
def main():
    # ---------------------------------------------------------------------------------------
    # INITIALIZING AIRCRAFT

    configs, analyses, vehicle = full_setup()
    # analyses.configs.cruise.aerodynamics.settings.drag_coefficient_increment = 0.001
    print 'full setup OK'
    simple_sizing(configs)

    configs.finalize()
    analyses.finalize()

    # ---------------------------------------------------------------------------------------
    # WEIGHT ANALYSIS
    weights = analyses.configs.base.weights
    weights.evaluate()

    print 'WEIGHTS OK'
    # ---------------------------------------------------------------------------------------
    # MISSION ANALYSIS
    mission = analyses.missions.base
    results = mission.evaluate()
    print 'MISSION OK'
    configs.cruise.conditions = Data()
    configs.cruise.conditions = results.segments.cruise.conditions
    # print weight breakdown
    print_weight_breakdown(configs.base, filename='ATR72_weight_breakdown.dat')

    # print parasite drag data into file - define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6
    print_parasite_drag(ref_condition, configs.cruise, analyses,
                        'ATR72_parasite_drag.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,
                        analyses,
                        filename='ATR72_compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(results, filename='ATR72_mission_breakdown.dat')

    # # print engine data into file
    # print_turboprop_data(configs.cruise,filename = 'ATR72_engine_data.dat')

    state = Data()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics(
    )
    state.numerics = SUAVE.Analyses.Mission.Segments.Conditions.Numerics()
    # ---------------------------------------------------------------------------------------
    # PLOT RESULTS

    plot_mission(results, 0)
    # ---------------------------------------------------------------------------------------
    # PAYLOAD RANGE DIAGRAM

    config = configs.base
    cruise_segment_tag = "cruise"
    reserves = [775., 1120., 1100.]
    weights.mass_properties.operating_empty = weights.mass_properties.operating_empty - 239.
    # payloadrange = payload_range(config, mission, cruise_segment_tag, reserves)

    return
コード例 #9
0
def post_process(nexus):
    # Unpack data
    vehicle = nexus.vehicle_configurations.base
    configs = nexus.vehicle_configurations
    results = nexus.results
    summary = nexus.summary
    missions = nexus.missions

    # pretty_print(results)

    # start comment

    # # Static stability calculations
    # CMA = -10.
    # for segment in results.base.segments.values():
    #     max_CMA = np.max(segment.conditions.stability.static.cm_alpha[:, 0])
    #     # lamda with a min/max?
    #     if max_CMA > CMA:
    #         CMA = max_CMA
    #
    # # Dynamics stability calculations
    # # j=0
    #
    # cn_r = np.array([])
    # cl_p = np.array([])
    # cl_beta = np.array([])
    # cm_q = np.array([])
    # cm_alpha_dot = np.array([])
    # cz_alpha = np.array([])
    # cy_phi = np.array([])
    # cl_r = np.array([])
    #
    # cl_psi = np.array([])
    # cz_u = np.array([])
    # cz_alpha_dot = np.array([])
    # cz_q = np.array([])
    # cx_u = np.array([])
    # cx_alpha = np.array([])
    #
    # eigen_modes = np.array([])
    #
    # for segment in results.base.segments.values():
    #     # max_CMA = np.max(segment.conditions.stability.static.cm_alpha[:, 0])
    #
    #     # print segment.conditions.stability.dynamic.keys()
    #     # pretty_print(segment.conditions.stability)
    #     stability_model = segment.conditions.stability.stability_model
    #
    #     cn_r = np.append(cn_r,segment.conditions.stability.dynamic.cn_r[:,0])
    #     # cl_p = np.append(cl_p,segment.conditions.stability.dynamic.cl_p)
    #     # cl_beta = np.append(cl_beta,segment.conditions.stability.dynamic.cl_beta)
    #     cm_q = np.append(cm_q,segment.conditions.stability.dynamic.cm_q[:, 0])
    #     cm_alpha_dot = np.append(cm_alpha_dot,segment.conditions.stability.dynamic.cm_alpha_dot[:, 0])
    #     cz_alpha = np.append(cz_alpha,segment.conditions.stability.dynamic.cz_alpha[:, 0])
    #
    #     cy_phi = np.append(cy_phi,segment.conditions.stability.dynamic.cy_phi[:,0])
    #     cl_r = np.append(cl_r,segment.conditions.stability.dynamic.cl_r[:,0] )
    #
    #     cl_psi = np.append(cl_psi,segment.conditions.stability.dynamic.cl_psi[:,0] )
    #     cz_u = np.append(cz_u,segment.conditions.stability.dynamic.cz_u[:,0] )
    #     cz_alpha_dot = np.append(cz_alpha_dot,segment.conditions.stability.dynamic.cz_alpha_dot[:,0] )
    #     cz_q = np.append(cz_q,segment.conditions.stability.dynamic.cz_q[:,0] )
    #     cx_u = np.append(cx_u,segment.conditions.stability.dynamic.cx_u[:,0] )
    #     cx_alpha = np.append(cx_alpha,segment.conditions.stability.dynamic.cx_alpha[:,0] )
    #
    #
    #     eigen_modes = np.append(eigen_modes,
    #                             np.array([stability_model.dutch_roll.natural_frequency,
    #                                       stability_model.dutch_roll.damping_ratio,
    #                                       stability_model.spiral_tau,
    #                                       stability_model.roll_tau,
    #                                       stability_model.short_period.natural_frequency,
    #                                       stability_model.short_period.damping_ratio,
    #                                       stability_model.phugoid.natural_frequency,
    #                                       stability_model.phugoid.damping_ratio])
    #                             )
    #
    # # stability_model = results.stability_model
    # #
    # # eigen_modes = np.array([stability_model.dutch_roll.natural_frequency,
    # # stability_model.dutch_roll.damping_ratio,
    # # stability_model.spiral_tau,
    # # stability_model.roll_tau,
    # # stability_model.short_period.natural_frequency,
    # # stability_model.short_period.damping_ratio,
    # # stability_model.phugoid.natural_frequency,
    # # stability_model.phugoid.damping_ratio])
    #
    # dyn_stab = np.array([cn_r,cl_p,cl_beta,cm_q,cm_alpha_dot,cz_alpha,
    # cy_phi,
    # cl_r,
    # cl_psi,
    # cz_u,
    # cz_alpha_dot,
    # cz_q,
    # cx_u,
    # cx_alpha,
    # eigen_modes])
    # # lol = vehicle.stability_model.dutch_roll

    # stop comments

    # stability_model = self.stability_model

    # cn_r
    #         cl_p
    #         cl_beta
    #         cm_q
    #         cm_alpha_dot
    #         cz_alpha



    # lamda with a min/max?
    # if max_CMA > CMA:
    #     CMA = max_CMA






    # lst=[]
    #
    # for element in results.base.segments.conditions.stability.dynamic.values():
    #
    #     lst.append(element)
    #
    # for segment in results.base.segments.values():
    #
    #
    #
    #     max_CMA = np.max(segment.conditions.stability.static.cm_alpha[:, 0])
    #     # lamda with a min/max?
    #     if max_CMA > CMA:
    #         CMA = max_CMA
    #
    #
    #

    # for derivative in

    # stability data structure:


    # stability
    #     static
    #         cm_alpha
    #         cn_beta
    #
    #
    #     dynamic
    #         cn_r
    #         cl_p
    #         0
    #         cl_beta
    #         0
    #         cm_q
    #         cm_alpha_dot
    #         cz_alpha


    #
    # summary.static_stability = CMA
    #
    results = evaluate_field_length(configs, nexus.analyses, missions.base, results)
    #
    summary.field_length_takeoff = results.field_length.takeoff
    # print summary.field_length_takeoff
    summary.field_length_landing = results.field_length.landing
    # print summary.field_length_landing
    #
    # #
    # pretty_print(nexus)
    # throttle in design mission
    max_throttle = 0
    min_throttle = 0
    for segment in results.base.segments.values():
        max_segment_throttle = np.max(segment.conditions.propulsion.throttle[:, 0])
        min_segment_throttle = np.min(segment.conditions.propulsion.throttle[:, 0])
        if max_segment_throttle > max_throttle:
            max_throttle = max_segment_throttle
        if min_segment_throttle < min_throttle:
            min_throttle = min_segment_throttle

    summary.max_throttle = max_throttle
    summary.min_throttle = min_throttle

    # short_w_n, short_zeta, phugoid_w_n, phugoid_zeta = longitudinal(velocity, density, S_gross_w, mac, Cm_q, Cz_alpha, mass, Cm_alpha, Iy, Cm_alpha_dot, Cz_u, Cz_alpha_dot, Cz_q, Cw, Theta, Cx_u, Cx_alpha):


    # Fuel margin and base fuel calculations

    vehicle.mass_properties.operating_empty += 0e3  # FIXME hardcoded wing mass correction # area scaling?

    operating_empty = vehicle.mass_properties.operating_empty
    payload = vehicle.mass_properties.payload  # TODO fuel margin makes little sense when ejecting aerosol
    design_landing_weight = results.base.segments[-1].conditions.weights.total_mass[-1]
    design_takeoff_weight = vehicle.mass_properties.takeoff
    max_takeoff_weight = nexus.vehicle_configurations.takeoff.mass_properties.max_takeoff
    zero_fuel_weight = payload + operating_empty

    # pretty_print(nexus.vehicle_configurations)
    clmax = 0
    for segment in results.base.segments.values():
        cl = np.max(segment.conditions.aerodynamics.lift_coefficient[:, 0])
        if cl > clmax:
            clmax = cl

    summary.clmax = clmax

    for i in range(1, len(results.base.segments)):  # make fuel burn and sprayer continuous
        # print i
        results.base.segments[i].conditions.weights.fuel_burn[:, 0] += \
            results.base.segments[i - 1].conditions.weights.fuel_burn[-1]

        results.base.segments[i].conditions.weights.spray[:, 0] += \
            results.base.segments[i - 1].conditions.weights.spray[-1]

    summary.op_empty = operating_empty
    summary.max_zero_fuel_margin = (
                                       design_landing_weight - operating_empty) / operating_empty  # used to be (design_landing_weight - zero_fuel_weight) / zero_fuel_weight changed because of aerosol ejection
    summary.base_mission_fuelburn = results.base.segments[-1].conditions.weights.fuel_burn[
        -1]  # esults.base.segments[i].conditions.weights.fuel_burn0#results.base.segments.conditions.weights.fuel_burn                         #design_takeoff_weight - results.base.segments['descent_3'].conditions.weights.total_mass[-1] # - results.base.segments['cruise'].conditions.sprayer_rate
    summary.base_mission_sprayed = results.base.segments[-1].conditions.weights.spray[-1]

    summary.cruise_range = 0  # missions.base.segments.cruise_2.distance # assume we're flying straight
    summary.empty_range = results.base.segments['cruise_outgoing'].conditions.frames.inertial.position_vector[:, 0][
                              -1] / 1000.
    summary.mission_range = results.base.segments['cruise_final'].conditions.frames.inertial.position_vector[:, 0][
                                -1] / 1000.  # Assuming mission ends at cruise altitude
    summary.spray_range = summary.mission_range - summary.empty_range

    summary.total_range = results.base.segments[-1].conditions.frames.inertial.position_vector[:, 0][-1] / 1000.

    summary.main_mission_time = (results.base.segments['descent_final'].conditions.frames.inertial.time[-1] -
                                 results.base.segments[0].conditions.frames.inertial.time[0])
    summary.total_mission_time = (results.base.segments[-1].conditions.frames.inertial.time[-1] -
                                  results.base.segments[0].conditions.frames.inertial.time[0])

    summary.MTOW_delta = zero_fuel_weight + summary.base_mission_fuelburn - vehicle.mass_properties.takeoff

    # summary.power_draw = results.base.segments.

    # summary.engine_weight =

    # print results.base.segments.keys()
    # print summary.engine_weight

    print "zero fuel weight: ", zero_fuel_weight, "kg  i.e. (", payload, "+", operating_empty, ")"
    print "MTOW selected: ", vehicle.mass_properties.takeoff, "kg, MTOW calculated: ", zero_fuel_weight + summary.base_mission_fuelburn
    # FIXME Fuel burn doesn't change when the operating empty weight changes!
    print "Max/Min throttle: ", summary.max_throttle, ", ", summary.min_throttle
    print "Take-off field length: ", summary.field_length_takeoff[0], "m"
    print "Landing field length: ", summary.field_length_landing[0], "m"
    print "Mission Range (must be at least 7000km): ", summary.mission_range, " km"
    print "Non-spraying range (must be at least 3500km): ", summary.empty_range, " km"
    print "Spraying Range (must be at least 3500km): ", summary.spray_range, " km"
    print "Total Range: ", summary.total_range, " km", "(+", summary.total_range - summary.mission_range, ")"
    print "Mission time: ", summary.main_mission_time[0] * Units['s'] / Units.h, "hours (main) +", \
        (summary.total_mission_time - summary.main_mission_time)[0] * Units['s'] / Units.h, "hours (diversion)"
    summary.nothing = 0.0
    print 'Fuel burn: ', summary.base_mission_fuelburn, " Fuel margin: ", summary.max_zero_fuel_margin
    print "CL_max: ", summary.clmax
    # print 'fuel margin=', problem.all_constraints()

    gt_engine = nexus.vehicle_configurations.base.propulsors.turbofan

    # print thrust
    # FIXME move that to printing/results section
    print "Turbofan thrust:", gt_engine.sealevel_static_thrust, " x ", int(
        gt_engine.number_of_engines), "engines (tot: ", gt_engine.sealevel_static_thrust * gt_engine.number_of_engines, " N)"
    print "Thrust required: ", gt_engine.design_thrust, "N"

    print "Estimated engine length: ", gt_engine.engine_length, ", diameter: ", gt_engine.nacelle_diameter, ", wetted area: ", gt_engine.areas.wetted

    # FXI

    print "Aerosol released: ", summary.base_mission_sprayed[0], " kg\n\n"

    # print vehicle.wings.main_wing.chords.root, vehicle.wings.main_wing.spans.projected, vehicle.wings.main_wing.areas.reference

    # print "cruise range: ",problem.summary.cruise_range/1000., " km"


    hf = vehicle.fuselages.fuselage.heights.at_wing_root_quarter_chord
    wf = vehicle.fuselages.fuselage.width
    Lf = vehicle.fuselages.fuselage.lengths.total
    Sw = vehicle.wings.main_wing.areas.reference
    cw = vehicle.wings.main_wing.chords.mean_aerodynamic
    b = vehicle.wings.main_wing.spans.projected
    Sh = vehicle.wings.horizontal_stabilizer.areas.reference
    Sv = vehicle.wings.vertical_stabilizer.areas.reference
    lh = vehicle.wings.horizontal_stabilizer.origin[0] + vehicle.wings.horizontal_stabilizer.aerodynamic_center[0] - \
         vehicle.mass_properties.center_of_gravity[0]
    lv = vehicle.wings.vertical_stabilizer.origin[0] + vehicle.wings.vertical_stabilizer.aerodynamic_center[0] - \
         vehicle.mass_properties.center_of_gravity[0]

    # when you run want to output results to a file
    unscaled_inputs = nexus.optimization_problem.inputs[:, 1]  # use optimization problem inputs here
    input_scaling = nexus.optimization_problem.inputs[:, 3]
    scaled_inputs = unscaled_inputs / input_scaling
    problem_inputs = []

    # SEGMENTS: need to loop it and add all segments
    output_array_segments = np.zeros(6).reshape(6, 1)
    for i in range(0, len(results.base.segments)):
        # print results.base.segments[i].conditions.aerodynamics.lift_coefficient[:, 0]
        # print results.base.segments[i].conditions.aerodynamics.angle_of_attack[:, 0] / Units.deg
        # print results.base.segments[i].conditions.freestream.dynamic_viscosity[:,0]
        # print results.base.segments[i].conditions.freestream.density[:,0].shape
        # print results.base.segments[i].conditions.freestream.mach_number[:, 0].shape
        # print results.base.segments[i].conditions.freestream.reynolds_number[:, 0]
        output_array_i = np.vstack((results.base.segments[i].conditions.aerodynamics.lift_coefficient[:, 0],
                                    results.base.segments[i].conditions.aerodynamics.angle_of_attack[:, 0] / Units.deg,
                                    results.base.segments[i].conditions.freestream.dynamic_viscosity[:, 0],
                                    results.base.segments[i].conditions.freestream.density[:, 0],
                                    results.base.segments[i].conditions.freestream.mach_number[:, 0],
                                    results.base.segments[i].conditions.freestream.reynolds_number[:, 0]))
        output_array_segments = np.hstack((output_array_segments, output_array_i))

    output_segment_indices = ["CL", "alpha", "dynamic_visc", "air_density", "mach", "reynolds_number"]

    C_L_des = np.average(output_array_segments[0, 112:176])  # Average CL over the spraying cruise
    # print C_L_des

    # print output_array_segments[segment_output_indexes.index("CL")]

    # print         vehicle.wings.main_wing.areas.wetted + vehicle.wings.horizontal_stabilizer.areas.wetted +\
    #    vehicle.wings.vertical_stabilizer.areas.wetted + vehicle.fuselages.fuselage.areas.wetted

    SUAVE.Input_Output.D3JS.save_tree(vehicle, output_folder + 'tree.json')

    output_array = np.array([
        vehicle.wings.main_wing.aspect_ratio,
        vehicle.wings.main_wing.areas.reference,
        vehicle.wings.main_wing.sweep,
        vehicle.wings.main_wing.taper,
        vehicle.wings.main_wing.chords.root,
        vehicle.wings.main_wing.spans.projected,
        vehicle.fuselages.fuselage.effective_diameter,
        vehicle.fuselages.fuselage.lengths.total,
        vehicle.wings.main_wing.chords.mean_aerodynamic,
        2. * vehicle.fuselages.fuselage.origin[1],

        configs.takeoff.maximum_lift_coefficient,
        configs.landing.maximum_lift_coefficient,
        vehicle.maximum_lift_coefficient,
        missions.base.segments['descent_final'].air_speed,
        missions.base.segments['cruise_1'].air_speed,

        gt_engine.number_of_engines,
        gt_engine.mass_properties.mass / gt_engine.number_of_engines,  # PER ENGINE
        9000,  # PER ENGINE DRY WEIGHT
        gt_engine.nacelle_diameter,

        summary.base_mission_fuelburn,
        vehicle.mass_properties.max_takeoff,
        operating_empty,
        design_landing_weight,
        vehicle.weight_breakdown.wing,
        vehicle.weight_breakdown.fuselage,
        vehicle.weight_breakdown.landing_gear,
        payload,
        vehicle.weight_breakdown.horizontal_tail,
        vehicle.weight_breakdown.vertical_tail,
        vehicle.weight_breakdown.systems,
        vehicle.weight_breakdown.rudder,

        820.,  # Fuel density

        vehicle.wings.horizontal_stabilizer.sweep,
        vehicle.wings.horizontal_stabilizer.spans.projected,
        vehicle.wings.horizontal_stabilizer.chords.root,

        vehicle.wings.vertical_stabilizer.sweep,
        vehicle.wings.vertical_stabilizer.taper,
        vehicle.wings.vertical_stabilizer.chords.root,

        vehicle.wings.main_wing.areas.wetted + vehicle.wings.horizontal_stabilizer.areas.wetted + \
        vehicle.wings.vertical_stabilizer.areas.wetted + vehicle.fuselages.fuselage.areas.wetted

        # Oswald
        # Wetted area

        # QUESTIONABLE: CL_alpha, CM_alpha, Lift distribution, CM_delta, CL_delta
    ])

    output_indices = ["A",
                      "S",
                      "sweep",
                      "taper",
                      "c_r",
                      "b",
                      "d_fus",
                      "l_fus",
                      "c_mac",
                      "y_fuselages",
                      "CL_max_TO",
                      "CL_max_landing",
                      "CL_max_clean",
                      "v_landing",
                      "v_cr",
                      "N_engines",
                      "m_engine_wet",
                      "m_engine_dry",
                      "d_engine",
                      "m_fuel",
                      "MTOW",
                      "OEW",
                      "m_landing",
                      "m_wing",
                      "m_fus",
                      "m_landing_gear",
                      "m_payload",
                      "m_htail",
                      "m_vtail",
                      "m_systems",
                      "m_rudder",
                      "rho_fuel",
                      "sweep_h",
                      "b_h",
                      "c_r_h",
                      "sweep_v",
                      "taper_v",
                      "c_r_v",
                      "S_wet"
                      ]
    print output_array[output_indices.index('l_fus')]
    fuel_burn_sec = np.zeros(1)
    for i in range(1, len(results.base.segments)):
        fuel_burn_sec = np.hstack((fuel_burn_sec, results.base.segments[i - 1].conditions.weights.fuel_burn[-1]))

    wing_loading = (
                       operating_empty + summary.base_mission_fuelburn - fuel_burn_sec) * 9.81 / vehicle.wings.main_wing.areas.reference
    # print wing_loading
    # print output_array[output_indexes.index("c_r_v")]
    # print output_array[-1]

    # print vehicle.weight_breakdown

    if numpy_export:
        np.save(output_folder + "wing_loading.npy", wing_loading)
        np.save(output_folder + "output_array.npy", output_array)
        np.save(output_folder + "output_indices.npy", output_indices)
        np.save(output_folder + "output_array_segments.npy", output_array_segments)
        np.save(output_folder + "output_segment_indices.npy", output_segment_indices)
        # np.save(output_folder + "dynamic_stability.npy",dyn_stab)

    for value in unscaled_inputs:
        problem_inputs.append(value)

    file_out = open(output_folder + 'results.txt', 'ab')

    file_out.write('fuel weight = ')
    file_out.write(str(summary.base_mission_fuelburn))

    file_out.write(', inputs = ')
    file_out.write(str(problem_inputs))

    file_out.write('\n')
    file_out.close()

    # print vehicle.weight_breakdown.wing

    print_weight_breakdown(nexus.vehicle_configurations.base, filename=output_folder + 'weight_breakdown.dat')
    #
    # # print engine data into file
    print_engine_data(nexus.vehicle_configurations.base, filename=output_folder + 'engine_data.dat')
    #
    # # print parasite drag data into file
    # # define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.71  # FIXME
    ref_condition.reynolds_number = 9e6  # FIXME
    Analyses = Data()
    Analyses.configs = nexus.analyses

    print_parasite_drag(ref_condition, nexus.vehicle_configurations.cruise, Analyses,
                        filename=output_folder + 'parasite_drag.dat')
    #
    # print compressibility drag data into file

    # print Analyses
    print_compress_drag(nexus.vehicle_configurations.cruise, Analyses, filename=output_folder + 'compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(nexus.results.base,
                            filename=output_folder + 'mission_breakdown.dat')  # FIXME fuel weight adds aerosol = wrong!!!!!

    return nexus
コード例 #10
0
def plot_mission(nexus, id=0, line_style='bo-'):
    results = nexus.results.base
    axis_font = {'fontname': 'Arial', 'size': '14'}
    configs = nexus.vehicle_configurations
    analyses = Data()
    analyses.configs = Data()
    analyses.configs = nexus.analyses

    # print mission breakdown
    print_mission_breakdown(results,
                            filename='mission_breakdown' + str(id) + '.dat')

    # print engine data into file
    # print_engine_data(configs.base, filename='engine_data'+str(id)+'.dat')

    # print weight breakdown
    print_weight_breakdown(configs.base,
                           filename='weight_breakdown' + str(id) + '.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,
                        analyses,
                        filename='compress_drag' + str(id) + '.dat')

    # print parasite drag data into file - define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6
    print_parasite_drag(ref_condition, configs.cruise, analyses,
                        'parasite_drag' + str(id) + '.dat')
    # ------------------------------------------------------------------
    #   Aerodynamics
    # ------------------------------------------------------------------

    fig = plt.figure('Mission Parameters' + str(id), figsize=(8, 12))
    for segment in results.segments.values():

        time = segment.conditions.frames.inertial.time[:, 0] / Units.min
        Thrust = segment.conditions.frames.body.thrust_force_vector[:,
                                                                    0] / Units.lbf
        eta = segment.conditions.propulsion.throttle[:, 0]

        mdot = segment.conditions.weights.vehicle_mass_rate[:, 0] * 60 * 60
        mdot2 = segment.conditions.weights.vehicle_mass_rate[:,
                                                             0] / Units['lb/h']

        try:
            sfc = segment.conditions.propulsion.psfc
            pitch = segment.conditions.propulsion.pitch_command[:, 0]
            P = segment.conditions.propulsion.propeller_power[:,
                                                              0] * 1.34102 / 1000
            gas_turbine_power = segment.conditions.propulsion.gas_turbine_power[:,
                                                                                0] * 1.34102 / 1000
            etap = segment.conditions.propulsion.etap[:, 0]
            mdot3 = segment.conditions.propulsion.vehicle_mass_rate
            sfc2 = mdot2 / P / 2.
        except:
            sfc = mdot2 / Thrust / 2.
            pitch = segment.conditions.propulsion.throttle[:, 0] * 0.
            P = segment.conditions.propulsion.throttle[:, 0] * 0.
            gas_turbine_power = segment.conditions.propulsion.throttle[:,
                                                                       0] * 0.
            etap = segment.conditions.propulsion.throttle[:, 0] * 0.
            sfc2 = sfc
            mdot3 = mdot2

        axes = fig.add_subplot(5, 1, 1)
        axes.plot(time, Thrust, line_style)
        axes.set_ylabel('Thrust (lbf)', axis_font)
        axes.grid(True)

        axes = fig.add_subplot(5, 1, 2)
        axes.plot(time, P, 'ko-', label='Propeller')
        axes.plot(time, gas_turbine_power, 'ro-', label='Gas Turbine')
        axes.set_ylabel('Power (HP)', axis_font)
        axes.grid(True)

        axes = fig.add_subplot(5, 1, 3)
        axes.plot(time, eta, line_style)
        axes.set_xlabel('Time (min)', axis_font)
        axes.set_ylabel('Throttle', axis_font)
        axes.grid(True)

        axes = fig.add_subplot(5, 1, 4)
        axes.plot(time, pitch * 180 / 3.14159, line_style)
        axes.set_xlabel('Time (min)', axis_font)
        axes.set_ylabel('Pitch Command', axis_font)
        axes.grid(True)

        axes = fig.add_subplot(5, 1, 5)
        axes.plot(time, etap, line_style)
        axes.set_xlabel('Time (min)', axis_font)
        axes.set_ylabel('Propeller Efficiency', axis_font)
        axes.grid(True)

        plt.savefig("engine" + str(id) + ".png")

    # ------------------------------------------------------------------
    #   Aerodynamics
    # ------------------------------------------------------------------
    fig = plt.figure("Aerodynamic Coefficients", figsize=(8, 10))
    for segment in results.segments.values():

        time = segment.conditions.frames.inertial.time[:, 0] / Units.min
        CLift = segment.conditions.aerodynamics.lift_coefficient[:, 0]
        CDrag = segment.conditions.aerodynamics.drag_coefficient[:, 0]
        aoa = segment.conditions.aerodynamics.angle_of_attack[:, 0] / Units.deg
        l_d = CLift / CDrag

        axes = fig.add_subplot(3, 1, 1)
        axes.plot(time, CLift, line_style)
        axes.set_ylabel('Lift Coefficient', axis_font)
        axes.grid(True)

        axes = fig.add_subplot(3, 1, 2)
        axes.plot(time, l_d, line_style)
        axes.set_ylabel('L/D', axis_font)
        axes.grid(True)

        axes = fig.add_subplot(3, 1, 3)
        axes.plot(time, aoa, 'ro-')
        axes.set_xlabel('Time (min)', axis_font)
        axes.set_ylabel('AOA (deg)', axis_font)
        axes.grid(True)

    plt.savefig("aero" + str(id) + ".png")

    # ------------------------------------------------------------------
    #   Aerodynamics 2
    # ------------------------------------------------------------------
    fig = plt.figure("Drag Components", figsize=(8, 10))
    axes = plt.gca()
    for i, segment in enumerate(results.segments.values()):

        time = segment.conditions.frames.inertial.time[:, 0] / Units.min
        drag_breakdown = segment.conditions.aerodynamics.drag_breakdown
        cdp = drag_breakdown.parasite.total[:, 0]
        cdi = drag_breakdown.induced.total[:, 0]
        cdc = drag_breakdown.compressible.total[:, 0]
        cdm = drag_breakdown.miscellaneous.total[:, 0]
        cd = drag_breakdown.total[:, 0]

        if line_style == 'bo-':
            axes.plot(time, cdp, 'ko-', label='CD parasite')
            axes.plot(time, cdi, 'bo-', label='CD induced')
            axes.plot(time, cdc, 'go-', label='CD compressibility')
            axes.plot(time, cdm, 'yo-', label='CD miscellaneous')
            axes.plot(time, cd, 'ro-', label='CD total')
            if i == 0:
                axes.legend(loc='upper center')
        else:
            axes.plot(time, cdp, line_style)
            axes.plot(time, cdi, line_style)
            axes.plot(time, cdc, line_style)
            axes.plot(time, cdm, line_style)
            axes.plot(time, cd, line_style)

    axes.set_xlabel('Time (min)')
    axes.set_ylabel('CD')
    axes.grid(True)
    plt.savefig("drag" + str(id) + ".png")

    # ------------------------------------------------------------------
    #   Altitude, sfc, vehicle weight
    # ------------------------------------------------------------------

    fig = plt.figure("Altitude_sfc_weight", figsize=(8, 10))
    for segment in results.segments.values():

        time = segment.conditions.frames.inertial.time[:, 0] / Units.min
        aoa = segment.conditions.aerodynamics.angle_of_attack[:, 0] / Units.deg
        mass = segment.conditions.weights.total_mass[:, 0] / Units.lb
        altitude = segment.conditions.freestream.altitude[:, 0] / Units.ft
        mdot = segment.conditions.weights.vehicle_mass_rate[:, 0]
        thrust = segment.conditions.frames.body.thrust_force_vector[:, 0]
        sfc = (mdot / Units.lb) / (thrust / Units.lbf) * Units.hr

        axes = fig.add_subplot(3, 1, 1)
        axes.plot(time, altitude, line_style)
        axes.set_ylabel('Altitude (ft)', axis_font)
        axes.grid(True)

        axes = fig.add_subplot(3, 1, 3)
        axes.plot(time, sfc, line_style)
        axes.set_xlabel('Time (min)', axis_font)
        axes.set_ylabel('sfc (lb/lbf-hr)', axis_font)
        axes.grid(True)

        axes = fig.add_subplot(3, 1, 2)
        axes.plot(time, mass, 'ro-')
        axes.set_ylabel('Weight (lb)', axis_font)
        axes.grid(True)
    plt.savefig("mission" + str(id) + ".png")
    # plt.show(block=True)

    return
コード例 #11
0
ファイル: E170_reference.py プロジェクト: nevesgeovana/TCC
def main():

    configs, analyses, vehicle = full_setup()

    simple_sizing(configs)

    configs.finalize()
    analyses.finalize()

    # weight analysis
    weights = analyses.configs.base.weights
    breakdown = weights.evaluate()
    # analyses.configs.base.weights.mass_properties.operating_empty = 20736. * Units.kg

    # mission analysis
    mission = analyses.missions.base
    results = mission.evaluate()

    # print weight breakdown
    print_weight_breakdown(configs.base,filename = 'E170_weight_breakdown.dat')

    # print engine data into file
    print_engine_data(configs.base,filename = 'E170_engine_data.dat')

    # print parasite drag data into file
    # define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6     
    print_parasite_drag(ref_condition,configs.cruise,analyses,'E170_parasite_drag.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,analyses,filename = 'E170_compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(results,filename='E170_mission_breakdown.dat')

    state = Data()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics()
    state.numerics = SUAVE.Analyses.Mission.Segments.Conditions.Numerics()

    # ---------------------------------------------------------------------------------------
    # PAYLOAD RANGE DIAGRAM

    config = configs.base
    cruise_segment_tag = "cruise"
    reserves = 1600.
    # payload_range_results = payload_range(config, mission, cruise_segment_tag, reserves)

    # ---------------------------------------------------------------------------------------
    # PLOT RESULTS

    # plot_mission(results)

    # ---------------------------------------------------------------------------------------
    # TAKE OFF FIELD LENGTH
    # ---- Inputs
    analyses.base = analyses.configs.base
    airport = mission.airport
    
    airport.delta_isa  = 0.0
    airport.altitude   = 8000.0 * Units.ft


    clb_grad = 1
    weights_tofl = [20000,
    21009.319,
    22008.12425,
    23017.44325,
    24005.73477,
    25009.79689,
    25998.08841,
    27427.95699,
    28999.76105,
    29988.05257,
    30997.37157,
    32994.98208,
    35008.3632,
    37005.97372,
    38588.29152]

    np.linspace(vehicle.mass_properties.operating_empty, vehicle.mass_properties.max_takeoff, 10)
    tofl          = np.zeros(len(weights_tofl))
    secsegclbgrad = np.zeros(len(weights_tofl))

    # ---- Run
    for i, TOW in enumerate(weights_tofl):
        configs.takeoff.mass_properties.takeoff = TOW * Units.kg
        tofl[i], secsegclbgrad[i] = estimate_take_off_field_length(configs.takeoff, analyses, airport, clb_grad)
        print tofl[i]

    import pylab as plt
    title = "TOFL vs W"
    plt.figure(1)
    plt.plot(weights_tofl, tofl, 'k-')
    plt.xlabel('TOW (kg)')
    plt.ylabel('Takeoff Field Length (m)')
    plt.title(title)
    plt.grid(True)
    plt.show(True)

    return
コード例 #12
0
def main():
    # ---------------------------------------------------------------------------------------
    # INITIALIZING AIRCRAFT

    configs, analyses, vehicle = full_setup()

    print 'full setup OK'
    simple_sizing(configs)

    configs.finalize()
    analyses.finalize()

    # ---------------------------------------------------------------------------------------
    # WEIGHT ANALYSIS
    weights = analyses.configs.base.weights
    weights.evaluate()

    print 'WEIGHTS OK'
    # ---------------------------------------------------------------------------------------
    # MISSION ANALYSIS
    mission = analyses.missions.base
    results = mission.evaluate()
    print 'MISSION OK'
    configs.cruise.conditions = Data()
    configs.cruise.conditions = results.segments.cruise.conditions

    # print weight breakdown
    print_weight_breakdown(configs.base, filename='ATR72_weight_breakdown.dat')

    # print parasite drag data into file - define reference condition for parasite drag
    ref_condition = Data()
    ref_condition.mach_number = 0.3
    ref_condition.reynolds_number = 12e6
    print_parasite_drag(ref_condition, configs.cruise, analyses,
                        'ATR72_parasite_drag.dat')

    # print compressibility drag data into file
    print_compress_drag(configs.cruise,
                        analyses,
                        filename='ATR72_compress_drag.dat')

    # print mission breakdown
    print_mission_breakdown(results, filename='ATR72_mission_breakdown.dat')

    state = Data()
    state.conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics(
    )
    state.numerics = SUAVE.Analyses.Mission.Segments.Conditions.Numerics()
    # ---------------------------------------------------------------------------------------
    # PLOT RESULTS

    plot_mission(results, 0)
    # ---------------------------------------------------------------------------------------
    # PAYLOAD RANGE DIAGRAM

    config = configs.base
    cruise_segment_tag = "cruise"
    reserves = [775., 1120., 1040.]

    weights.mass_properties.operating_empty = weights.mass_properties.operating_empty - 239.
    payloadrange = payload_range(config, mission, cruise_segment_tag, reserves)

    # ---------------------------------------------------------------------------------------
    # TAKE OFF FIELD LENGTH
    # ---- Inputs
    analyses.base = analyses.configs.base
    airport = mission.airport
    clb_grad = 1

    altitude = [0., 6000.]
    delta_isa = 0.  # +23
    # 1000, 1100, 1200, 1300, 1400, -, 1500, 1600
    # 1200, 1300, 1400, 1500, 1600, 1700
    weights_tofl = [[20062, 21044, 21954, 22801, 23000, 23452, 23754, 21200],
                    [18489, 19342, 20154, 20928, 21671, 22105, 21530]]

    # ---- Inputs: FLAP AND SLAT DEFLECTION
    flaps = [15., 0.]  # Deflections inboard local
    slats = [0., 0.]

    # ---- Inputs: FACTOR CLMAX
    configs.takeoff.max_lift_coefficient_factor = 1.189
    configs.takeoff.V2_VS_ratio = 1.143

    # ---- Open output file
    fid = open('TOFL.txt', 'w')  # Open output file

    # ---- Run
    for j, h in enumerate(altitude):
        airport.altitude = h * Units.ft
        airport.delta_isa = delta_isa
        fid.write('Altitude: %4.0f ft \n' % (h))
        fid.write(
            'TOFL      CLIMB GRADIENT     THRUST    L/D     L/Dv2    CDasym    CDwindm     CL     CD  CG_CORRECT\n'
        )
        tofl = np.zeros(len(weights_tofl[j]))
        secsegclbgrad = np.zeros(len(weights_tofl[j]))
        thrust = np.zeros(len(weights_tofl[j]))
        l_over_d = np.zeros(len(weights_tofl[j]))
        l_over_d_v2 = np.zeros(len(weights_tofl[j]))
        asymmetry_drag_coefficient = np.zeros(len(weights_tofl[j]))
        windmilling_drag_coefficient = np.zeros(len(weights_tofl[j]))
        clv2 = np.zeros(len(weights_tofl[j]))
        cdv2 = np.zeros(len(weights_tofl[j]))
        secsegclbgrad_corrected = np.zeros(len(weights_tofl[j]))

        CLmax_ind = 0
        # configs.takeoff.maximum_lift_coefficient = maximum_lift_coefficient[CLmax_ind]
        configs.takeoff.wings[
            'main_wing'].flaps.angle = flaps[CLmax_ind] * Units.deg
        configs.takeoff.wings[
            'main_wing'].slats.angle = slats[CLmax_ind] * Units.deg

        for i, TOW in enumerate(weights_tofl[j]):
            configs.takeoff.mass_properties.takeoff = TOW * Units.kg
            tofl[i], secsegclbgrad[i], thrust[i], l_over_d[i], l_over_d_v2[i], asymmetry_drag_coefficient[i], \
            windmilling_drag_coefficient[i], clv2[i], cdv2[i], secsegclbgrad_corrected[
                i] = estimate_take_off_field_length(configs.takeoff,
                                                    analyses, airport,
                                                    clb_grad)
            if secsegclbgrad_corrected[i] < 0.024:
                # CLmax_ind = CLmax_ind + 1
                # if CLmax_ind > 1:
                #     CLmax_ind = 1
                print CLmax_ind, CLmax_ind, CLmax_ind, CLmax_ind, CLmax_ind, CLmax_ind

                configs.takeoff.wings[
                    'main_wing'].flaps.angle = flaps[CLmax_ind] * Units.deg
                configs.takeoff.wings[
                    'main_wing'].slats.angle = slats[CLmax_ind] * Units.deg

                tofl[i], secsegclbgrad[i], thrust[i], l_over_d[i], l_over_d_v2[i], asymmetry_drag_coefficient[i], \
                windmilling_drag_coefficient[i], clv2[i], cdv2[i], secsegclbgrad_corrected[
                    i] = estimate_take_off_field_length(configs.takeoff,
                                                        analyses, airport,
                                                        clb_grad)

            fid.write(
                '%4.2f     %4.4f    %4.4f    %4.4f    %4.4f    %4.4f    %4.4f    %4.4f    %4.4f    %4.4f \n'
                % (tofl[i], secsegclbgrad[i], thrust[i], l_over_d[i],
                   l_over_d_v2[i], asymmetry_drag_coefficient[i],
                   windmilling_drag_coefficient[i], clv2[i], cdv2[i],
                   secsegclbgrad_corrected[i]))
        fid.write('\n')

    fid.close()
    # ---------------------------------------------------------------------------------------
    # LANDING FIELD LENGTH
    # ---- Inputs
    airport.delta_isa = 0
    altitude = [0, 6000]
    weights_lfl = [[17000, 18000, 19000, 20000, 21000, 22000, 22350],
                   [17000, 18000, 19000, 20000, 21000, 22000, 22350]]

    flaps = [30., 15.]
    slats = [0., 0.]
    configs.landing.landing_constants = Data()

    configs.landing.landing_constants[0] = 250. * 0.25
    configs.landing.landing_constants[1] = 0.
    configs.landing.landing_constants[2] = 2.485 / 9.81

    configs.landing.wings['main_wing'].flaps.angle = flaps[0] * Units.deg
    configs.landing.wings['main_wing'].slats.angle = slats[0] * Units.deg

    configs.landing.max_lift_coefficient_factor = 1.31

    fid = open('LFL.txt', 'w')  # Open output file
    for j, h in enumerate(altitude):
        airport.altitude = h * Units.ft
        lfl = np.zeros(len(weights_lfl[j]))
        fid.write('Altitude: %4.0f ft \n' % (h))
        for i, TOW in enumerate(weights_lfl[j]):
            configs.landing.mass_properties.landing = TOW * Units.kg
            lfl[i] = estimate_landing_field_length(configs.landing, analyses,
                                                   airport)
            fid.write('%4.2f \n' % (lfl[i]))
        fid.write('\n')
    fid.close()

    return