-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Description
import numpy as np
import matplotlib.pyplot as plt
Grid (vindtunnel)
nx, ny = 200, 100
x = np.linspace(-2, 4, nx)
y = np.linspace(-1.5, 1.5, ny)
X, Y = np.meshgrid(x, y)
Basis-flow (ensartet vind fra venstre mod højre)
U_inf = 1.0
U = U_inf * np.ones_like(X)
V = np.zeros_like(Y)
Definér en simpel "rytterprofil" som en kombination af cirkler/ellipser
def rider_mask(X, Y):
# Krop (ellipse)
body = ((X - 0.0)2 / 0.252 + (Y - 0.0)2 / 0.52) <= 1.0
# Hoved (cirkel)
head = (X - 0.4)**2 + (Y + 0.3)2 <= 0.122
# Ryg/foroverbøjet (lille ekstra ellipse)
back = ((X - -0.2)2 / 0.32 + (Y + 0.1)2 / 0.252) <= 1.0
# Samlet maske
return body | head | back
mask = rider_mask(X, Y)
"Bloker" flowet inde i rytteren (sæt hastighed til 0)
U_masked = U.copy()
V_masked = V.copy()
U_masked[mask] = 0.0
V_masked[mask] = 0.0
Plot
fig, ax = plt.subplots(figsize=(10, 4))
Baggrund: hastighedsstørrelse
speed = np.sqrt(U_masked2 + V_masked2)
cont = ax.contourf(X, Y, speed, levels=50, cmap="viridis")
Strømlinjer
start_y = np.linspace(-1.2, 1.2, 25)
start_x = -1.8 * np.ones_like(start_y)
ax.streamplot(X, Y, U_masked, V_masked, color="white", linewidth=0.8,
start_points=np.column_stack((start_x, start_y)), density=2)
Tegn rytterens kontur
ax.contour(X, Y, mask, levels=[0.5], colors="red", linewidths=2)
ax.set_aspect("equal")
ax.set_xlabel("x (m)")
ax.set_ylabel("y (m)")
ax.set_title("Simpel virtuel vindtunnel – rytterprofil")
cbar = fig.colorbar(cont, ax=ax, label="Hastighed (relativ)")
plt.tight_layout()
plt.show()