from common import Atmosphere from test.test_library import is_close h_0 = Atmosphere(0) h_40k = Atmosphere(40000) out = list() out.append((is_close(h_0.air_density(), 0.002379))) out.append(is_close(h_40k.air_density(), 0.0005848)) out.append((is_close(h_0.pressure(), 2118.145))) out.append(is_close(h_40k.pressure(), 391.234)) out.append((is_close(h_0.speed_of_sound(), 1116.462))) out.append(is_close(h_40k.speed_of_sound(), 967.723)) out.append((is_close(h_0.viscosity(), 3.737e-07))) out.append(is_close(h_40k.viscosity(), 2.967e-07)) if any(out): print("atmosphere test passed!") else: print("atmosphere test failed")
from common import Gravity from test.test_library import is_close h_0 = Gravity(0) h_40k = Gravity(40000) out = list() out.append((is_close(h_0.gravity(), 32.14894))) out.append(is_close(h_40k.gravity(), 32.026389)) if any(out): print("earth test passed!") else: print("earth test failed")
from numpy import pi mach = 0.3 altitude = 10000 c_l_alpha = 2 * pi x_ref = 5 ar = 5 sweep_le = 30 taper = 0.5 q_e = dynamic_pressure(mach, altitude) c_f = friction_coefficient(mach, altitude, x_ref) re = reynolds_number(mach, altitude, x_ref) c_l_alpha_w = polhamus(c_l_alpha, ar, mach, taper, sweep_le) out = list() out.append((is_close(q_e, 91.83224))) out.append(is_close(c_f, 0.003111)) out.append(is_close(re, 8038249.384)) out.append(is_close(c_l_alpha_w, 4.2811)) mach = 0.6 altitude = 30000 ar = 3 q_e = dynamic_pressure(mach, altitude) c_f = friction_coefficient(mach, altitude, x_ref) re = reynolds_number(mach, altitude, x_ref) c_l_alpha_w = polhamus(c_l_alpha, ar, mach, taper, sweep_le) out.append((is_close(q_e, 158.89079))) out.append(is_close(c_f, 0.00307937))
from src.modeling.trapezoidal_wing import mac, root_chord, span, sweep_x, x_mac, y_chord, y_mac from test.test_library import is_close ar = 5 s = 10 sweep_le = 30 taper = 0.5 c_bar = mac(ar, s, taper) cr = root_chord(ar, s, taper) b = span(ar, s) sweep = sweep_x(ar, taper, sweep_le, 0.5) y = y_mac(ar, s, taper) x = x_mac(3, sweep_le) c = y_chord(0.25, cr, b, taper) out = list() out.append((is_close(c_bar, 1.46659))) out.append(is_close(b, 7.071067)) out.append(is_close(cr, 1.8856)) out.append(is_close(c, 1.81895)) out.append(is_close(x, 1.73205)) out.append(is_close(y, 1.5713)) out.append(is_close(sweep, 23.942)) if any(out): print("trapezoidal wing test passed!") else: print("trapezoidal wing test failed")
'name': 'elevator_l', 'cf_c': 0.3, 'b_1': -0.999, 'b_2': -0.01, }, 'control_2': { 'name': 'elevator_r', 'cf_c': 0.3, 'b_1': 0.01, 'b_2': 0.999, }, } cg = [40, 0, 1] mach = 0.5 c_l = c_f_m_flap(ht, ht['control_1'], mach, cg) c_r = c_f_m_flap(ht, ht['control_2'], mach, cg) c = c_l + c_r out = list() out.append((is_close(c_l[3], 6.1968))) out.append((is_close(c_r[3], -6.1968))) out.append((is_close(c[1], 0))) out.append((is_close(c[2], -1.0188))) out.append((is_close(c[4], -49.36))) if any(out): print("flap test passed!") else: print("flap test failed")
from rotations import angular_rate_rotation, body_to_wind, eci_to_ned, ned_to_body from numpy import pi from test.test_library import is_close e2b = angular_rate_rotation(5 * pi/180, 5 * pi/180) b2w = body_to_wind(5 * pi/180, 5 * pi/180) e2n = eci_to_ned(5 * pi/180, 5 * pi/180) n2b = ned_to_body(5 * pi/180, 5 * pi/180, 5 * pi/180) out = list() out.append(is_close(e2b[0, 0], 1)) out.append(is_close(e2b[1, 1], 0.99619)) out.append(is_close(e2b[2, 2], 1)) out.append(is_close(b2w[0, 0], 0.9924)) out.append(is_close(b2w[1, 1], 0.99619)) out.append(is_close(b2w[2, 2], 0.99619)) out.append(is_close(e2n[0, 0], 0.99619)) out.append(is_close(e2n[1, 1], 0.99619)) out.append(is_close(e2n[2, 2], 0.9924)) out.append(is_close(n2b[0, 0], 0.9924)) out.append(is_close(n2b[1, 1], 0.99306)) out.append(is_close(n2b[2, 2], 0.9924)) if any(out): print("rotation test passed!") else: print("rotation test failed")
'buttline': -30, # [ft] 'thrust_angle': 5, # [deg] 'toe_angle': -2, # [deg] 'diameter': 4, # [ft] 'rpm_max': 10000, # [rpm] 'pitch': 20 # [deg] }, } cg = [43, 0, 2] throttle = [1, 1] x = [100, 30000] p = Propulsion(propulsion, x, throttle, cg) cfm = p.thrust_f_m() out = list() out.append((is_close(cfm[0], 4780.1585))) out.append((is_close(cfm[4], 10220.1982))) out.append((is_close(cfm[3], 0))) throttle = [0.5, 0.5] x = [200, 0] p = Propulsion(propulsion, x, throttle, cg) cfm = p.thrust_f_m() out.append((is_close(cfm[0], 713.781))) out.append((is_close(cfm[4], 1526.0972))) out.append((is_close(cfm[3], 0))) propulsion = { 'n_engines': 1, 'engine_1': { 'type': 'jet',
from Gravity import Gravity from test.test_library import is_close h_0 = Gravity(0) h_40k = Gravity(40000) out = list() out.append((is_close(h_0.gravity(), 32.14894))) out.append(is_close(h_40k.gravity(), 32.026389)) h_0 = Gravity(0).gravity(planet='mars') h_40k = Gravity(40000).gravity(planet='mars') out = list() out.append((is_close(h_0, 12.17927))) out.append(is_close(h_40k, 12.09213)) h_0 = Gravity(0).gravity(planet='jupiter') h_40k = Gravity(40000).gravity(planet='jupiter') out = list() out.append((is_close(h_0, 88.82685))) out.append(is_close(h_40k, 88.79586)) h_0 = Gravity(0).gravity(planet='mercury') h_40k = Gravity(40000).gravity(planet='mercury') out = list() out.append((is_close(h_0, 12.08413))) out.append(is_close(h_40k, 11.96425))
vertical = { 'planform': 50, # [ft^2] } fuselage = { 'width': 10, # [ft] 'height': 10, # [ft] } mach = 0.3 altitude = 20000 w = LiftingSurface(wing) c_l_a = w.c_l_alpha_wing(mach) de_da = w.d_epsilon_d_alpha(horizontal, mach) ac = w.aerodynamic_center() cd0 = w.parasite_drag(mach, altitude) ds_db_v = w.d_sigma_d_beta_vt(vertical, fuselage) ds_db_h = w.d_sigma_d_beta_ht(horizontal, fuselage) out = list() out.append((is_close(c_l_a, 4.23295))) out.append((is_close(de_da, 0.27033))) out.append((is_close(ac, 41.2388))) out.append((is_close(cd0, 0.00766999))) out.append((is_close(ds_db_v, 0.95375))) out.append((is_close(ds_db_h, 1.0715))) if any(out): print("lifting surface test passed!") else: print("lifting surface test failed")