コード例 #1
0
def main():
    # This function runs the vortex panel method on a NACA 2412
    
    # Generate airfoil coordinates
    airfoil_coordinates = NACA4('2412', 50)
        
    x_airfoil = airfoil_coordinates[:, 0]
    y_airfoil = airfoil_coordinates[:, 1]
    
    # Set the angle of attack
    alpha = 10

    # Run the vortex panel method
    x, cp, cl, cm = vortex_panel_method(alpha, airfoil_coordinates)
    
    # Print the values of cl and cm in the terminal 
    print('C_l = ', cl)
    print('C_m = ', cm)
    
    # Plot the pressure distribution
    plot_cp(x, cp, x_airfoil, y_airfoil)
    
    # Plot the lift coefficient and moment coefficient versus angle of attack
    plot_polar(airfoil_coordinates)
コード例 #2
0
def plot_polar(coordinates, alpha_begin=-10, alpha_end=20, samples=31, use_TeX=False):
    """ TODO: Add description
    """
    
    blue = [0.118, 0.506, 0.984, 1]
    #cyan = [0.129, 0.996, 0.996, 1]
    #green = [0.118, 0.988, 0.133, 1]
    #orange = [0.992, 0.596, 0.118, 1]
    red = [0.988, 0.047, 0.082, 1]
    
    alpha_range = np.linspace(alpha_begin, alpha_end, samples)
    
    cl = np.zeros(np.size(alpha_range))
    cm = np.zeros(np.size(alpha_range))
    
    for i in range(np.size(alpha_range)):
        x, cp, cl[i], cm[i] = vortex_panel_method(alpha_range[i], coordinates)
    
    plt.figure(num='Lift Coefficient and Moment Coefficient versus Angle of Attack', figsize=(6, 6), dpi=100)
    ax = plt.gca()
    
    if use_TeX:
        plt.rc('font', **{'family': 'serif', 'serif': ['Palatino']})
        plt.rc('text', usetex=True)
    
    # Use no labels for minor ticks
    yLocator = MultipleLocator(0.1)
    majorFormatter = FormatStrFormatter('%d')
    xLocator = MultipleLocator(1)
    ax.yaxis.set_minor_locator(yLocator)
    ax.xaxis.set_minor_locator(xLocator)
    
    # Plot the data
    plt.plot(alpha_range, cl, color=blue, label=r'$C_l$')
    plt.plot(alpha_range, cm, color=red, label=r'$C_m$')
    plt.legend(loc='center right', frameon=False)
    plt.ylabel('$C_l / C_m$ $[-]$', fontsize=16)
    plt.xlabel(r'$\alpha$ $[deg]$', fontsize=16)
    plt.xlim(-8, 20)
    plt.ylim(-1.0, 2.5)
    plt.xticks(np.linspace(-8, 20, 8))
    plt.yticks(np.array([-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5]))
    
    # Hide the right and top spines
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    
    # Only show ticks on the left and bottom spines
    ax.spines['left'].set_position('zero')
    ax.spines['bottom'].set_position('zero')
    ax.yaxis.set_ticks_position('left')
    ax.xaxis.set_ticks_position('bottom')
    ax.xaxis.labelpad = 20
    
    # Hide the tick label at the origin
    yticks = ax.get_yticklabels()
    yticks[2].set_visible(False)
    xticks = ax.xaxis.get_major_ticks()
    xticks[2].set_visible(False)
    
    #plt.savefig('name.pdf', format = 'pdf', dpi = 1000, bbox_inches='tight')
    plt.show()