예제 #1
0
파일: s2.py 프로젝트: ElieGrnr/Projet_avion
 def q2():
     lm = np.linspace(Ma[0], Ma[1])
     n = len(lm)
     for i, ms_i in enumerate(ms):
         for j, km_i in enumerate(km):
             PLANE.set_mass_and_static_margin(km_i, ms_i)
             F0 = np.zeros(n)
             F1 = np.zeros(n)
             for k, m_i in enumerate(lm):
                 va0 = dynamic.va_of_mach(m_i, h[0])
                 va1 = dynamic.va_of_mach(m_i, h[1])
                 X0, U0 = dynamic.trim(PLANE, {'va': va0, 'h': h[0]})
                 X1, U1 = dynamic.trim(PLANE, {'va': va1, 'h': h[1]})
                 F0[k] = dynamic.propulsion_model(X0, U0, PLANE)
                 F1[k] = dynamic.propulsion_model(X1, U1, PLANE)
             plt.subplot(2, 2, i + 2 * j + 1)
             plt.plot(lm, F0, label="$h={}$".format(h[0]))
             plt.plot(lm, F1, label="$h={}$".format(h[1]))
             plt.legend()
             plt.title("$m_s={}, k_m={}$".format(ms_i, km_i))
             plt.xlabel("$M_a$")
             plt.ylabel("$F$")
     plt.tight_layout(.5)
     plt.savefig(file + "q2" + format)
     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)
def plot_thrust(P, filename=None):
    figure = ut.prepare_fig(None, u'Poussée {}'.format(P.name))
    hs = np.linspace(3000, 11000, 5)
    for h in hs:
        Machs = np.linspace(0.5, 0.8, 30)
        thrusts = np.zeros(len(Machs))
        for i in range(0, len(Machs)):
            thrusts[i] = dyn.propulsion_model([0, h, dyn.va_of_mach(Machs[i], h), 0, 0, 0], [0, 1., 0, 0], P)
        plt.plot(Machs, thrusts)
    ut.decorate(plt.gca(), u'Poussée maximum {}'.format(P.name), r'Mach', '$N$', 
                ['{} m'.format(h) for h in hs])
    if filename<> None: plt.savefig(filename, dpi=160)
    return figure
def evol_poussee(P):
    U = [0, 1, 0, 0]
    hs = np.linspace(3000, 11000, 5)
    machs = np.linspace(0.5, 0.8, 30)
    for h in hs:
        Poussee = [
            dyn.propulsion_model([0, h, dyn.va_of_mach(mach, h), 0, 0, 0], U,
                                 P) for mach in machs
        ]
        plt.plot(machs, Poussee)
    ut.decorate(plt.gca(),
                title='Poussée maximale en fonction du Mach',
                xlab='Mach',
                ylab='Poussee (N)',
                legend=['{} m'.format(h) for h in hs])
    plt.show()
예제 #5
0
                        'gamm': 0.,
                        'h': l
                    })
                    alphatrim[ib, jb, kb, lb] = X[3]
                    dphrtrim[ib, jb, kb, lb] = U[0]
                    dthtrim[ib, jb, kb, lb] = U[1]
            for kbb, k in enumerate(Ma1):
                for lbb, l in enumerate(h):
                    va_h0b = dynamic.va_of_mach(k, l, k=1.4, Rs=287.05)
                    Xb, Ub = dynamic.trim(avion, {
                        'va': va_h0b,
                        'gamm': 0.,
                        'h': l
                    })
                    prop[ib, jb, kbb,
                         lbb] = dynamic.propulsion_model(Xb, Ub, avion)

    affiche()
    '''''' '''''' ''''''

    # question 3

    valeur_trim = alphatrim[0, 0, 0, 0], dphrtrim[0, 0, 0, 0], dthtrim[0, 0, 0,
                                                                       0]
    point_trim = [3000.0, 0.4, -0.2, 0.1]

    h_trim, Ma_trim, ms_trim, km_trim = point_trim
    p_trim, rho_trim, T_trim = utils.isa(h_trim)
    avion.set_mass_and_static_margin(km_trim, ms_trim)
    va_trim = dynamic.va_of_mach(Ma_trim, h_trim, k=1.4, Rs=287.05)
예제 #6
0
# calcul de va en m/s
va = dy.va_of_mach(mac, h)

# calcul de rho
rho = ut.isa(h)[1]

args = {}
args['h'] = h
args['va'] = dy.va_of_mach(mac, h)  # conv mach en m/s
X, U = dy.trim(P, args)
alpha16 = X[3]  # alpha en radians
dphr16 = U[0]  # delta PHR en radians
dth16 = U[1]  # thrust de 0 à 1

# calcul de la poussée pour le point de trim 16
F16 = dy.propulsion_model(X, U, P)

# calcul de CL16, la val du CL au point de trim16
CL16 = 2 * (P.m * P.g - math.sin(alpha16)) / ((rho * np.power(va, 2) * P.S))

print("valeurs obtenues via la fonction trim.")
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.
예제 #7
0
alphatrim = np.zeros((len(h), len(Ma), len(ms), len(km)))
dphrtrim = np.zeros((len(h), len(Ma), len(ms), len(km)))
dthtrim = np.zeros((len(h), len(Ma), len(ms), len(km)))
prop = np.zeros((len(h), len(Ma), len(ms), len(km)))

for ib, i in enumerate(ms):
    for jb, j in enumerate(km):
        avion.set_mass_and_static_margin(j, i)
        for kb, k in enumerate(Ma):
            for lb, l in enumerate(h):
                va_h0 = dynamic.va_of_mach(k, l, k=1.4, Rs=287.05)
                X, U = dynamic.trim(avion, {'va': va_h0, 'gamm': 0., 'h': l})
                alphatrim[ib, jb, kb, lb] = X[3]
                dphrtrim[ib, jb, kb, lb] = U[0]
                dthtrim[ib, jb, kb, lb] = U[1]
                prop[ib, jb, kb, lb] = dynamic.propulsion_model(X, U, avion)


def affiche():
    for i in range(len(ms)):
        for j in range(len(km)):
            for k in range(len(Ma)):
                plt.suptitle('ms=' + str(ms[i]) + ', km=' + str((km[j])))
                plt.subplot(1, 4, 1)
                plt.title("alpha")
                plt.plot(h,
                         utils.deg_of_rad(alphatrim[i, j, k, :]),
                         label="Mach = " + str(Ma[k]) + "")
                plt.ylabel('alpha en degre')
                plt.xlabel('altitude')
                plt.legend()
def question_1():
    trims = get_all_trims(aircraft, hs, Mas, sms, kms)
    plot_trims(aircraft)
    trim_select = trims[0]
    plot_traj_trim(aircraft,trim_select[0][1], Mas[1], sms[1], kms[1])
    print(dyn.propulsion_model(trim_select[0],trim_select[1],aircraft))