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()
# ) # 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 plt.plot(V_range, D_inc, '-r', label='Drag (incompressible)') plt.plot(V_range, D_com, '--r', label='Drag (compressible)') plt.plot(V_range, [T_a / 1000 for i in range(V_range.shape[0])], '-b', label='Thrust Available')