| |
| """ |
| Basic usage example for the airfoil parametrizer. |
| This script demonstrates how to create and visualize airfoils using the parametrizer. |
| """ |
|
|
| import numpy as np |
| import matplotlib.pyplot as plt |
| from airfoil_parametrizer import get_parametrizer |
|
|
| def main(): |
| |
| fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5)) |
| |
| |
| naca_params = { |
| "m": 0.02, |
| "p": 0.4, |
| "t": 0.12, |
| "num_points": 100 |
| } |
| |
| naca_airfoil = get_parametrizer("NACA", **naca_params) |
| naca_airfoil.plot_2d(ax=ax1, color_by_index=True) |
| ax1.set_title(f"NACA Airfoil (m={naca_params['m']}, p={naca_params['p']}, t={naca_params['t']})") |
| |
| |
| kulfan_params = { |
| "a_upper": [0.17, 0.2, 0.1, 0.1], |
| "a_lower": [-0.17, -0.1, -0.05, -0.05], |
| "n_order": 3, |
| "num_points": 100 |
| } |
| |
| kulfan_airfoil = get_parametrizer("KULFAN", **kulfan_params) |
| kulfan_airfoil.plot_2d(ax=ax2, color_by_index=True) |
| ax2.set_title("Kulfan (CST) Airfoil") |
| |
| |
| plt.tight_layout() |
| plt.savefig("airfoil_examples.png", dpi=300) |
| plt.show() |
| |
| print("Airfoil coordinates can be accessed using the get_coordinates() method:") |
| x, y = naca_airfoil.get_coordinates() |
| print(f"NACA airfoil has {len(x)} points") |
| |
| |
| print("\nFirst 5 coordinates of the NACA airfoil:") |
| for i in range(5): |
| print(f"Point {i+1}: ({x[i]:.4f}, {y[i]:.4f})") |
|
|
| if __name__ == "__main__": |
| main() |