def evol_dphre(P): mss = [-0.1, 0, 0.2, 1] alphas = np.arange(ut.rad_of_deg(-10), ut.rad_of_deg(20), ut.rad_of_deg(1)) km = 0.1 for ms in mss: P.set_mass_and_static_margin(km, ms) dphrs = [] dphrs = np.array([(P.ms * P.CLa * (alpha - P.a0) - P.Cm0) / P.Cmd for alpha in alphas]) plt.plot(ut.deg_of_rad(alphas), ut.deg_of_rad(dphrs)) legends = ['ms {}'.format(ms) for ms in mss] ut.decorate(plt.gca(), "Evolution de DPHRe en fonction de l'incidence", 'Incidence', 'Delta de braquage équilibré', legend=legends) plt.figure() Vts = [0.9, 1, 1.1] for Vt in Vts: P.Vt = Vt P.Cmd = -P.Vt * P.CLat dphrs = np.array([(P.ms * P.CLa * (alpha - P.a0) - P.Cm0) / P.Cmd for alpha in alphas]) plt.plot(ut.deg_of_rad(alphas), ut.deg_of_rad(dphrs)) legends = ['Vt {}'.format(Vt) for Vt in Vts] ut.decorate(plt.gca(), "Evolution de DPHRe en fonction de l'incidence", 'Incidence', 'Delta de braquage équilibré', legend=legends) plt.show()
def polaire_equi(P): q = 0 mss = [0.2, 1] alphas = np.arange(ut.rad_of_deg(-10), ut.rad_of_deg(20), ut.rad_of_deg(1)) km = 0.1 for ms in mss: P.set_mass_and_static_margin(km, ms) dphrs = [] dphrs = np.array([(P.ms * P.CLa * (alpha - P.a0) - P.Cm0) / P.Cmd for alpha in alphas]) CLe = [] CLe = [ dyn.get_aero_coefs(dyn.va_of_mach(0.7, 7000), alpha, q, dphr, P)[0] for alpha, dphr in zip(alphas, dphrs) ] Cxe = [ dyn.get_aero_coefs(dyn.va_of_mach(0.7, 7000), alpha, q, dphr, P)[1] for alpha, dphr in zip(alphas, dphrs) ] finesse = [CL / Cx for Cx, CL in zip(Cxe, CLe)] fmax = np.max(finesse) idmax = np.argmax(finesse) print(fmax) plt.plot([0, Cxe[idmax]], [0, CLe[idmax]]) plt.plot(Cxe, CLe) label1 = patches.Patch(color='blue', label='fmax (ms = 0.2)') label2 = patches.Patch(color='green', label='Polaire (ms = 0.2)') label3 = patches.Patch(color='red', label='fmax (ms = 1)') label4 = patches.Patch(color='cyan', label='Polaire (ms = 1)') plt.legend(loc='upper left', handles=[label1, label2, label3, label4]) ut.decorate(plt.gca(), "Evolution de la polaire équilibrée", 'Coefficient de trainée équilibrée', 'Coefficient de portance équilibrée') plt.show
def run_trajecotry(time, h, Ma, ms, km, Wh=2): Xe, Ue = get_trim(aircraft, h, Ma, ms, km) fmt = r'Trim: h={:.1f}, Ma={:.1f}, ms={:.1f}, km={:.1f} -> $\alpha$={:.1f}, $\delta_{{PHR}}$={:.1f}, $\delta_{{th}}$={:.1f}' print fmt.format(h, Ma, ms, km, ut.rad_of_deg(Xe[dyn.s_a]), ut.rad_of_deg(Ue[dyn.i_dm]), Ue[dyn.i_dth]) X = NonLinearTraj(aircraft, h, Ma, ms, km, Wh, time) Xlin = LinearTraj(aircraft, h, Ma, ms, km, Wh, time) figure = dyn.plot(time, X) dyn.plot(time, Xlin, figure=figure)
def plot_CL(P, filename=None): alphas = np.linspace(ut.rad_of_deg(-10), ut.rad_of_deg(20), 30) dms = np.linspace(ut.rad_of_deg(20), ut.rad_of_deg(-30), 3) figure = ut.prepare_fig(None, u'Coefficient de Portance {}'.format(P.name)) for dm in dms: plt.plot(ut.deg_of_rad(alphas), CL(P, alphas, dm)) ut.decorate(plt.gca(), u'Coefficient de Portance', r'$\alpha$ en degres', '$C_L$') plt.legend(['$\delta _{{PHR}} = ${:.1f}'.format(ut.deg_of_rad(dm)) for dm in dms], loc='best') if filename<> None: plt.savefig(filename, dpi=160)
def plot_Cm(P, filename=None): alphas = np.linspace(ut.rad_of_deg(-10), ut.rad_of_deg(20), 30) mss = np.array([-0.1, 0, 0.2, 1]) figure = ut.prepare_fig(None, u'Coefficient du moment de tangage {}'.format(P.name)) for ms1 in mss: plt.plot(ut.deg_of_rad(alphas), Cm(P, alphas, ms1)) ut.decorate(plt.gca(), u'Coefficient du moment de tangage', r'$\alpha$ en degres', '$C_m$') plt.legend(['ms = {}'.format(ms) for ms in mss], loc='best') if filename<> None: plt.savefig(filename, dpi=160)
def plot_dphr_e(P, filename=None): alphas = np.linspace(ut.rad_of_deg(-10), ut.rad_of_deg(20), 30) mss = [-0.1, 0., 0.2, 1.] figure = ut.prepare_fig(None, u'Équilibre {}'.format(P.name)) for ms in mss: P.set_mass_and_static_margin(0.5, ms) dmes = np.array([dphr_e(P, alpha) for alpha in alphas]) plt.plot(ut.deg_of_rad(alphas), ut.deg_of_rad(dmes)) ut.decorate(plt.gca(), r'$\delta_{PHR_e}$', r'$\alpha$ en degres', r'$\delta_{PHR_e}$ en degres', ['$ms = ${: .1f}'.format(ms) for ms in mss])
def plot_CLe(P): alphas = np.linspace(ut.rad_of_deg(-10), ut.rad_of_deg(20), 30) figure = ut.prepare_fig(None, u'Coefficient de portance équilibrée {}'.format(P.name)) sms = [0.2, 1] for sm in sms: P.set_mass_and_static_margin(0.5, sm) dphres = [dphr_e(P, alpha) for alpha in alphas] CLes = [CL(P, alpha, dphr) for alpha, dphr in zip(alphas, dphres)] plt.plot(ut.deg_of_rad(alphas), CLes) ut.decorate(plt.gca(), u'Coefficient de portance équilibrée', r'$\alpha$ en degres', r'$CL_e$', ['$ms = ${: .1f}'.format(sm) for sm in sms])
def plot_polar(P): alphas = np.linspace(ut.rad_of_deg(-10), ut.rad_of_deg(20), 30) figure = ut.prepare_fig(None, u'Polaire équilibrée{}'.format(P.name)) sms = [0.2, 1] for sm in sms: P.set_mass_and_static_margin(0.5, sm) dphres = [dphr_e(P, alpha) for alpha in alphas] CLes = [CL(P, alpha, dphr) for alpha, dphr in zip(alphas, dphres)] CDes = [P.CD0 + P.ki * CL1**2 for CL1 in CLes] plt.plot(CDes, CLes) ut.decorate(plt.gca(), u'Polaire équilibrée', r'$CD_e$', r'$CL_e$', ['$ms = ${: .1f}'.format(sm) for sm in sms])
def __init__(self): self.g = 9.81 self.m_k = 0.5 self.ms = 0.3 # static margin # aero self.a0 = ut.rad_of_deg(-2.) # zero lift angle self.CD0 = 0.025 # zero drag coefficient self.Cm0 = -0.59 # zero moment coefficient self.CLq = 1.3
def trim(P, args=None): va = args.get('va', 100.) gamma = args.get('gamma', 0.) h = args.get('h', 5000.) wy, wz = 0, 0 def err_func((dm, dth, alpha)): theta = gamma + alpha U = np.array([dm, dth, wy, wz]) X = np.array([0., h, va, alpha, theta, 0]) L, D, M = get_aero_forces_and_moments(X, U, P) F = propulsion_model(X, U, P) cg, sg = math.cos(gamma), math.sin(gamma) ca, sa = math.cos(alpha), math.sin(alpha) return [(F*ca-D)/P.m-P.g*sg, -(L+F*sa)/P.m + P.g*cg, M] p0 = [ut.rad_of_deg(0.), 0.5, ut.rad_of_deg(1.)] sol = scipy.optimize.root(err_func, p0, method='hybr') dm, dth, alpha = sol.x X, U = [0, h, va, alpha, gamma+alpha, 0], [dm, dth, 0, 0] return X, U
def evol_Cm(P): ms = [-0.1, 0, 0.2, 1] dphr = 0 alphas = np.arange(ut.rad_of_deg(-10), ut.rad_of_deg(20), ut.rad_of_deg(1)) Cm_tab1 = [] Cm_tab2 = [] Cm_tab3 = [] Cm_tab4 = [] q = 0 for alpha in alphas: Cm1 = P.Cm0 - ms[0] * P.CLa * (alpha - P.a0) + P.Cmq * P.lt / dyn.va_of_mach( 0.7, 7000) * q + P.Cmd * dphr Cm_tab1.append(Cm1) Cm2 = P.Cm0 - ms[1] * P.CLa * (alpha - P.a0) + P.Cmq * P.lt / dyn.va_of_mach( 0.7, 7000) * q + P.Cmd * dphr Cm_tab2.append(Cm2) Cm3 = P.Cm0 - ms[2] * P.CLa * (alpha - P.a0) + P.Cmq * P.lt / dyn.va_of_mach( 0.7, 7000) * q + P.Cmd * dphr Cm_tab3.append(Cm3) Cm4 = P.Cm0 - ms[3] * P.CLa * (alpha - P.a0) + P.Cmq * P.lt / dyn.va_of_mach( 0.7, 7000) * q + P.Cmd * dphr Cm_tab4.append(Cm4) plt.plot(ut.deg_of_rad(alphas), Cm_tab1) plt.plot(ut.deg_of_rad(alphas), Cm_tab2) plt.plot(ut.deg_of_rad(alphas), Cm_tab3) plt.plot(ut.deg_of_rad(alphas), Cm_tab4) label1 = patches.Patch(color='blue', label='ms = -0.1') label2 = patches.Patch(color='green', label='ms = 0') label3 = patches.Patch(color='red', label='ms = 0.2') label4 = patches.Patch(color='cyan', label='ms = 1') plt.legend(loc='upper right', handles=[label1, label2, label3, label4]) ut.decorate(plt.gca(), title="Evolution du Cm en fonction de l'incidence", xlab='Incidence', ylab='Cm') plt.show()
def trim(P, args=None): va = args.get('va', 100.) gamma = args.get('gamma', 0.) h = args.get('h', 5000.) wy, wz = 0, 0 def err_func(arg): (dm, dth, alpha) = arg theta = gamma + alpha U = np.array([dm, dth, wy, wz]) X = np.array([0., h, va, alpha, theta, 0]) L, D, M = get_aero_forces_and_moments(X, U, P) F = propulsion_model(X, U, P) cg, sg = math.cos(gamma), math.sin(gamma) ca, sa = math.cos(alpha), math.sin(alpha) return [(F * ca - D) / P.m - P.g * sg, -(L + F * sa) / P.m + P.g * cg, M] p0 = [ut.rad_of_deg(0.), 0.5, ut.rad_of_deg(1.)] sol = scipy.optimize.root(err_func, p0, method='hybr') dm, dth, alpha = sol.x X, U = [0, h, va, alpha, gamma + alpha, 0], [dm, dth, 0, 0] return X, U
def evol_CLe(P): q = 0 mss = [0.2, 1] alphas = np.arange(ut.rad_of_deg(-10), ut.rad_of_deg(20), ut.rad_of_deg(1)) km = 0.1 for ms in mss: P.set_mass_and_static_margin(km, ms) dphrs = [] dphrs = np.array([(P.ms * P.CLa * (alpha - P.a0) - P.Cm0) / P.Cmd for alpha in alphas]) CLe = [] CLe = [ dyn.get_aero_coefs(dyn.va_of_mach(0.7, 7000), alpha, q, dphr, P)[0] for alpha, dphr in zip(alphas, dphrs) ] plt.plot(ut.deg_of_rad(alphas), CLe) label1 = patches.Patch(color='blue', label='ms = 0.2') label2 = patches.Patch(color='green', label='ms = 1') plt.legend(loc='upper left', handles=[label1, label2]) ut.decorate(plt.gca(), "Evolution de CLe en fonction de l'incidence", 'Incidence', 'Coefficient de portance équilibrée') plt.show
def evol_coeff_portance(P): alphas = np.arange(ut.rad_of_deg(-10), ut.rad_of_deg(20), ut.rad_of_deg(1)) dphrs = [ut.rad_of_deg(-30), ut.rad_of_deg(20)] q = 0 Cz_tab1 = [] Cz_tab2 = [] for alpha in alphas: coeff_portance1 = dyn.get_aero_coefs(dyn.va_of_mach(0.7, 7000), alpha, q, dphrs[0], P) Cz_tab1.append(coeff_portance1[0]) coeff_portance2 = dyn.get_aero_coefs(dyn.va_of_mach(0.7, 7000), alpha, q, dphrs[1], P) Cz_tab2.append(coeff_portance2[0]) plt.plot(ut.deg_of_rad(alphas), Cz_tab1, 'r') plt.plot(ut.deg_of_rad(alphas), Cz_tab2, 'b') label1 = patches.Patch(color='red', label='dPHR1 = -30°') label2 = patches.Patch(color='blue', label='dPHR2 = 20°') plt.legend(loc='upper left', handles=[label1, label2]) ut.decorate(plt.gca(), title="Evolution du Cz en fonction de l'incidence", xlab='Incidence', ylab='Cz') plt.show()
def plot_trims(aircraft, gamma=0., saturate=True): ''' Affichage de trims sous forme de surfaces colorées ''' vs = np.linspace(60, 350, 21, endpoint=True) hs = np.linspace(1000, 14000, 21, endpoint=True) trims = np.zeros((len(hs), len(vs), 2)) for i,v in enumerate(vs): for j,h in enumerate(hs): Xe, Ue = dyn.trim(aircraft, args = {'va': v, 'h': h, 'gamma': gamma}) trims[j, i] = Xe[dyn.s_a], tons_of_newton(dyn.propulsion_model([0, h, v, 0, 0, 0], [0, Ue[dyn.i_dth], 0, 0], aircraft)) if saturate: alpha_c, T_c = trims[j,i][0], trims[j,i,1] alpha_max = ut.rad_of_deg(15) if alpha_c > alpha_max: trims[j,i][0] = 1e16 trims[j,i][1] = 1e16 Tmax = tons_of_newton(dyn.propulsion_model([0, h, v, 0, 0, 0], [0, 1, 0, 0], aircraft)) if T_c > Tmax: trims[j,i, 0] = 1e16 trims[j,i, 1] = 1e16 fig = plt.figure(figsize=(0.75*20.48, 0.5*10.24)) ax = plt.subplot(1,2,1) thetas_deg = ut.deg_of_rad(trims[:, :, 0]) v = np.linspace(0, 15, 16, endpoint=True) plt.contour(vs, hs, thetas_deg, v, linewidths=0.5, colors='k') plt.contourf(vs, hs, thetas_deg, v, cmap=plt.cm.jet) ax.set_title(u'$\\alpha$ (degrés)') ax.xaxis.set_label_text('vitesse (m/s)') ax.yaxis.set_label_text('altitude (m)') plt.colorbar(ticks=v) ax = plt.subplot(1,2,2) T_tons = trims[:, :, 1] #/9.81/1000. v = np.linspace(2, 10, 17, endpoint=True) plt.contour(vs, hs, T_tons, v, linewidths=0.5, colors='k') plt.contourf(vs, hs, T_tons, v, cmap=plt.cm.jet) ax.set_title('thrust (tons)') ax.xaxis.set_label_text('vitesse (m/s)') ax.yaxis.set_label_text('altitude (m)') plt.colorbar(ticks=v)
print("alpha16 = ", alpha16, " rad") print("angle réglage PHR dphr16 = ", dphr16, " rad") print("Gaz ou thrust dth16 = ", dth16) print("CL16 = ", CL16) # 4.2.2.4 Conclure quant à la technique de réglage de la vitesse de l’avion. # >>>> pour augmenter la vitesse, il faut diminuer CL donc alphae donc augmenter algébriquement # l'angle du PHR pour augmenter la portance ou diminuer la déportance. # 4.2.2.5 - Utiliser la valeur de CL obtenue ainsi que les graphiques tracés lors de la première séance # pour déterminer (approximativement) les valeurs de trim αe et δPHRe . print( "La valeur de alphae obtenue via le graphique de la séance 1 CLe=f(alphae) est ", ut.rad_of_deg(6.7)) print( "La valeur de dphre obtenue via le graphique dphre = f(alphae) de la séance 1 en utilisant la valeur de alphae précédente est -0.21rad" ) # 4.2.2.6 - Comment obtenir la valeur de trim de la manette des gaz δth à partir de la polaire équilibrée ? # connaissant CL16=CLe = 0.57 la polaire équilibrée donne CDe = 0.038 donc f = CLe/CDe donc D = mg/f ; # on utilise F = Fmax * delta-th = D, i.e. poussee = trainee, pour calculer deltath # le graphe de poussée donne Fmax = 50128N # delta_th = D/Fmax # par le calcul on delta_th = 0.67 ; par la méthode graphique on a delta_th=0.0.70 CLe = CL16 CDe = 0.038 f = CLe / CDe # calcul du coef de poussée tel que F = coef * deltath