Asignatura: Vehículos aeroespaciales
Departamento: Ciencia y Tecnología de Materiales y Fluidos
Centro: Escuela Universitaria Politécnica de Teruel
Profesor: Adrián Navas Montilla
import numpy as np
import matplotlib.pyplot as plt
import math
from ipywidgets import interact, IntSlider, fixed
def airfoilNACA(m,p,t,c,n):
m = m / 100
p = p / 10
t = t / 100
# x distribution (cosine spacing)
theta = np.linspace(0, np.pi, n)
x = 0.5 * c * (1 - np.cos(theta))
x_hat = x / c # normalized x
# Thickness distribution
yt = 5 * t * ( 0.2969 * np.sqrt(x_hat) - 0.1260 * x_hat - 0.3516 * x_hat**2 + 0.2843 * x_hat**3 - 0.1015 * x_hat**4 )
# Camber line and slope
z = np.zeros_like(x)
dzdx = np.zeros_like(x)
for i in range(len(x)):
if x_hat[i] < p and p != 0:
z[i] = (m / p**2) * (2 * p * x_hat[i] - x_hat[i]**2)
dzdx[i] = (2 * m / p**2) * (p - x_hat[i])
elif p != 0:
z[i] = (m / (1 - p)**2) * ((1 - 2 * p) + 2 * p * x_hat[i] - x_hat[i]**2)
dzdx[i] = (2 * m / (1 - p)**2) * (p - x_hat[i])
beta = np.arctan(dzdx)
# Upper and lower airfoil coordinates
xu = x - yt * np.sin(beta)
yu = z + yt * np.cos(beta)
xl = x + yt * np.sin(beta)
yl = z - yt * np.cos(beta)
# Combine and plot
x_total = np.concatenate([xu[::-1], xl[1:]])
y_total = np.concatenate([yu[::-1], yl[1:]])
plt.figure(figsize=(10, 4))
plt.plot(x_total, y_total, 'k-', linewidth=1.5, label="Airfoil")
plt.plot(x, z, 'r--', linewidth=1.2, label="Camber line")
plt.axis('equal')
plt.title(f"NACA {m*100:.0f}{p*10:.0f}{t*100:.0f}")
plt.xlabel("x/c")
plt.ylabel("y/c")
plt.grid(True)
plt.legend()
plt.show()
return x_total, y_total
# Airfoil function
def plot_airfoil(m,p,t,c,n):
airfoilNACA(m,p,t,c,n) # ignoramos el return
# Interactive sliders
interact(
plot_airfoil,
m=IntSlider(min=0, max=9, step=1, value=2, description="m"),
p=IntSlider(min=0, max=9, step=1, value=4, description="p"),
t=IntSlider(min=10, max=40, step=1, value=12, description="t"),
c=fixed(1.0), # cuerda
n=fixed(200) # número de puntos
)
plot_airfoil
def plot_airfoil(m, p, t, c, n)
<no docstring>