File size: 1,755 Bytes
369c880
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
"""
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():
    # Create a figure with two subplots
    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))
    
    # Example 1: NACA 4-digit airfoil
    naca_params = {
        "m": 0.02,      # Maximum camber
        "p": 0.4,       # Position of maximum camber
        "t": 0.12,      # Maximum thickness
        "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']})")
    
    # Example 2: Kulfan (CST) airfoil
    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")
    
    # Adjust layout and show the plot
    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")
    
    # Example of how to access the first few coordinates
    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()