def on_init(self): pygame.init() self._display_surf = pygame.display.set_mode((287,510), pygame.HWSURFACE) pygame.display.set_caption("Annoying Bird 0.5") self._running = True self.ss = spritesheet.spritesheet("Flappy-Graphics.bmp") self.numbers = self.ss.images_at([(276,647,11,13), (276,665,11,13), (276,699,11,13), (276,717,11,13), (276,751,11,13), (276,769,11,13), (276,803,11,13), (276,821,11,13), (276,855,11,13), (276,873,11,13)], colorkey =(255,255,255)) self.background = self.ss.image_at((0, 0, 287, 510)) self.score = 0 self.numberRect = self.numbers[0].get_rect().move(125, 30) self.flappy = flappy.flappy(self.ss) self.tube = tube.tube(self.ss) self.ground = ground.ground(self.ss) self.menu = True self.title = pygame.image.load("Menu.bmp") pygame.mixer.init() pygame.mixer.music.load("TOP.ogg") pygame.mixer.music.set_volume(1.0)
def on_init(self): pygame.init() self._display_surf = pygame.display.set_mode((287, 510), pygame.HWSURFACE) pygame.display.set_caption("Annoying Bird 0.5") self._running = True self.ss = spritesheet.spritesheet("Flappy-Graphics.bmp") self.numbers = self.ss.images_at( [(276, 647, 11, 13), (276, 665, 11, 13), (276, 699, 11, 13), (276, 717, 11, 13), (276, 751, 11, 13), (276, 769, 11, 13), (276, 803, 11, 13), (276, 821, 11, 13), (276, 855, 11, 13), (276, 873, 11, 13)], colorkey=(255, 255, 255)) self.background = self.ss.image_at((0, 0, 287, 510)) self.score = 0 self.numberRect = self.numbers[0].get_rect().move(125, 30) self.flappy = flappy.flappy(self.ss) self.tube = tube.tube(self.ss) self.ground = ground.ground(self.ss) self.menu = True self.title = pygame.image.load("Menu.bmp") pygame.mixer.init() pygame.mixer.music.load("TOP.ogg") pygame.mixer.music.set_volume(1.0)
def empty(vehicle): """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical) This is for a standard Tube and Wing aircraft configuration. Inputs: engine - a data dictionary with the fields: thrust_sls - sea level static thrust of a single engine [Newtons] wing - a data dictionary with the fields: gross_area - wing gross area [meters**2] span - span of the wing [meters] taper - taper ratio of the wing [dimensionless] t_c - thickness-to-chord ratio of the wing [dimensionless] sweep - sweep angle of the wing [radians] mac - mean aerodynamic chord of the wing [meters] r_c - wing root chord [meters] aircraft - a data dictionary with the fields: Nult - ultimate load of the aircraft [dimensionless] Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless] TOW - maximum takeoff weight of the aircraft [kilograms] zfw - maximum zero fuel weight of the aircraft [kilograms] num_eng - number of engines on the aircraft [dimensionless] num_pax - number of passengers on the aircraft [dimensionless] wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms] num_seats - number of seats installed on the aircraft [dimensionless] ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless] ac - determines type of instruments, electronics, and operating items based on types: "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless] w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters] fuselage - a data dictionary with the fields: area - fuselage wetted area [meters**2] diff_p - Maximum fuselage pressure differential [Pascal] width - width of the fuselage [meters] height - height of the fuselage [meters] length - length of the fuselage [meters] horizontal area - area of the horizontal tail [meters**2] span - span of the horizontal tail [meters] sweep - sweep of the horizontal tail [radians] mac - mean aerodynamic chord of the horizontal tail [meters] t_c - thickness-to-chord ratio of the horizontal tail [dimensionless] exposed - exposed area ratio for the horizontal tail [dimensionless] vertical area - area of the vertical tail [meters**2] span - sweight = weight * Units.lbpan of the vertical [meters] t_c - thickness-to-chord ratio of the vertical tail [dimensionless] sweep - sweep angle of the vertical tail [radians] t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless] Outputs: output - a data dictionary with fields: wt_payload - weight of the passengers plus baggage and paid cargo [kilograms] wt_pax - weight of all the passengers [kilogram] wt_bag - weight of all the baggage [kilogram] wt_fuel - weight of the fuel carried[kilogram] wt_empty - operating empty weight of the aircraft [kilograms] Assumptions: calculated aircraft weight from correlations created per component of historical aircraft """ # Unpack inputs Nult = vehicle.envelope.ultimate_load Nlim = vehicle.envelope.limit_load TOW = vehicle.mass_properties.max_takeoff wt_zf = vehicle.mass_properties.max_zero_fuel num_pax = vehicle.passengers wt_cargo = vehicle.mass_properties.cargo num_seats = vehicle.fuselages['fuselage'].number_coach_seats ctrl_type = vehicle.systems.control ac_type = vehicle.systems.accessories propulsor_name = vehicle.propulsors.keys()[ 0] #obtain the key for the propulsor for assignment purposes propulsors = vehicle.propulsors[propulsor_name] num_eng = propulsors.number_of_engines if propulsor_name == 'turbofan' or propulsor_name == 'Turbofan': # thrust_sls should be sea level static thrust. Using design thrust results in wrong propulsor # weight estimation. Engine sizing should return this value. # for now, using thrust_sls = design_thrust / 0.20, just for optimization evaluations thrust_sls = propulsors.sealevel_static_thrust wt_engine_jet = Propulsion.engine_jet(thrust_sls) wt_propulsion = Propulsion.integrated_propulsion( wt_engine_jet, num_eng) propulsors.mass_properties.mass = wt_propulsion else: #propulsor used is not a turbo_fan; assume mass_properties defined outside model wt_propulsion = propulsors.mass_properties.mass if wt_propulsion == 0: warnings.warn( "Propulsion mass= 0 ;e there is no Engine Weight being added to the Configuration", stacklevel=1) S_gross_w = vehicle.reference_area #S_gross_w = vehicle.wings['main_wing'].Areas.reference if not vehicle.wings.has_key('main_wing'): wt_wing = 0.0 wing_c_r = 0.0 warnings.warn( "There is no Wing Weight being added to the Configuration", stacklevel=1) else: b = vehicle.wings['main_wing'].spans.projected lambda_w = vehicle.wings['main_wing'].taper t_c_w = vehicle.wings['main_wing'].thickness_to_chord sweep_w = vehicle.wings['main_wing'].sweep mac_w = vehicle.wings['main_wing'].chords.mean_aerodynamic wing_c_r = vehicle.wings['main_wing'].chords.root wt_wing = wing_main(S_gross_w, b, lambda_w, t_c_w, sweep_w, Nult, TOW, wt_zf) vehicle.wings['main_wing'].mass_properties.mass = wt_wing S_fus = vehicle.fuselages['fuselage'].areas.wetted diff_p_fus = vehicle.fuselages['fuselage'].differential_pressure w_fus = vehicle.fuselages['fuselage'].width h_fus = vehicle.fuselages['fuselage'].heights.maximum l_fus = vehicle.fuselages['fuselage'].lengths.total if not vehicle.wings.has_key('horizontal_stabilizer'): wt_tail_horizontal = 0.0 S_h = 0.0 warnings.warn( "There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1) else: S_h = vehicle.wings['horizontal_stabilizer'].areas.reference b_h = vehicle.wings['horizontal_stabilizer'].spans.projected sweep_h = vehicle.wings['horizontal_stabilizer'].sweep mac_h = vehicle.wings['horizontal_stabilizer'].chords.mean_aerodynamic t_c_h = vehicle.wings['horizontal_stabilizer'].thickness_to_chord h_tail_exposed = vehicle.wings[ 'horizontal_stabilizer'].areas.exposed / vehicle.wings[ 'horizontal_stabilizer'].areas.wetted l_w2h = vehicle.wings['horizontal_stabilizer'].origin[ 0] + vehicle.wings['horizontal_stabilizer'].aerodynamic_center[ 0] - vehicle.wings['main_wing'].origin[0] - vehicle.wings[ 'main_wing'].aerodynamic_center[ 0] #Need to check this is the length of the horizontal tail moment arm wt_tail_horizontal = tail_horizontal(b_h, sweep_h, Nult, S_h, TOW, mac_w, mac_h, l_w2h, t_c_h, h_tail_exposed) vehicle.wings[ 'horizontal_stabilizer'].mass_properties.mass = wt_tail_horizontal if not vehicle.wings.has_key('vertical_stabilizer'): output_3 = Data() output_3.wt_tail_vertical = 0.0 output_3.wt_rudder = 0.0 S_v = 0.0 warnings.warn( "There is no Vertical Tail Weight being added to the Configuration", stacklevel=1) else: S_v = vehicle.wings['vertical_stabilizer'].areas.reference b_v = vehicle.wings['vertical_stabilizer'].spans.projected t_c_v = vehicle.wings['vertical_stabilizer'].thickness_to_chord sweep_v = vehicle.wings['vertical_stabilizer'].sweep t_tail = vehicle.wings['vertical_stabilizer'].t_tail output_3 = tail_vertical(S_v, Nult, b_v, TOW, t_c_v, sweep_v, S_gross_w, t_tail) vehicle.wings[ 'vertical_stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder # Calculating Empty Weight of Aircraft wt_landing_gear = landing_gear(TOW) wt_fuselage = tube(S_fus, diff_p_fus, w_fus, h_fus, l_fus, Nlim, wt_zf, wt_wing, wt_propulsion, wing_c_r) output_2 = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type) # Calculate the equipment empty weight of the aircraft wt_empty = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_2.wt_systems + \ wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder) vehicle.fuselages['fuselage'].mass_properties.mass = wt_fuselage # packup outputs output = payload(TOW, wt_empty, num_pax, wt_cargo) output.wing = wt_wing output.fuselage = wt_fuselage output.propulsion = wt_propulsion output.landing_gear = wt_landing_gear output.horizontal_tail = wt_tail_horizontal output.vertical_tail = output_3.wt_tail_vertical output.rudder = output_3.wt_rudder output.systems = output_2.wt_systems output.systems_breakdown = Data() output.systems_breakdown.control_systems = output_2.wt_flt_ctrl output.systems_breakdown.apu = output_2.wt_apu output.systems_breakdown.hydraulics = output_2.wt_hyd_pnu output.systems_breakdown.instruments = output_2.wt_instruments output.systems_breakdown.avionics = output_2.wt_avionics output.systems_breakdown.optionals = output_2.wt_opitems output.systems_breakdown.electrical = output_2.wt_elec output.systems_breakdown.air_conditioner = output_2.wt_ac output.systems_breakdown.furnish = output_2.wt_furnish #define weights components try: landing_gear_component = vehicle.landing_gear #landing gear previously defined except AttributeError: # landing gear not defined landing_gear_component = SUAVE.Components.Landing_Gear.Landing_Gear() vehicle.landing_gear = landing_gear_component control_systems = SUAVE.Components.Physical_Component() electrical_systems = SUAVE.Components.Physical_Component() passengers = SUAVE.Components.Physical_Component() furnishings = SUAVE.Components.Physical_Component() air_conditioner = SUAVE.Components.Physical_Component() fuel = SUAVE.Components.Physical_Component() apu = SUAVE.Components.Physical_Component() hydraulics = SUAVE.Components.Physical_Component() optionals = SUAVE.Components.Physical_Component() rudder = SUAVE.Components.Physical_Component() avionics = SUAVE.Components.Energy.Peripherals.Avionics() #assign output weights to objects landing_gear_component.mass_properties.mass = output.landing_gear control_systems.mass_properties.mass = output.systems_breakdown.control_systems electrical_systems.mass_properties.mass = output.systems_breakdown.electrical passengers.mass_properties.mass = output.pax + output.bag furnishings.mass_properties.mass = output.systems_breakdown.furnish avionics.mass_properties.mass = output.systems_breakdown.avionics \ + output.systems_breakdown.instruments air_conditioner.mass_properties.mass = output.systems_breakdown.air_conditioner fuel.mass_properties.mass = output.fuel apu.mass_properties.mass = output.systems_breakdown.apu hydraulics.mass_properties.mass = output.systems_breakdown.hydraulics optionals.mass_properties.mass = output.systems_breakdown.optionals rudder.mass_properties.mass = output.rudder #assign components to vehicle vehicle.control_systems = control_systems vehicle.electrical_systems = electrical_systems vehicle.avionics = avionics vehicle.furnishings = furnishings vehicle.passenger_weights = passengers vehicle.air_conditioner = air_conditioner vehicle.fuel = fuel vehicle.apu = apu vehicle.hydraulics = hydraulics vehicle.optionals = optionals vehicle.landing_gear = landing_gear_component vehicle.wings['vertical_stabilizer'].rudder = rudder return output
] ds_list = ds_list_sine #[ds_list_mhd[0], ds_list_hydro[0]] renorm = {'density': 1, 'pressure': 0.6, 'TotalEnergy': 0.9} if 0: ds0 = ds_list[0] ds1 = ds_list[1] for ds in ds_list: ray_set[ds] = ds.ortho_ray(axis, coord) ray_mhd = ray_set[ds0] ray_hydro = ray_set[ds1] simname = "both_ics" simname = 't05_sine' #x=tube.tube(ds_list, delta=True, fields=fields, renorm=renorm,filename = simname+".png",legend=True) #y=tube.tube(ds_list_mhd, delta=true, fields=fields, renorm=renorm,filename = "mhd"+".png") y = tube.tube(ds_list_sine, delta=True, fields=fields, renorm=renorm, filename="sine" + ".png") #y=tube.tube(ds_list_hydro,delta=True, fields=fields, renorm=renorm,filename = "hydro"+".png") if 0: for i, field in enumerate(fields): for n_ds, ds in enumerate(ds_list): counter += 1 this_ray = ray_set[ds] this_x = this_ray['xyz'[axis]] this_y = this_ray[field] stat(this_y) #needs: ensure list
def empty(vehicle): """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical) This is for a standard Tube and Wing aircraft configuration. Inputs: engine - a data dictionary with the fields: thrust_sls - sea level static thrust of a single engine [Newtons] wing - a data dictionary with the fields: gross_area - wing gross area [meters**2] span - span of the wing [meters] taper - taper ratio of the wing [dimensionless] t_c - thickness-to-chord ratio of the wing [dimensionless] sweep - sweep angle of the wing [radians] mac - mean aerodynamic chord of the wing [meters] r_c - wing root chord [meters] aircraft - a data dictionary with the fields: Nult - ultimate load of the aircraft [dimensionless] Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless] TOW - maximum takeoff weight of the aircraft [kilograms] zfw - maximum zero fuel weight of the aircraft [kilograms] num_eng - number of engines on the aircraft [dimensionless] num_pax - number of passengers on the aircraft [dimensionless] wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms] num_seats - number of seats installed on the aircraft [dimensionless] ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless] ac - determines type of instruments, electronics, and operating items based on types: "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless] w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters] fuselage - a data dictionary with the fields: area - fuselage wetted area [meters**2] diff_p - Maximum fuselage pressure differential [Pascal] width - width of the fuselage [meters] height - height of the fuselage [meters] length - length of the fuselage [meters] horizontal area - area of the horizontal tail [meters**2] span - span of the horizontal tail [meters] sweep - sweep of the horizontal tail [radians] mac - mean aerodynamic chord of the horizontal tail [meters] t_c - thickness-to-chord ratio of the horizontal tail [dimensionless] exposed - exposed area ratio for the horizontal tail [dimensionless] vertical area - area of the vertical tail [meters**2] span - sweight = weight * Units.lbpan of the vertical [meters] t_c - thickness-to-chord ratio of the vertical tail [dimensionless] sweep - sweep angle of the vertical tail [radians] t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless] Outputs: output - a data dictionary with fields: wt_payload - weight of the passengers plus baggage and paid cargo [kilograms] wt_pax - weight of all the passengers [kilogram] wt_bag - weight of all the baggage [kilogram] wt_fuel - weight of the fuel carried[kilogram] wt_empty - operating empty weight of the aircraft [kilograms] Assumptions: calculated aircraft weight from correlations created per component of historical aircraft """ # Unpack inputs Nult = vehicle.envelope.ultimate_load Nlim = vehicle.envelope.limit_load TOW = vehicle.mass_properties.max_takeoff wt_zf = vehicle.mass_properties.max_zero_fuel num_pax = vehicle.passengers wt_cargo = vehicle.mass_properties.cargo num_seats = vehicle.fuselages['fuselage'].number_coach_seats ctrl_type = vehicle.systems.control ac_type = vehicle.systems.accessories V_descent = 80. d_fus = vehicle.fuselages['fuselage'].effective_diameter propulsor_name = vehicle.propulsors.keys()[0] # obtain the key for the propulsor for assignment purposes propulsors = vehicle.propulsors[propulsor_name] num_eng = propulsors.number_of_engines if propulsor_name == 'turbofan' or propulsor_name == 'Turbofan': # thrust_sls should be sea level static thrust. Using design thrust results in wrong propulsor # weight estimation. Engine sizing should return this value. # for now, using thrust_sls = design_thrust / 0.20, just for optimization evaluations thrust_sls = propulsors.sealevel_static_thrust wt_engine_jet = Propulsion.engine_jet(thrust_sls) # print wt_engine_jet # print "Test2" wt_propulsion = Propulsion.integrated_propulsion(wt_engine_jet, num_eng) propulsors.mass_properties.mass = wt_propulsion # print wt_propulsion d_eng = propulsors.nacelle_diameter else: # propulsor used is not a turbo_fan; assume mass_properties defined outside model wt_propulsion = propulsors.mass_properties.mass if wt_propulsion == 0: warnings.warn("Propulsion mass= 0 ;e there is no Engine Weight being added to the Configuration", stacklevel=1) S_gross_w = vehicle.reference_area # S_gross_w = vehicle.wings['main_wing'].Areas.reference if not vehicle.wings.has_key('main_wing'): wt_wing = 0.0 wing_c_r = 0.0 warnings.warn("There is no Wing Weight being added to the Configuration", stacklevel=1) else: b = vehicle.wings['main_wing'].spans.projected lambda_w = vehicle.wings['main_wing'].taper t_c_w = vehicle.wings['main_wing'].thickness_to_chord sweep_w = vehicle.wings['main_wing'].sweep mac_w = vehicle.wings['main_wing'].chords.mean_aerodynamic wing_c_r = vehicle.wings['main_wing'].chords.root # print 'c_root =',wing_c_r wt_wing = wing_main(S_gross_w, b, lambda_w, t_c_w, sweep_w, Nult, TOW, wt_zf) vehicle.wings['main_wing'].mass_properties.mass = wt_wing S_fus = vehicle.fuselages['fuselage'].areas.wetted diff_p_fus = vehicle.fuselages['fuselage'].differential_pressure w_fus = vehicle.fuselages['fuselage'].width h_fus = vehicle.fuselages['fuselage'].heights.maximum l_fus = vehicle.fuselages['fuselage'].lengths.total if not vehicle.wings.has_key('horizontal_stabilizer'): wt_tail_horizontal = 0.0 S_h = 0.0 warnings.warn("There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1) else: S_h = vehicle.wings['horizontal_stabilizer'].areas.reference b_h = vehicle.wings['horizontal_stabilizer'].spans.projected A_h = vehicle.wings['horizontal_stabilizer'].aspect_ratio sweep_h = vehicle.wings['horizontal_stabilizer'].sweep mac_h = vehicle.wings['horizontal_stabilizer'].chords.mean_aerodynamic c_r_h = vehicle.wings['horizontal_stabilizer'].chords.root t_c_h = vehicle.wings['horizontal_stabilizer'].thickness_to_chord # print 'c_r_h =',c_r_h taper_h = vehicle.wings['horizontal_stabilizer'].taper h_tail_exposed = vehicle.wings['horizontal_stabilizer'].areas.exposed / vehicle.wings[ 'horizontal_stabilizer'].areas.wetted l_w2h = vehicle.wings['horizontal_stabilizer'].origin[0] + \ vehicle.wings['horizontal_stabilizer'].aerodynamic_center[0] - vehicle.wings['main_wing'].origin[0] - \ vehicle.wings['main_wing'].aerodynamic_center[ 0] # Need to check this is the length of the horizontal tail moment arm # wt_tail_horizontal = tail_horizontal(b_h, sweep_h, Nult, S_h, TOW, mac_w, mac_h, l_w2h, t_c_h, h_tail_exposed) Sel = 0.15 * S_h wt_tail_horizontal = hor_tail(c_r_h, taper_h, l_w2h, Sel, S_h, A_h, b_h, sweep_h, TOW, Nult) vehicle.wings['horizontal_stabilizer'].mass_properties.mass = wt_tail_horizontal if not vehicle.wings.has_key('vertical_stabilizer'): output_3 = Data() output_3.wt_tail_vertical = 0.0 output_3.wt_rudder = 0.0 S_v = 0.0 warnings.warn("There is no Vertical Tail Weight being added to the Configuration", stacklevel=1) else: S_v = vehicle.wings['vertical_stabilizer'].areas.reference b_v = vehicle.wings['vertical_stabilizer'].spans.projected A_v = vehicle.wings['vertical_stabilizer'].aspect_ratio t_c_v = vehicle.wings['vertical_stabilizer'].thickness_to_chord sweep_v = vehicle.wings['vertical_stabilizer'].sweep taper_v = vehicle.wings['vertical_stabilizer'].taper c_r_v = vehicle.wings['vertical_stabilizer'].chords.root mac_v = vehicle.wings['vertical_stabilizer'].chords.mean_aerodynamic t_tail = vehicle.wings['vertical_stabilizer'].t_tail output_3 = tail_vertical(S_v, Nult, b_v, TOW, t_c_v, sweep_v, S_gross_w, t_tail) wt_tail_vertical = vert_tail(S_v, b_v, c_r_v, taper_v, t_c_v, A_v, sweep_v, l_w2h, TOW) vehicle.wings['vertical_stabilizer'].mass_properties.mass = wt_tail_vertical # print 'b_v =',b_v # print 'c_r_v =',c_r_v # print 'c_t_v =',c_r_v*taper_v # vehicle.wings['vertical_stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder # Calculating Empty Weight of Aircraft wt_landing_gear, gear, h_gear = landing_gear(TOW, d_eng, h_fus, V_descent) # print 'h_gear =', h_gear l_nose = vehicle.fuselages['fuselage'].lengths.nose l_center = vehicle.fuselages['fuselage'].lengths.cabin l_tail = vehicle.fuselages['fuselage'].lengths.tail S_cstot = 0.22 * mac_w * 0.6 * b * 1.5 + 0.3 * mac_v * 0.9 * b_v + 0.2 * mac_h * 0.9 * b_h # 1.5 factor is because of assumed spoilers on wings Iy_SI = 1230140.7646609414 # kgm^2 Vmax = 240 # m/s wt_fuselage = tube(S_fus, diff_p_fus, w_fus, h_fus, l_nose, l_center, l_tail, l_fus, Nlim, wt_zf, wt_wing, wt_propulsion, wing_c_r, TOW, h_gear) # output_2 = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type) OEW = 109000 # kg #FIXME V_fuel = 69000 / 820 # m^3 #FIXME wt_engine_jet = 9000 # kg output_sys = classIIsys(num_eng, wt_engine_jet, V_fuel, Iy_SI, S_cstot, l_fus, OEW, TOW, Vmax, b) l_eng = 7 # m output_prop = propgroup(num_eng, wt_engine_jet, d_eng, l_eng, output_sys.w_fuelsys, output_sys.w_starter, Nult, Vmax) wt_propulsion = output_prop.w_propulsion # Calculate the equipment empty weight of the aircraft wt_empty = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_sys.w_system + wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder) vehicle.fuselages['fuselage'].mass_properties.mass = wt_fuselage # packup outputs output = payload(TOW, wt_empty, num_pax, wt_cargo) output.wing = wt_wing output.fuselage = wt_fuselage output.propulsion = wt_propulsion output.landing_gear = wt_landing_gear output.horizontal_tail = wt_tail_horizontal output.vertical_tail = output_3.wt_tail_vertical output.rudder = output_3.wt_rudder output.systems = output_sys.w_system output.systems_breakdown = Data() output.systems_breakdown.control_systems = output_sys.w_flightcontrol output.systems_breakdown.apu = output_sys.w_apu output.systems_breakdown.hydraulics = output_sys.w_hydraullics # output.systems_breakdown.instruments = output_sys.wt_instruments output.systems_breakdown.avionics = output_sys.w_avionics # output.systems_breakdown.optionals = output_sys.wt_opitems output.systems_breakdown.electrical = output_sys.w_electrical output.systems_breakdown.air_conditioner = output_sys.w_env # output.systems_breakdown.furnish = output_2.wt_furnish # define weights components try: landing_gear_component = vehicle.landing_gear # landing gear previously defined except AttributeError: # landing gear not defined landing_gear_component = SUAVE.Components.Landing_Gear.Landing_Gear() vehicle.landing_gear = landing_gear_component control_systems = SUAVE.Components.Physical_Component() electrical_systems = SUAVE.Components.Physical_Component() passengers = SUAVE.Components.Physical_Component() # furnishings = SUAVE.Components.Physical_Component() air_conditioner = SUAVE.Components.Physical_Component() fuel = SUAVE.Components.Physical_Component() apu = SUAVE.Components.Physical_Component() hydraulics = SUAVE.Components.Physical_Component() # optionals = SUAVE.Components.Physical_Component() rudder = SUAVE.Components.Physical_Component() avionics = SUAVE.Components.Energy.Peripherals.Avionics() # assign output weights to objects landing_gear_component.mass_properties.mass = output.landing_gear control_systems.mass_properties.mass = output.systems_breakdown.control_systems electrical_systems.mass_properties.mass = output.systems_breakdown.electrical passengers.mass_properties.mass = output.pax + output.bag # furnishings.mass_properties.mass = output.systems_breakdown.furnish avionics.mass_properties.mass = output.systems_breakdown.avionics # \ # + output.systems_breakdown.instruments air_conditioner.mass_properties.mass = output.systems_breakdown.air_conditioner fuel.mass_properties.mass = output.fuel apu.mass_properties.mass = output.systems_breakdown.apu hydraulics.mass_properties.mass = output.systems_breakdown.hydraulics # optionals.mass_properties.mass = output.systems_breakdown.optionals rudder.mass_properties.mass = output.rudder # assign components to vehicle vehicle.control_systems = control_systems vehicle.electrical_systems = electrical_systems vehicle.avionics = avionics # vehicle.furnishings = furnishings vehicle.passenger_weights = passengers vehicle.air_conditioner = air_conditioner vehicle.fuel = fuel vehicle.apu = apu vehicle.hydraulics = hydraulics # vehicle.optionals = optionals vehicle.landing_gear = landing_gear_component vehicle.wings['vertical_stabilizer'].rudder = rudder return output
axis = 0 coord = (0.505, 0.505) counter = 0 #fields=['density','pressure','TotalEnergy','x-velocity', ]#,'x-velocity'] fields = ['%s_p' % s for s in all_x] #fields += ['Bx','By','Bz','magnetic_energy'] #fields += ['magnetic_field_x','magnetic_field_y','magnetic_field_z','magnetic_energy'] #fields +=['x-velocity','y-velocity','z-velocity'] #fields += ['Ltension_x', #fields += ['Badvection_x'] ray_set = {} sim = 'a03' frames = [0] ds_list = [ yt.load("%s/DD%04d/data%04d" % (sims[sim], frame, frame)) for frame in frames ] g = ds_list[0].index.grids[0] #print g[fields[0]] data = g renorm = {'density': 1, 'pressure': 0.6, 'TotalEnergy': 0.9} y = tube.tube(ds_list, return_ray=True, delta=False, fields=fields, renorm=renorm, filename="Tube_%s%s.png" % (sim, "_%s" * len(fields) % tuple(fields)), labels=fields, plot_args={'marker': '*'})
def empty(vehicle): """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical) This is for a standard Tube and Wing aircraft configuration. Inputs: engine - a data dictionary with the fields: thrust_sls - sea level static thrust of a single engine [Newtons] wing - a data dictionary with the fields: gross_area - wing gross area [meters**2] span - span of the wing [meters] taper - taper ratio of the wing [dimensionless] t_c - thickness-to-chord ratio of the wing [dimensionless] sweep - sweep angle of the wing [radians] mac - mean aerodynamic chord of the wing [meters] r_c - wing root chord [meters] aircraft - a data dictionary with the fields: Nult - ultimate load of the aircraft [dimensionless] Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless] TOW - maximum takeoff weight of the aircraft [kilograms] zfw - maximum zero fuel weight of the aircraft [kilograms] num_eng - number of engines on the aircraft [dimensionless] num_pax - number of passengers on the aircraft [dimensionless] wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms] num_seats - number of seats installed on the aircraft [dimensionless] ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless] ac - determines type of instruments, electronics, and operating items based on types: "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless] w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters] fuselage - a data dictionary with the fields: area - fuselage wetted area [meters**2] diff_p - Maximum fuselage pressure differential [Pascal] width - width of the fuselage [meters] height - height of the fuselage [meters] length - length of the fuselage [meters] horizontal area - area of the horizontal tail [meters**2] span - span of the horizontal tail [meters] sweep - sweep of the horizontal tail [radians] mac - mean aerodynamic chord of the horizontal tail [meters] t_c - thickness-to-chord ratio of the horizontal tail [dimensionless] exposed - exposed area ratio for the horizontal tail [dimensionless] vertical area - area of the vertical tail [meters**2] span - sweight = weight * Units.lbpan of the vertical [meters] t_c - thickness-to-chord ratio of the vertical tail [dimensionless] sweep - sweep angle of the vertical tail [radians] t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless] Outputs: output - a data dictionary with fields: wt_payload - weight of the passengers plus baggage and paid cargo [kilograms] wt_pax - weight of all the passengers [kilogram] wt_bag - weight of all the baggage [kilogram] wt_fuel - weight of the fuel carried[kilogram] wt_empty - operating empty weight of the aircraft [kilograms] Assumptions: calculated aircraft weight from correlations created per component of historical aircraft """ # Unpack inputs Nult = vehicle.envelope.ultimate_load Nlim = vehicle.envelope.limit_load TOW = vehicle.mass_properties.max_takeoff wt_zf = vehicle.mass_properties.max_zero_fuel num_pax = vehicle.passengers wt_cargo = vehicle.mass_properties.cargo num_seats = vehicle.fuselages.Fuselage.number_coach_seats ctrl_type = vehicle.systems.control ac_type = vehicle.systems.accessories if not vehicle.propulsors.has_key('Turbo Fan'): wt_engine_jet = 0.0 wt_propulsion = 0.0 warnings.warn("There is no Turbo Fan Engine Weight being added to the Configuration", stacklevel=1) else: num_eng = vehicle.propulsors['Turbo Fan'].number_of_engines thrust_sls = vehicle.propulsors['Turbo Fan'].thrust.design wt_engine_jet = Propulsion.engine_jet(thrust_sls) wt_propulsion = Propulsion.integrated_propulsion(wt_engine_jet,num_eng) S_gross_w = vehicle.reference_area #S_gross_w = vehicle.wings['Main Wing'].Areas.reference if not vehicle.wings.has_key('Main Wing'): wt_wing = 0.0 wing_c_r = 0.0 warnings.warn("There is no Wing Weight being added to the Configuration", stacklevel=1) else: b = vehicle.wings['Main Wing'].spans.projected lambda_w = vehicle.wings['Main Wing'].taper t_c_w = vehicle.wings['Main Wing'].thickness_to_chord sweep_w = vehicle.wings['Main Wing'].sweep mac_w = vehicle.wings['Main Wing'].chords.mean_aerodynamic wing_c_r = vehicle.wings['Main Wing'].chords.root wt_wing = wing_main(S_gross_w,b,lambda_w,t_c_w,sweep_w,Nult,TOW,wt_zf) vehicle.wings['Main Wing'].mass_properties.mass = wt_wing S_fus = vehicle.fuselages.Fuselage.areas.wetted diff_p_fus = vehicle.fuselages.Fuselage.differential_pressure w_fus = vehicle.fuselages.Fuselage.width h_fus = vehicle.fuselages.Fuselage.heights.maximum l_fus = vehicle.fuselages.Fuselage.lengths.total if not vehicle.wings.has_key('Horizontal Stabilizer'): wt_tail_horizontal = 0.0 S_h = 0.0 warnings.warn("There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1) else: S_h = vehicle.wings['Horizontal Stabilizer'].areas.reference b_h = vehicle.wings['Horizontal Stabilizer'].spans.projected sweep_h = vehicle.wings['Horizontal Stabilizer'].sweep mac_h = vehicle.wings['Horizontal Stabilizer'].chords.mean_aerodynamic t_c_h = vehicle.wings['Horizontal Stabilizer'].thickness_to_chord h_tail_exposed = vehicle.wings['Horizontal Stabilizer'].areas.exposed / vehicle.wings['Horizontal Stabilizer'].areas.wetted l_w2h = vehicle.wings['Horizontal Stabilizer'].origin[0] + vehicle.wings['Horizontal Stabilizer'].aerodynamic_center[0] - vehicle.wings['Main Wing'].origin[0] - vehicle.wings['Main Wing'].aerodynamic_center[0] #Need to check this is the length of the horizontal tail moment arm wt_tail_horizontal = tail_horizontal(b_h,sweep_h,Nult,S_h,TOW,mac_w,mac_h,l_w2h,t_c_h, h_tail_exposed) vehicle.wings['Horizontal Stabilizer'].mass_properties.mass = wt_tail_horizontal if not vehicle.wings.has_key('Vertical Stabilizer'): output_3 = Data() output_3.wt_tail_vertical = 0.0 output_3.wt_rudder = 0.0 S_v = 0.0 warnings.warn("There is no Vertical Tail Weight being added to the Configuration", stacklevel=1) else: S_v = vehicle.wings['Vertical Stabilizer'].areas.reference b_v = vehicle.wings['Vertical Stabilizer'].spans.projected t_c_v = vehicle.wings['Vertical Stabilizer'].thickness_to_chord sweep_v = vehicle.wings['Vertical Stabilizer'].sweep t_tail = vehicle.wings['Vertical Stabilizer'].t_tail output_3 = tail_vertical(S_v,Nult,b_v,TOW,t_c_v,sweep_v,S_gross_w,t_tail) vehicle.wings['Vertical Stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder # process # Calculating Empty Weight of Aircraft wt_landing_gear = landing_gear(TOW) wt_fuselage = tube(S_fus, diff_p_fus,w_fus,h_fus,l_fus,Nlim,wt_zf,wt_wing,wt_propulsion, wing_c_r) output_2 = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type) # Calculate the equipment empty weight of the aircraft wt_empty = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_2.wt_systems + \ wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder) vehicle.fuselages.Fuselage.mass_properties.mass = wt_fuselage # packup outputs output = payload(TOW, wt_empty, num_pax,wt_cargo) output.wing = wt_wing output.fuselage = wt_fuselage output.propulsion = wt_propulsion output.landing_gear = wt_landing_gear output.systems = output_2.wt_systems output.wt_furnish = output_2.wt_furnish output.horizontal_tail = wt_tail_horizontal output.vertical_tail = output_3.wt_tail_vertical output.rudder = output_3.wt_rudder return output
line_title = f"the {line.capitalize()} Line" station_list = [] line_names = t.getLines(False) line_ids = t.getLines(True) if line != "all": if line.lower() != "dlr": print( "--------------------------------------------NON-DLR------------------------------------" ) id_num = line_names.index(line.title()) line_id = line_ids[id_num] station_list = t.getStationsOnLine(line_id) else: print( "--------------------------------------------DLR------------------------------------" ) station_list = t.getDlrStations() print(station_list) else: station_list = t.getAllStations(False) station_result = [] for item in station_list: station_result.append("<tr><td>" + item + "</td></tr>") return str(page).format(''.join(result), line_title, ''.join(station_result)) if __name__ == "__main__": t = tube.tube() cherrypy.quickstart(tube_app(), config="config.txt")
import tube reload(tube) sim1 = '/Users/dcollins/Enzo/dave_vs_enzo_COSMOLOGY_UP/run/Cosmology/MHDZeldovichPancake' sim2 = '/Users/dcollins/Enzo/dave_vs_enzo_COSMOLOGY_UP/run/Cosmology/MHDCTZeldovichPancake' coord = (0.505, 0.505) frame_list = [0] #ds_list = [yt.load("%s/DD%04d/data%04d"%(sim,frame,frame)) for frame in frame_list] #rays = [ds.ortho_ray(0,coord) for ds in ds_list] for this_frame in [0, 20]: frame_list = [this_frame] ds_list = [ yt.load("%s/DD%04d/data%04d" % (sim1, frame, frame)) for frame in frame_list ] ds_list += [ yt.load("%s/DD%04d/mhdct%04d" % (sim2, frame, frame)) for frame in frame_list ] outname = 'with_a_in_pressure_%d.pdf' % frame fields = ['density', 'pressure', 'By', 'x-velocity'] y = tube.tube(ds_list, fields=fields, filename=outname, legend=True) #, renorm=renorm,filename = "sine"+".png") if 0: print outname #print rays[0]['magnetic_energy']/rays[2]['magnetic_energy'] print rays[0]['magnetic_energy'] / rays[2]['magnetic_energy'] print "print rays[1]['magnetic_energy']/rays[3]['magnetic_energy']" x = rays[0]['density'] / rays[2]['density'] print "densty 0", x.min(), x.max()
from pylab import * import numpy as np import scikits.audiolab import tube import scipy.io.wavfile #x = arange(0, 1, 0.01) ret = scikits.audiolab.wavread("/Users/shaoduo/Desktop/dsp_presentation/eg.wav") #ret = scipy.io.wavfile.read("/Users/shaoduo/Desktop/dsp_presentation/eg.wav") x = ret[1] subplot(3, 1, 1) plot(x) for i in range(0, len(x)): x[i] = x[i] / 2**15 y = tube.tube(x, 3.0, 1.0, 150.0, 0.8, 0.8, 0.6) #y = tube.symclip(x) #y = tube.expdist(x, 10.0, 0.8) scikits.audiolab.wavwrite(y, "/Users/shaoduo/Desktop/dsp_presentation/eg-d.wav", fs=44100, enc='pcm16') #scipy.io.wavfile.write("/Users/shaoduo/Desktop/dsp_presentation/eg-d.wav", 44100, y) subplot(3, 1, 2) plot(y) xy = abs(x) - abs(y) subplot(3, 1, 3) plot(xy) show()
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import yt import tube ds_list = [yt.load("DD%04d/data%04d"%(frame,frame)) for frame in [0,1]] tube.tube(ds_list, legend = True, delta=False, fields=['density','Metal_Density'],filename = 'tube.pdf',labels=['DD%04d'%n for n in [0,1]])
] all_ds += ds_list print(all_ds) g = ds_list[0].index.grids[0] data = g renorm = {'density': 1, 'pressure': 0.6, 'TotalEnergy': 0.9} #renorm = False #this_ray = ray_info.get(i,ray_info_default) print(this_ray) y = tube.tube( ds_list, return_ray=False, delta=False, fields=fields, renorm=renorm, filename= outname, # "Tube_%s%s.png"%(sim,"_%s"*len(fields)%tuple(fields)), #labels=fields, plot_args={'marker': '*'}, legend=True, labels=sim_list, ylim_method='monotonic', yscale={'density': 'linear'}, **this_ray) #y=tube.tube(all_ds, return_ray=False, delta=False, fields=fields, renorm=renorm, # filename = "TUBE_many",# "Tube_%s%s.png"%(sim,"_%s"*len(fields)%tuple(fields)), # #labels=fields, # plot_args={'marker':'*'},legend=True, labels=sim_list+sim_list+sim_list)
import tube reload(tube) base_dir = '/Users/dcollins/Enzo/enzo-dev/run/MHD/1D/' bw_ded = '%s/BrioWu-MHD-1D'%base_dir bw_ct = '%s/BrioWu-MHD-1D-MHDCT'%base_dir bw_cbremoval = '/Users/dcollins/Enzo/dave_vs_enzo_CenteredBremoval/run/MHD/1D/BrioWu-MHD-1D-MHDCT-CenteredBremoval' bw_ct_fid = '/Users/dcollins/Enzo/dave_vs_enzo_CenteredBremoval/run/MHD/1D/BrioWu-MHD-1D-MHDCT' frame = 1 fields=['density','pressure','TotalEnergy','x-velocity', 'By' ]#,'x-velocity'] fields += ['ByF','Bz', 'velocity_y','velocity_z'] BWfields = ['density','x-velocity','By'] fields = BWfields extra=2 frame=11 #set_name = 'ED%02d_%04d/Extra%02d_%04d'%(extra,frame,extra,frame) #outname = 'ED%02d_%04d.pdf'%(extra,frame) outname="BW"+"%04d.pdf"%frame set_name = 'DD%04d/data%04d'%(frame,frame) #ds_list = [yt.load("%s/%s"%(sim, set_name)) for sim in [bw_ct_fid,bw_cbremoval]] bw02 = '/scratch1/dcollins/EnzoProjects/E22_DEF_NonCosmo/bw02_ct' bw01 = '/scratch1/dcollins/EnzoProjects/E22_DEF_NonCosmo/bw01_ded' outname = 'E22_wtf.pdf' ds_list = [yt.load("%s/%s"%(sim, set_name)) for sim in [bw01,bw02]] y=tube.tube(ds_list, delta=False, fields=fields, renorm=False,filename =outname ,labels=['bw01','bw02'],legend=True)
#OutputTemplate = "/RD%04d/RedshiftOutput%04d" axis = 1 counter = 0 #fields=['density','TotalEnergy','x-velocity','By','enzo_pressure'] #renorm={'density':1,'pressure':0.6,'TotalEnergy':0.9} for frame in frames: ds_list = [ yt.load(sim_1 + OutputTemplate % (frame, frame)) for sim_1 in sim_list ] y = tube.tube(ds_list, delta=delta, fields=fields, renorm=False, filename='e12_tube_%s_cons_%04d.pdf' % (note, frame), legend=True, labels=labels, xlim=[0.42, 0.58]) if 0: fields_derived = ['thermal_energy', 'pressure', 'BoverRho'] y = tube.tube(ds_list, delta=delta, fields=fields_derived, renorm=False, filename='e12_tube_%s_derived_%04d.pdf' % (note, frame), legend=True, labels=labels)
def process(mobile, message): # extract the first word, and call it "operator" message_array = message.split() operator = message_array[0] data = sessions.retrive_data(mobile) origin = data[1] destination = data[2] req_time = data[3] req_mes = " ".join(message_array[1:]) if len(re.findall("((?<= at )\d{1,2})(:)((?<=:)\d{1,2}).*", req_mes, re.IGNORECASE)) != 0: user_time = re.findall("((?<= at )\d{1,2})(:)((?<=:)\d{1,2}).*", req_mes, re.IGNORECASE)[0] start_time = datetime.datetime.today() start_time = start_time.replace(hour = int(user_time[0])) start_time = start_time.replace(minute = int(user_time[2])) req_time = int((start_time - datetime.datetime(1970,1,1)).total_seconds()) sessions.save_time(number, req_time) #Is the operator "from" if operator == "from": #do we have a stored destination? if destination != None: #google using the rest of the message and the stored destination google_it(mobile, " ".join(message_array[1:]), destination, req_time) # else: else: # save the rest of the message as the origin origin = " ".join(message_array[1:]) sessions.add_origin(mobile, origin) # Request the destination dest_req(mobile) #ok, how about "to" elif operator == "to": process_origin(mobile, " ".join(message_array[1:]), origin, destination, req_time) #if they have asked to reset: elif operator == "reset": sessions.delete(mobile) send_text.text(mobile, "Reset successful!") elif operator == "bus": bus.bus(mobile, " ".join(message_array[1:])) elif operator == "tube": tube.tube(mobile, " ".join(message_array[1:])) #help operator: elif operator == "help": send_text.text(mobile, "Hi! Thanks for using traxt. Our service is simple to use:") time.sleep(3) send_text.text(mobile, "1) If you want directions, send a text containing either the start or end point, formatted like so: ") time.sleep(3) send_text.text(mobile, "To set the destination, send a message starting with \"to\" directly followed by the destination. e.g: \"to London\". You will then be prompted to send your start point, which should be formatted like so: ") time.sleep(3) send_text.text(mobile, "To set the start point of your journey, send a message starting with \"from\", directly followed by the start point. e.g: \"from London\". You will then be prompted to send your destination, which should be formatted as shown above.") time.sleep(3) send_text.text(mobile, "2) If you would like tube or bus status, text \"tube [underground line]\" or \"bus [bus No.]\" ") time.sleep(3) send_text.text(mobile, "By sending \"reset\", your session will be cleared, although it will also be cleared automatically. Thanks for using traxt.") sessions.delete(mobile) # so we don't know the operator. else: # Do we have a saved origin? if origin != None: # then this must be the destination destination = " ".join(message_array) # google using the saved origin and the rest of the message print "Origin is: " +str(origin) +". Type is "+str(type(origin)) print "Destination is: "+str(destination)+". Type is "+str(type(destination)) google_it(mobile, origin, destination, req_time) # we dont have a saved origin, so this must be it else: # save the message as the origin origin = " ".join(message_array) if destination != None: google_it(mobile, origin, destination, req_time) else: sessions.add_origin(mobile, origin) # prompt for the destination dest_req(mobile)
simlist = ['s11'] axis = 0 coord = (0.505, 0.505) counter = 0 #fields=['density','pressure','TotalEnergy','x-velocity', ]#,'x-velocity'] #fields =['%s_p'%s for s in all_x] #fields += ['Bx','By','Bz','magnetic_energy'] #fields += ['magnetic_field_x','magnetic_field_y','magnetic_field_z','magnetic_energy'] #fields +=['x-velocity','y-velocity','z-velocity'] #fields += ['Ltension_x', #fields += ['Badvection_x'] fields = ['density', 'Metal_Density'] #'Temperature', 'TotalEnergy']# , 'metallicity'] ray_set = {} frames = [0, 1] #range(0,10) renorm = {'density': 1, 'pressure': 0.6, 'TotalEnergy': 0.9} for sim in simlist: ds_list = [] ds_list += [ yt.load("%s/DD%04d/data%04d" % (sims[sim], frame, frame)) for frame in frames ] fname = "Tube_%s_dev_%s.pdf" % (sim, "_%s" * len(fields) % tuple(fields)) y = tube.tube(ds_list, legend=True, delta=False, fields=fields, filename=fname, labels=[""] * 100) #, xlim = [0.25,0.75]) #, labels=fields, plot_args={'marker':'*'})
def main(): system("cls") print("Welcome to the JMC Tube & Rail App") print( "\n[1]: View Statuses\n[2]: View Stations\n[3]: View Fares\n[4]: View Lines\n[9]: Sync\n[0]: Exit" ) option = input("Please select an option > ") if option == "1": status() elif option == "2": station() elif option == "3": fares() elif option == "4": lines() elif option == "9": print("\nSyncing...") tube_data.update() rail_data.update() elif option == "0": raise SystemExit else: print("Thats not an option!") input("Press enter to continue... ") main() if __name__ == "__main__": tube_data = tube.tube() rail_data = tube.rail() main()
def empty_custom_eng(vehicle, propulsor): """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical) This is for a standard Tube and Wing aircraft configuration. Inputs: propulsor - a propulsor object mass_properties.mass wing - a data dictionary with the fields: gross_area - wing gross area [meters**2] span - span of the wing [meters] taper - taper ratio of the wing [dimensionless] t_c - thickness-to-chord ratio of the wing [dimensionless] sweep - sweep angle of the wing [radians] mac - mean aerodynamic chord of the wing [meters] r_c - wing root chord [meters] aircraft - a data dictionary with the fields: Nult - ultimate load of the aircraft [dimensionless] Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless] TOW - maximum takeoff weight of the aircraft [kilograms] zfw - maximum zero fuel weight of the aircraft [kilograms] num_eng - number of engines on the aircraft [dimensionless] num_pax - number of passengers on the aircraft [dimensionless] wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms] num_seats - number of seats installed on the aircraft [dimensionless] ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless] ac - determines type of instruments, electronics, and operating items based on types: "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless] w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters] fuselage - a data dictionary with the fields: area - fuselage wetted area [meters**2] diff_p - Maximum fuselage pressure differential [Pascal] width - width of the fuselage [meters] height - height of the fuselage [meters] length - length of the fuselage [meters] horizontal area - area of the horizontal tail [meters**2] span - span of the horizontal tail [meters] sweep - sweep of the horizontal tail [radians] mac - mean aerodynamic chord of the horizontal tail [meters] t_c - thickness-to-chord ratio of the horizontal tail [dimensionless] exposed - exposed area ratio for the horizontal tail [dimensionless] vertical area - area of the vertical tail [meters**2] span - sweight = weight * Units.lbpan of the vertical [meters] t_c - thickness-to-chord ratio of the vertical tail [dimensionless] sweep - sweep angle of the vertical tail [radians] t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless] Outputs: output - a data dictionary with fields: wt_payload - weight of the passengers plus baggage and paid cargo [kilograms] wt_pax - weight of all the passengers [kilogram] wt_bag - weight of all the baggage [kilogram] wt_fuel - weight of the fuel carried[kilogram] wt_empty - operating empty weight of the aircraft [kilograms] Assumptions: calculated aircraft weight from correlations created per component of historical aircraft """ # Unpack inputs #thrust_sls = vehicle.propulsors['Turbo Fan'].thrust.design S_gross_w = vehicle.reference_area #S_gross_w = vehicle.wings['Main Wing'].Areas.reference b = vehicle.wings['Main Wing'].spans.projected lambda_w = vehicle.wings['Main Wing'].taper t_c_w = vehicle.wings['Main Wing'].thickness_to_chord sweep_w = vehicle.wings['Main Wing'].sweep mac_w = vehicle.wings['Main Wing'].chords.mean_aerodynamic wing_c_r = vehicle.wings['Main Wing'].chords.root Nult = vehicle.envelope.ultimate_load Nlim = vehicle.envelope.limit_load TOW = vehicle.mass_properties.max_takeoff wt_zf = vehicle.mass_properties.max_zero_fuel num_pax = vehicle.passengers wt_cargo = vehicle.mass_properties.cargo num_seats = vehicle.fuselages.Fuselage.number_coach_seats ctrl_type = vehicle.systems.control ac_type = vehicle.systems.accessories #l_w2h = vehicle.wings['Horizontal Stabilizer'].position[0] + vehicle.wings['Horizontal Stabilizer'].aerodynamic_center[0] - vehicle.wings['Main Wing'].position[0] - vehicle.wings['Main Wing'].aerodynamic_center[0] #Need to check this is the length of the horizontal tail moment arm l_w2h = vehicle.w2h S_fus = vehicle.fuselages.Fuselage.areas.wetted diff_p_fus = vehicle.fuselages.Fuselage.differential_pressure w_fus = vehicle.fuselages.Fuselage.width h_fus = vehicle.fuselages.Fuselage.heights.maximum l_fus = vehicle.fuselages.Fuselage.lengths.total S_h = vehicle.wings['Horizontal Stabilizer'].areas.reference b_h = vehicle.wings['Horizontal Stabilizer'].spans.projected sweep_h = vehicle.wings['Horizontal Stabilizer'].sweep mac_h = vehicle.wings['Horizontal Stabilizer'].chords.mean_aerodynamic t_c_h = vehicle.wings['Horizontal Stabilizer'].thickness_to_chord h_tail_exposed = vehicle.wings[ 'Horizontal Stabilizer'].areas.exposed / vehicle.wings[ 'Horizontal Stabilizer'].areas.wetted S_v = vehicle.wings['Vertical Stabilizer'].areas.reference b_v = vehicle.wings['Vertical Stabilizer'].spans.projected t_c_v = vehicle.wings['Vertical Stabilizer'].thickness_to_chord sweep_v = vehicle.wings['Vertical Stabilizer'].sweep t_tail = vehicle.wings['Vertical Stabilizer'].t_tail # process # Calculating Empty Weight of Aircraft wt_wing = wing_main(S_gross_w, b, lambda_w, t_c_w, sweep_w, Nult, TOW, wt_zf) wt_landing_gear = landing_gear(TOW) wt_propulsion = propulsor.mass_properties.mass wt_fuselage = tube(S_fus, diff_p_fus, w_fus, h_fus, l_fus, Nlim, wt_zf, wt_wing, wt_propulsion, wing_c_r) output_2 = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type) wt_tail_horizontal = tail_horizontal(b_h, sweep_h, Nult, S_h, TOW, mac_w, mac_h, l_w2h, t_c_h, h_tail_exposed) output_3 = tail_vertical(S_v, Nult, b_v, TOW, t_c_v, sweep_v, S_gross_w, t_tail) # Calculate the equipment empty weight of the aircraft wt_empty = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_2.wt_systems + \ wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder) vehicle.wings['Main Wing'].mass_properties.mass = wt_wing vehicle.wings[ 'Horizontal Stabilizer'].mass_properties.mass = wt_tail_horizontal vehicle.wings[ 'Vertical Stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder vehicle.fuselages.Fuselage.mass_properties.mass = wt_fuselage #vehicle.propulsors['Turbo Fan'].mass_properties.mass = wt_engine_jet # packup outputs output = payload(TOW, wt_empty, num_pax, wt_cargo) output.wing = wt_wing output.fuselage = wt_fuselage output.propulsion = wt_propulsion output.landing_gear = wt_landing_gear output.systems = output_2.wt_systems output.wt_furnish = output_2.wt_furnish output.horizontal_tail = wt_tail_horizontal output.vertical_tail = output_3.wt_tail_vertical output.rudder = output_3.wt_rudder return output
#df.loc[:, 'num_bends_quantity'] = (df['num_bends'] / df['quantity']) ** (1/3) #df.loc[:, 'bend_ratio'] = ((df['num_bends'] * df['bend_radius']) / df['quantity']) ** (1/3) # train.loc[:, 'inv_diameter'] = train['diameter'].apply(utils.make_inv) # test.loc[:, 'inv_diameter'] = test['diameter'].apply(utils.make_inv) return df print('reading train data') data = pd.read_csv('../competition_data/train_set.csv', parse_dates=[2, ]) data = data[data['quantity'] != 2500] #data = data[data['annual_usage'] != 150000] # tube data tube_data = pd.read_csv('../competition_data/tube.csv') tube_data = tube.tube(tube_data) data = pd.merge(data, tube_data, on='tube_assembly_id') data = specs.specs(data) data = bill_of_material.bill_of_material(data) #data.loc[:, 'diameter'] = (data['diameter'] / data['quantity']) ** (1/3) #data.loc[:, 'length_quantity'] = (data['length'] / data['quantity']) ** (1/3) #data.loc[:, 'wall_quantity'] = (data['wall'] / data['quantity']) ** (1/3) #data.loc[:, 'volume_quantity'] = (data['volume'] / data['quantity']) feature_importance = {} if not test: scores = [] for train, test in train_test(data, unique_split_label='tube_assembly_id'): #print('train', train.head())
# train.loc[:, 'inv_diameter'] = train['diameter'].apply(utils.make_inv) # test.loc[:, 'inv_diameter'] = test['diameter'].apply(utils.make_inv) return df print('reading train data') data = pd.read_csv('../competition_data/train_set.csv', parse_dates=[ 2, ]) data = data[data['quantity'] != 2500] #data = data[data['annual_usage'] != 150000] # tube data tube_data = pd.read_csv('../competition_data/tube.csv') tube_data = tube.tube(tube_data) data = pd.merge(data, tube_data, on='tube_assembly_id') data = specs.specs(data) data = bill_of_material.bill_of_material(data) #data.loc[:, 'diameter'] = (data['diameter'] / data['quantity']) ** (1/3) #data.loc[:, 'length_quantity'] = (data['length'] / data['quantity']) ** (1/3) #data.loc[:, 'wall_quantity'] = (data['wall'] / data['quantity']) ** (1/3) #data.loc[:, 'volume_quantity'] = (data['volume'] / data['quantity']) feature_importance = {} if not test: scores = [] for train, test in train_test(data, unique_split_label='tube_assembly_id'): #print('train', train.head())
def empty(vehicle): """ This is for a standard Tube and Wing aircraft configuration. Assumptions: calculated aircraft weight from correlations created per component of historical aircraft Source: N/A Inputs: engine - a data dictionary with the fields: thrust_sls - sea level static thrust of a single engine [Newtons] wing - a data dictionary with the fields: gross_area - wing gross area [meters**2] span - span of the wing [meters] taper - taper ratio of the wing [dimensionless] t_c - thickness-to-chord ratio of the wing [dimensionless] sweep - sweep angle of the wing [radians] mac - mean aerodynamic chord of the wing [meters] r_c - wing root chord [meters] aircraft - a data dictionary with the fields: Nult - ultimate load of the aircraft [dimensionless] Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless] TOW - maximum takeoff weight of the aircraft [kilograms] zfw - maximum zero fuel weight of the aircraft [kilograms] num_eng - number of engines on the aircraft [dimensionless] num_pax - number of passengers on the aircraft [dimensionless] wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms] num_seats - number of seats installed on the aircraft [dimensionless] ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless] ac - determines type of instruments, electronics, and operating items based on types: "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless] w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters] fuselage - a data dictionary with the fields: area - fuselage wetted area [meters**2] diff_p - Maximum fuselage pressure differential [Pascal] width - width of the fuselage [meters] height - height of the fuselage [meters] length - length of the fuselage [meters] horizontal area - area of the horizontal tail [meters**2] span - span of the horizontal tail [meters] sweep - sweep of the horizontal tail [radians] mac - mean aerodynamic chord of the horizontal tail [meters] t_c - thickness-to-chord ratio of the horizontal tail [dimensionless] exposed - exposed area ratio for the horizontal tail [dimensionless] vertical area - area of the vertical tail [meters**2] span - sweight = weight * Units.lbpan of the vertical [meters] t_c - thickness-to-chord ratio of the vertical tail [dimensionless] sweep - sweep angle of the vertical tail [radians] t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless] Outputs: output - a data dictionary with fields: wt_payload - weight of the passengers plus baggage and paid cargo [kilograms] wt_pax - weight of all the passengers [kilogram] wt_bag - weight of all the baggage [kilogram] wt_fuel - weight of the fuel carried [kilogram] wt_empty - operating empty weight of the aircraft [kilograms] Properties Used: N/A """ # Unpack inputs Nult = vehicle.envelope.ultimate_load Nlim = vehicle.envelope.limit_load TOW = vehicle.mass_properties.max_takeoff wt_zf = vehicle.mass_properties.max_zero_fuel num_pax = vehicle.passengers wt_cargo = vehicle.mass_properties.cargo num_seats = vehicle.fuselages['fuselage'].number_coach_seats ctrl_type = vehicle.systems.control ac_type = vehicle.systems.accessories propulsor_name = vehicle.propulsors.keys()[0] #obtain the key for the propulsor for assignment purposes propulsors = vehicle.propulsors[propulsor_name] num_eng = propulsors.number_of_engines if propulsor_name=='turbofan' or propulsor_name=='Turbofan': # thrust_sls should be sea level static thrust. Using design thrust results in wrong propulsor # weight estimation. Engine sizing should return this value. # for now, using thrust_sls = design_thrust / 0.20, just for optimization evaluations thrust_sls = propulsors.sealevel_static_thrust wt_engine_jet = Propulsion.engine_jet(thrust_sls) wt_propulsion = Propulsion.integrated_propulsion(wt_engine_jet,num_eng) propulsors.mass_properties.mass = wt_propulsion else: #propulsor used is not a turbo_fan; assume mass_properties defined outside model wt_propulsion = propulsors.mass_properties.mass if wt_propulsion==0: warnings.warn("Propulsion mass= 0 ;e there is no Engine Weight being added to the Configuration", stacklevel=1) S_gross_w = vehicle.reference_area if not vehicle.wings.has_key('main_wing'): wt_wing = 0.0 wing_c_r = 0.0 warnings.warn("There is no Wing Weight being added to the Configuration", stacklevel=1) else: b = vehicle.wings['main_wing'].spans.projected lambda_w = vehicle.wings['main_wing'].taper t_c_w = vehicle.wings['main_wing'].thickness_to_chord sweep_w = vehicle.wings['main_wing'].sweeps.quarter_chord mac_w = vehicle.wings['main_wing'].chords.mean_aerodynamic wing_c_r = vehicle.wings['main_wing'].chords.root wt_wing = wing_main.wing_main(S_gross_w,b,lambda_w,t_c_w,sweep_w,Nult,TOW,wt_zf) vehicle.wings['main_wing'].mass_properties.mass = wt_wing S_fus = vehicle.fuselages['fuselage'].areas.wetted diff_p_fus = vehicle.fuselages['fuselage'].differential_pressure w_fus = vehicle.fuselages['fuselage'].width h_fus = vehicle.fuselages['fuselage'].heights.maximum l_fus = vehicle.fuselages['fuselage'].lengths.total if not vehicle.wings.has_key('horizontal_stabilizer'): wt_tail_horizontal = 0.0 S_h = 0.0 warnings.warn("There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1) else: S_h = vehicle.wings['horizontal_stabilizer'].areas.reference b_h = vehicle.wings['horizontal_stabilizer'].spans.projected sweep_h = vehicle.wings['horizontal_stabilizer'].sweeps.quarter_chord mac_h = vehicle.wings['horizontal_stabilizer'].chords.mean_aerodynamic t_c_h = vehicle.wings['horizontal_stabilizer'].thickness_to_chord h_tail_exposed = vehicle.wings['horizontal_stabilizer'].areas.exposed / vehicle.wings['horizontal_stabilizer'].areas.wetted l_w2h = vehicle.wings['horizontal_stabilizer'].origin[0] + vehicle.wings['horizontal_stabilizer'].aerodynamic_center[0] - vehicle.wings['main_wing'].origin[0] - vehicle.wings['main_wing'].aerodynamic_center[0] #Need to check this is the length of the horizontal tail moment arm wt_tail_horizontal = tail_horizontal(b_h,sweep_h,Nult,S_h,TOW,mac_w,mac_h,l_w2h,t_c_h, h_tail_exposed) vehicle.wings['horizontal_stabilizer'].mass_properties.mass = wt_tail_horizontal if not vehicle.wings.has_key('vertical_stabilizer'): output_3 = Data() output_3.wt_tail_vertical = 0.0 output_3.wt_rudder = 0.0 S_v = 0.0 warnings.warn("There is no Vertical Tail Weight being added to the Configuration", stacklevel=1) else: S_v = vehicle.wings['vertical_stabilizer'].areas.reference b_v = vehicle.wings['vertical_stabilizer'].spans.projected t_c_v = vehicle.wings['vertical_stabilizer'].thickness_to_chord sweep_v = vehicle.wings['vertical_stabilizer'].sweeps.quarter_chord t_tail = vehicle.wings['vertical_stabilizer'].t_tail output_3 = tail_vertical(S_v,Nult,b_v,TOW,t_c_v,sweep_v,S_gross_w,t_tail) vehicle.wings['vertical_stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder # Calculating Empty Weight of Aircraft wt_landing_gear = landing_gear.landing_gear(TOW) wt_fuselage = tube(S_fus, diff_p_fus,w_fus,h_fus,l_fus,Nlim,wt_zf,wt_wing,wt_propulsion, wing_c_r) output_2 = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type) # Calculate the equipment empty weight of the aircraft wt_empty = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_2.wt_systems + \ wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder) vehicle.fuselages['fuselage'].mass_properties.mass = wt_fuselage # packup outputs output = payload.payload(TOW, wt_empty, num_pax,wt_cargo) output.wing = wt_wing output.fuselage = wt_fuselage output.propulsion = wt_propulsion output.landing_gear = wt_landing_gear output.horizontal_tail = wt_tail_horizontal output.vertical_tail = output_3.wt_tail_vertical output.rudder = output_3.wt_rudder output.systems = output_2.wt_systems output.systems_breakdown = Data() output.systems_breakdown.control_systems = output_2.wt_flt_ctrl output.systems_breakdown.apu = output_2.wt_apu output.systems_breakdown.hydraulics = output_2.wt_hyd_pnu output.systems_breakdown.instruments = output_2.wt_instruments output.systems_breakdown.avionics = output_2.wt_avionics output.systems_breakdown.optionals = output_2.wt_opitems output.systems_breakdown.electrical = output_2.wt_elec output.systems_breakdown.air_conditioner = output_2.wt_ac output.systems_breakdown.furnish = output_2.wt_furnish #define weights components try: landing_gear_component=vehicle.landing_gear #landing gear previously defined except AttributeError: # landing gear not defined landing_gear_component=SUAVE.Components.Landing_Gear.Landing_Gear() vehicle.landing_gear=landing_gear_component control_systems = SUAVE.Components.Physical_Component() electrical_systems= SUAVE.Components.Physical_Component() passengers = SUAVE.Components.Physical_Component() furnishings = SUAVE.Components.Physical_Component() air_conditioner = SUAVE.Components.Physical_Component() fuel = SUAVE.Components.Physical_Component() apu = SUAVE.Components.Physical_Component() hydraulics = SUAVE.Components.Physical_Component() optionals = SUAVE.Components.Physical_Component() rudder = SUAVE.Components.Physical_Component() avionics = SUAVE.Components.Energy.Peripherals.Avionics() #assign output weights to objects landing_gear_component.mass_properties.mass = output.landing_gear control_systems.mass_properties.mass = output.systems_breakdown.control_systems electrical_systems.mass_properties.mass = output.systems_breakdown.electrical passengers.mass_properties.mass = output.pax + output.bag furnishings.mass_properties.mass = output.systems_breakdown.furnish avionics.mass_properties.mass = output.systems_breakdown.avionics \ + output.systems_breakdown.instruments air_conditioner.mass_properties.mass = output.systems_breakdown.air_conditioner fuel.mass_properties.mass = output.fuel apu.mass_properties.mass = output.systems_breakdown.apu hydraulics.mass_properties.mass = output.systems_breakdown.hydraulics optionals.mass_properties.mass = output.systems_breakdown.optionals rudder.mass_properties.mass = output.rudder #assign components to vehicle vehicle.control_systems = control_systems vehicle.electrical_systems = electrical_systems vehicle.avionics = avionics vehicle.furnishings = furnishings vehicle.passenger_weights = passengers vehicle.air_conditioner = air_conditioner vehicle.fuel = fuel vehicle.apu = apu vehicle.hydraulics = hydraulics vehicle.optionals = optionals vehicle.landing_gear = landing_gear_component vehicle.wings['vertical_stabilizer'].rudder = rudder return output