def _load(path, atmosphere=std_atm_earth()): data = {} with open(path) as f: data = json.load(f) engine = data.get('engine', {}) engine_name = engine.get('name', None) # If name is specified, look for it in the engine database # Then fall-back on database values if they're not given in the plane.json file engine_in_db = engine_db.get(engine_name, {}) if engine_name is not None else {} T_a_sl = engine.get('thrust', engine_in_db.get('thrust', None)) cost_engines = engine.get('cost', engine_in_db.get('cost', None)) engine_count = data.get('engine_count', 1) if T_a_sl is not None: T_a_sl *= engine_count if cost_engines is not None: cost_engines *= engine_count weight = data.get('weight', {'struct': 0, 'fuel': 0, 'payload': 0}) W_struct = weight.get('struct', 0) W_fuel = weight.get('fuel', 0) W_payload = weight.get('payload', 0) W_engines = engine.get('weight', engine_in_db.get('weight', 0)) * engine_count cost_struct = data.get('cost', None) if (cost_struct is not None) and (cost_engines is not None): cost_struct -= cost_engines plane = Plane( data.get('Cd_0', None), data.get('e_w', None), data.get('S', None), data.get('b', None), data.get('Cl_max', None), data.get('Lam', None), data.get('tc_max', None), W_struct, W_fuel, W_engines, W_payload, engine.get('cj', engine_in_db.get('cj', None)), T_a_sl, data.get('n_struct', None), atmosphere, ) plane._description = data.get('description', None) plane._cost_engines = cost_engines plane._cost_struct = cost_struct return plane
velocities) plt.cla() plt.clf() plt.plot(velocities, P_a_0, '--b', label='P_a @ h = 0m') plt.plot(velocities, P_r_0, '-b', label='P_r @ h = 0m') plt.plot(velocities, P_a_45, '--r', label='P_a @ h = 4500m') plt.plot(velocities, P_r_45, '-r', label='P_r @ h = 4500m') plt.title('Power Available and Power Required for the F-117') plt.xlabel('Velocity, V [m/s]') plt.ylabel('Power [W]') plt.legend(loc='upper right') plt.show() if __name__ == '__main__': from haydens_code.atmosphere import std_atm_earth from haydens_code.plane import Plane # Initialize atmosphere object atm = std_atm_earth() # Initialize F-117 Warthog plane object plane = Plane(0.042, None, 0.84, 84.8 / 13.2, 13.2, 1.2, None, None, 187000, 0.0, None, 96000, atm) # plane = Plane(187000, 13.2, 84.8/13.2, 0.042, 0.84, 1.2, 96000) QUESTION_2() QUESTION_3()
# tc_max=0.11, # W_0=88100, # W_fuel=33200, # cj=0.60, # T_a_sl=32500, # atmosphere=std_atm_earth() # ) # Initialize MD-11 plane object plane = Plane(Cd_0=0.018, Em=None, e=0.85, chord=339 / 51.8, span=51.8, Cl_max=1.4, Lam=35.0, tc_max=0.12, W_0=2710000, W_fuel=None, cj=None, T_a_sl=800000, atmosphere=std_atm_earth()) """QUESTION 1 PLOT""" plane.set_altitude(0) # meters T_a = plane.jet_thrust_available() # N V_limits = plane.speed_min_max(T_a) # m/s V_range = np.arange(V_limits[0, 0], V_limits[1, 0] + 5, 5) Cd_inc = plane.Cd(plane.Cd_i(plane.Cl(V_range))) Cd_com = Cd_inc + plane.Cd_c(plane.Cl(V_range), V_range) D_inc = plane.drag(Cd_inc, V_range) / 1000 D_com = plane.drag(Cd_com, V_range) / 1000
import sys sys.path.append('..') if __name__ == '__main__': from haydens_code.atmosphere import std_atm_earth from haydens_code.plane import Plane # Initialize The Global Flyer plane object plane = Plane( Cd_0=0.016, Em=None, e=0.94, chord=37.2 / 34.8,# MAC span=34.8, Cl_max=1.2, Lam=None, tc_max=None, W_0=98000, W_1=14900, cj=0.42, T_a_sl=10200, atmosphere=std_atm_earth() ) plane.set_altitude_range(500, 10000, 100) drag = plane.drag(plane.Cd(plane.Cd_i(plane.Cl(80))), 80) t_a = plane.jet_thrust_available() R_C = 80*(t_a - drag)/98000 print(R_C) plane.set_altitude(10000)
import sys sys.path.append('..') if __name__ == '__main__': from haydens_code.atmosphere import std_atm_earth from haydens_code.plane import Plane # Initialize atmosphere object atm = std_atm_earth() # Initialize B-2 Spirit plane object plane = Plane(1420000, 52.4, 9.1, 0.0090, 0.92, 1.22) # Generate data at requested altitudes altitudes = [] speed_const_Cl = [] speed_stall = [] drag_const_Cl = [] drag_210 = [] for i in range(0, 20001, 500): plane.set_altitude(i) altitudes.append(i) density = atm.density_at(i) speed_stall.append(plane.speed_stall()) speed = plane.speed(plane.Cl_min_drag) speed_const_Cl.append(speed) Cd_min = plane.Cd(plane.Cd_i(plane.Cl_min_drag)) drag_const_Cl.append(plane.drag(Cd_min, speed))
import numpy as np import matplotlib.pyplot as plt if __name__ == '__main__': from haydens_code.atmosphere import std_atm_earth from haydens_code.plane import Plane # Initialize Boeing 777-200 plane object plane = Plane( Cd_0=0.020, Em=None, e=0.93, chord=423 / 61, # MAC span=61, Cl_max=2.3, Lam=31.6, tc_max=0.13, W_0=2380000, W_1=None, cj=None, T_a_sl=342000 * 2, atmosphere=std_atm_earth()) """QUESTION 1 and 2 PLOTS ---------------------------------------------------------------------------------------""" # FOR 0m -------------------------------------------------------------------------------------------------------- # compute velocity range plane.set_altitude(0) # meters T_a = plane.jet_thrust_available() # N V_limits = plane.speed_min_max(T_a) # m/s V_range = np.arange(V_limits[0, 0], V_limits[1, 0] + 5, 5) # compute drag Cd_inc = plane.Cd(plane.Cd_i(plane.Cl(V_range)))
if __name__ == '__main__': from haydens_code.atmosphere import std_atm_earth from haydens_code.plane import Plane q3 = Plane( Cd_0=0.020, Em=None, e=0.9, chord=1.0, # MAC span=8.0, Cl_max=None, Lam=None, tc_max=None, W_0=1.0, W_1=None, cj=None, T_a_sl=0.2, n_struct=None, atmosphere=std_atm_earth(), ) print(q3.Cd_0) print(q3.AR) print(q3.e_w) print(q3.T_a_sl/q3.W_0) print('') print('n_aero: {}'.format(q3.n_aero)) print('') q4 = Plane( Cd_0=0.020,
import sys sys.path.append('..') if __name__ == '__main__': from haydens_code.atmosphere import std_atm_earth from haydens_code.plane import Plane # Initialize atmosphere object atm = std_atm_earth() # Initialize A-10 Warthog plane object plane = Plane(145000, 17.6, 2.676, 0.032, 0.87, 1.2, 80000) """QUESTION 1 - PART A""" altitude = 11500 # m plane.set_altitude(altitude) density = atm.density_at(altitude) thrust_avail = plane.jet_thrust_available() # Generate data at requested velocities speeds = [] lift_coeffs = [] drag_coeffs = [] drags = [] for speed in range(20, 301, 5): Cl = plane.Cl(speed) Cd = plane.Cd(plane.Cd_i(plane.Cl(speed))) drag = plane.drag(Cd, speed) speeds.append(speed) lift_coeffs.append(Cl) drag_coeffs.append(Cd)