def test_stall1_w_airfoil(self):
        R = 2.4
        r = 0.25*R
        chord = 0.18
        Omega = 200*pi/30
        Uinf = 10.0
        tsr = Omega*R/Uinf

        af = Airfoil([self.polar])
        newaf = af.correction3D(r/R, chord/r, tsr,
                                alpha_max_corr=30,
                                alpha_linear_min=-4,
                                alpha_linear_max=4)

        newpolar = newaf.polars[0]

        cl_3d = [-0.8466, -0.7523, -0.6420, -0.5342, -0.4302, -0.3284,
                 -0.2276, -0.1303, -0.0404, 0.0618, 0.2191, 0.3321, 0.4336,
                 0.5501, 0.6755, 0.7363, 0.8101, 0.8973, 0.9810, 1.0640,
                 1.1450, 1.2098, 1.2682, 1.3281, 1.3731, 1.3088, 1.3159,
                 1.3534, 1.4010, 1.4515, 1.9140, 1.8857, 1.6451]
        cd_3d = [0.0399, 0.0334, 0.0316, 0.0293, 0.0269, 0.0254, 0.0246,
                 0.0246, 0.0246, 0.0252, 0.0249, 0.0200, 0.0167, 0.0157,
                 0.0174, 0.0183, 0.0212, 0.0255, 0.0303, 0.0367, 0.0465,
                 0.0615, 0.0800, 0.1047, 0.1301, 0.1695, 0.2047, 0.2384,
                 0.2728, 0.3081, 0.8097, 1.2625, 1.6280]

        # test equality
        np.testing.assert_allclose(newpolar.cl, cl_3d, atol=1e-3)
        np.testing.assert_allclose(newpolar.cd, cd_3d, atol=1e-3)
Example #2
0
    def test_stall1_w_airfoil(self):
        R = 2.4
        r = 0.25 * R
        chord = 0.18
        Omega = 200 * pi / 30
        Uinf = 10.0
        tsr = Omega * R / Uinf

        af = Airfoil([self.polar])
        newaf = af.correction3D(r / R,
                                chord / r,
                                tsr,
                                alpha_max_corr=30,
                                alpha_linear_min=-4,
                                alpha_linear_max=4)
        _, _, cl_grid, cd_grid, cm_grid = newaf.createDataGrid()

        newpolar = newaf.polars[0]

        cl_3d = [
            -0.8466, -0.7523, -0.6420, -0.5342, -0.4302, -0.3284, -0.2276,
            -0.1303, -0.0404, 0.0618, 0.2191, 0.3321, 0.4336, 0.5501, 0.6755,
            0.7363, 0.8101, 0.8973, 0.9810, 1.0640, 1.1450, 1.2098, 1.2682,
            1.3281, 1.3731, 1.3088, 1.3159, 1.3534, 1.4010, 1.4515, 1.9140,
            1.8857, 1.6451
        ]
        cd_3d = [
            0.0399, 0.0334, 0.0316, 0.0293, 0.0269, 0.0254, 0.0246, 0.0246,
            0.0246, 0.0252, 0.0249, 0.0200, 0.0167, 0.0157, 0.0174, 0.0183,
            0.0212, 0.0255, 0.0303, 0.0367, 0.0465, 0.0615, 0.0800, 0.1047,
            0.1301, 0.1695, 0.2047, 0.2384, 0.2728, 0.3081, 0.8097, 1.2625,
            1.6280
        ]
        cm_test = [[-0.0037], [-0.0044], [-0.0051], [0.0018], [-0.0216],
                   [-0.0282], [-0.0346], [-0.0405], [-0.0455], [-0.0507],
                   [-0.0404], [-0.0321], [-0.0281], [-0.0284], [-0.0322],
                   [-0.0361], [-0.0363], [-0.0393], [-0.0398], [-0.0983],
                   [-0.1242], [-0.1155], [-0.1068], [-0.0981], [-0.0894],
                   [-0.0807], [-0.072], [-0.0633], [-0.054], [-0.045],
                   [-0.036], [-0.22], [-0.13]]

        # test equality
        np.testing.assert_allclose(newpolar.cl, cl_3d, atol=1e-3)
        np.testing.assert_allclose(newpolar.cd, cd_3d, atol=1e-3)
        np.testing.assert_allclose(cm_grid, cm_test, atol=1e-3)
    def test_stall1_w_airfoil(self):
        R = 2.4
        r = 0.25 * R
        chord = 0.18
        Omega = 200 * pi / 30
        Uinf = 10.0
        tsr = Omega * R / Uinf

        af = Airfoil([self.polar])
        newaf = af.correction3D(r / R,
                                chord / r,
                                tsr,
                                alpha_max_corr=30,
                                alpha_linear_min=-4,
                                alpha_linear_max=4)

        newpolar = newaf.polars[0]

        cl_3d = [
            -0.8466, -0.7523, -0.6420, -0.5342, -0.4302, -0.3284, -0.2276,
            -0.1303, -0.0404, 0.0618, 0.2191, 0.3321, 0.4336, 0.5501, 0.6755,
            0.7363, 0.8101, 0.8973, 0.9810, 1.0640, 1.1450, 1.2098, 1.2682,
            1.3281, 1.3731, 1.3088, 1.3159, 1.3534, 1.4010, 1.4515, 1.9140,
            1.8857, 1.6451
        ]
        cd_3d = [
            0.0399, 0.0334, 0.0316, 0.0293, 0.0269, 0.0254, 0.0246, 0.0246,
            0.0246, 0.0252, 0.0249, 0.0200, 0.0167, 0.0157, 0.0174, 0.0183,
            0.0212, 0.0255, 0.0303, 0.0367, 0.0465, 0.0615, 0.0800, 0.1047,
            0.1301, 0.1695, 0.2047, 0.2384, 0.2728, 0.3081, 0.8097, 1.2625,
            1.6280
        ]

        # test equality
        np.testing.assert_allclose(newpolar.cl, cl_3d, atol=1e-3)
        np.testing.assert_allclose(newpolar.cd, cd_3d, atol=1e-3)
Example #4
0
    def generate_af(self):

        af_type = self.airfoil_parameterization_type
        af_parameters = self.airfoil_parameters
        if af_type == 'CST':
            n = len(self.airfoil_parameters[0])
            af = [0]*n
        else:
            n = len(self.airfoil_parameters)
            af = [0]*n

        r_over_R = 0.5
        chord_over_r = 0.15
        tsr = 7.55
        cd_max = 1.5

        for i in range(n):
            x = []
            y = []

            if af_type == 'Coordinates':
                try:
                    f = open(af_parameters[i],'r')
                except:
                    print 'There was an error opening the airfoil file %s'%(af_parameters[i])
                    sys.exit(1)
                for line in f:
                    try:
                        x.append(float(string.split(line)[0]))
                        y.append(float(string.split(line)[1]))
                    except:
                        pass
            elif af_type == 'NACA':
                if len(str(int(af_parameters[i]))) == 4:
                    pts = naca4(str(int(af_parameters[i])), 60)
                elif len(str(int(af_parameters[i] == 5))):
                    pts = naca5(str(int(af_parameters[i])), 60)
                else:
                    'Please input only NACA 4 or 5 series'
                for j in range(len(pts)):
                    x.append(pts[j][0])
                    y.append(pts[j][1])
            elif af_type == 'CST':
                n = len(af_parameters)/2
                wu = np.zeros(n)
                wl = np.zeros(n)
                for j in range(n):
                    wu[j] = af_parameters[j][i]
                    wl[j] = af_parameters[j + n][i]
                # wu, wl = np.split(af_parameters[i], 2)
                w1 = np.average(wl)
                w2 = np.average(wu)
                if w1 < w2:
                    pass
                else:
                    higher = wl
                    lower = wu
                    wl = lower
                    wu = higher
                N = 120
                dz = 0.

                # Populate x coordinates
                x = np.ones((N, 1))
                zeta = np.zeros((N, 1))
                for z in range(0, N):
                    zeta[z] = 2 * pi / N * z
                    if z == N - 1:
                        zeta[z] = 2 * pi
                    x[z] = 0.5*(cos(zeta[z])+1)

                # N1 and N2 parameters (N1 = 0.5 and N2 = 1 for airfoil shape)
                N1 = 0.5
                N2 = 1

                try:
                    zerind = np.where(x == 0)  # Used to separate upper and lower surfaces
                    zerind = zerind[0][0]
                except:
                    zerind = N/2

                xl = np.zeros(zerind)
                xu = np.zeros(N-zerind)

                for z in range(len(xl)):
                    xl[z] = np.real(x[z])            # Lower surface x-coordinates
                for z in range(len(xu)):
                    xu[z] = np.real(x[z + zerind])   # Upper surface x-coordinates

                yl = self.__ClassShape(wl, xl, N1, N2, -dz) # Call ClassShape function to determine lower surface y-coordinates
                yu = self.__ClassShape(wu, xu, N1, N2, dz)  # Call ClassShape function to determine upper surface y-coordinates

                y = np.concatenate([yl, yu])  # Combine upper and lower y coordinates
                y = y[::-1]
                # coord_split = [xl, yl, xu, yu]  # Combine x and y into single output
                # coord = [x, y]
                x1 = np.zeros(len(x))
                for k in range(len(x)):
                    x1[k] = x[k][0]
                x = x1

            else:
                print 'Error. Airfoil parameterization type not specified. Please choose Coordinates, NACA, or CST.'

            if i < 3:
                Re1 = [1e6]
                af[0] = CCAirfoil([-180, 0, 180], Re1, [0, 0, 0], [0.5, 0.5, 0.5])
                af[1] = CCAirfoil([-180, 0, 180], Re1, [0, 0, 0], [0.5, 0.5, 0.5])
                af[2] = CCAirfoil([-180, 0, 180], Re1, [0, 0, 0], [0.35, 0.35, 0.35])
            else:
                coordinate_points = [x, y]
                Re = 1e6
                alphas = np.linspace(-20, 20, 80)
                airfoil = pyXLIGHT.xfoilAnalysis(coordinate_points)
                airfoil.re = Re
                airfoil.mach = 0.03
                airfoil.iter = 1000
                cl = np.zeros(len(alphas))
                cd = np.zeros(len(alphas))
                cm = np.zeros(len(alphas))
                for j in range(len(alphas)):
                    angle = alphas[j]
                    cl[j], cd[j], cm[j], lexitflag = airfoil.solveAlpha(angle)
                    # print cl[j], cd[j], angle
                p1 = Polar(Re, alphas, cl, cd, cm)
                af_p = Airfoil([p1])
                af3D = af_p.correction3D(r_over_R, chord_over_r, tsr)
                af_extrap1 = af3D.extrapolate(cd_max)
                alpha_ext, Re_ext, cl_ext, cd_ext, cm_ext = af_extrap1.createDataGrid()
                af[i] = CCAirfoil(alpha_ext, Re_ext, cl_ext, cd_ext)

        return af
Example #5
0
airfoil1 = Airfoil.initFromAerodynFile("DU21_A17.dat")
airfoil2 = Airfoil.initFromAerodynFile("DU25_A17.dat")

# blend the two airfoils
airfoil_blend = airfoil1.blend(airfoil2, 0.3)

# 3 ---------

# 4 ---------

r_over_R = 0.5
chord_over_r = 0.15
tsr = 5.0

# 3D stall correction
af3D_ex1 = af.correction3D(r_over_R, chord_over_r, tsr)

# a second example using the optional inputs
alpha_max_corr = 25  # apply full rotational correction only up to this angle of attack
alpha_linear_min = -3  # angle of attack to start evaluating slope of linear region
alpha_linear_max = 7  # angle of attack to stop evaluating slope of linear region

af3D_ex2 = af.correction3D(
    r_over_R,
    chord_over_r,
    tsr,
    alpha_max_corr=alpha_max_corr,
    alpha_linear_min=alpha_linear_min,
    alpha_linear_max=alpha_linear_max,
)
    def test_stall1_w_airfoil(self):
        R = 2.4
        r = 0.25 * R
        chord = 0.18
        Omega = 200 * pi / 30
        Uinf = 10.0
        tsr = Omega * R / Uinf

        af = Airfoil([self.polar])
        newaf = af.correction3D(r / R, chord / r, tsr, alpha_max_corr=30, alpha_linear_min=-4, alpha_linear_max=4)
        _, _, cl_grid, cd_grid, cm_grid = newaf.createDataGrid()

        newpolar = newaf.polars[0]

        cl_3d = [
            -0.8466,
            -0.7523,
            -0.6420,
            -0.5342,
            -0.4302,
            -0.3284,
            -0.2276,
            -0.1303,
            -0.0404,
            0.0618,
            0.2191,
            0.3321,
            0.4336,
            0.5501,
            0.6755,
            0.7363,
            0.8101,
            0.8973,
            0.9810,
            1.0640,
            1.1450,
            1.2098,
            1.2682,
            1.3281,
            1.3731,
            1.3088,
            1.3159,
            1.3534,
            1.4010,
            1.4515,
            1.9140,
            1.8857,
            1.6451,
        ]
        cd_3d = [
            0.0399,
            0.0334,
            0.0316,
            0.0293,
            0.0269,
            0.0254,
            0.0246,
            0.0246,
            0.0246,
            0.0252,
            0.0249,
            0.0200,
            0.0167,
            0.0157,
            0.0174,
            0.0183,
            0.0212,
            0.0255,
            0.0303,
            0.0367,
            0.0465,
            0.0615,
            0.0800,
            0.1047,
            0.1301,
            0.1695,
            0.2047,
            0.2384,
            0.2728,
            0.3081,
            0.8097,
            1.2625,
            1.6280,
        ]
        cm_test = [
            [-0.0037],
            [-0.0044],
            [-0.0051],
            [0.0018],
            [-0.0216],
            [-0.0282],
            [-0.0346],
            [-0.0405],
            [-0.0455],
            [-0.0507],
            [-0.0404],
            [-0.0321],
            [-0.0281],
            [-0.0284],
            [-0.0322],
            [-0.0361],
            [-0.0363],
            [-0.0393],
            [-0.0398],
            [-0.0983],
            [-0.1242],
            [-0.1155],
            [-0.1068],
            [-0.0981],
            [-0.0894],
            [-0.0807],
            [-0.072],
            [-0.0633],
            [-0.054],
            [-0.045],
            [-0.036],
            [-0.22],
            [-0.13],
        ]

        # test equality
        np.testing.assert_allclose(newpolar.cl, cl_3d, atol=1e-3)
        np.testing.assert_allclose(newpolar.cd, cd_3d, atol=1e-3)
        np.testing.assert_allclose(cm_grid, cm_test, atol=1e-3)
Example #7
0
airfoil1 = Airfoil.initFromAerodynFile('DU21_A17.dat')
airfoil2 = Airfoil.initFromAerodynFile('DU25_A17.dat')

# blend the two airfoils
airfoil_blend = airfoil1.blend(airfoil2, 0.3)

# 3 ---------

# 4 ---------

r_over_R = 0.5
chord_over_r = 0.15
tsr = 5.0

# 3D stall correction
af3D_ex1 = af.correction3D(r_over_R, chord_over_r, tsr)

# a second example using the optional inputs
alpha_max_corr = 25  # apply full rotational correction only up to this angle of attack
alpha_linear_min = -3  # angle of attack to start evaluating slope of linear region
alpha_linear_max = 7  # angle of attack to stop evaluating slope of linear region

af3D_ex2 = af.correction3D(r_over_R,
                           chord_over_r,
                           tsr,
                           alpha_max_corr=alpha_max_corr,
                           alpha_linear_min=alpha_linear_min,
                           alpha_linear_max=alpha_linear_max)

# 4 ---------