Esempio n. 1
0
    def test_blend1_w_airfoil(self):

        af1 = Airfoil([self.polar1])
        af2 = Airfoil([self.polar2])
        af3 = af1.blend(af2, 0.5)
        polar3 = af3.polars[0]  # kind of bad practice for me to be accessing this

        alpha_blend = [-3.04, -2.03, -1.01, 0.01, 1.03, 2.05, 3.07, 4.09,
                       5.11, 6.13, 7.14, 8.16, 9.17, 10.18, 11.18, 12.19,
                       13.18, 14.18, 15.18, 16.17, 17.14, 18.06, 19.06, 20.07,
                       25]
        cl_blend = [-0.078, 0.048, 0.158, 0.265, 0.372, 0.479, 0.589, 0.695,
                    0.801, 0.894, 0.971, 1.041, 1.101, 1.159, 1.162, 1.205,
                    1.252, 1.225, 1.181, 1.109, 1.045, 0.992, 0.875, 0.877,
                    1.200]
        cd_blend = [0.0134, 0.0117, 0.0125, 0.0147, 0.0150, 0.0154, 0.0162,
                    0.0172, 0.0178, 0.0190, 0.0210, 0.0237, 0.0273, 0.0373,
                    0.0598, 0.0497, 0.0490, 0.0737, 0.0822, 0.1131, 0.1620,
                    0.3101, 0.3101, 0.3101, 0.4000]

        # re-interpolate b/c angles of attack are different
        cl3 = np.interp(alpha_blend, polar3.alpha, polar3.cl)
        cd3 = np.interp(alpha_blend, polar3.alpha, polar3.cd)

        # should be within 1e-3
        np.testing.assert_allclose(cl3, cl_blend, atol=1e-3)
        np.testing.assert_allclose(cd3, cd_blend, atol=1e-3)
Esempio n. 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)

        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)
    def test_blend1_w_airfoil(self):

        af1 = Airfoil([self.polar1])
        af2 = Airfoil([self.polar2])
        af3 = af1.blend(af2, 0.5)
        polar3 = af3.polars[
            0]  # kind of bad practice for me to be accessing this

        alpha_blend = [
            -3.04, -2.03, -1.01, 0.01, 1.03, 2.05, 3.07, 4.09, 5.11, 6.13,
            7.14, 8.16, 9.17, 10.18, 11.18, 12.19, 13.18, 14.18, 15.18, 16.17,
            17.14, 18.06, 19.06, 20.07, 25
        ]
        cl_blend = [
            -0.078, 0.048, 0.158, 0.265, 0.372, 0.479, 0.589, 0.695, 0.801,
            0.894, 0.971, 1.041, 1.101, 1.159, 1.162, 1.205, 1.252, 1.225,
            1.181, 1.109, 1.045, 0.992, 0.875, 0.877, 1.200
        ]
        cd_blend = [
            0.0134, 0.0117, 0.0125, 0.0147, 0.0150, 0.0154, 0.0162, 0.0172,
            0.0178, 0.0190, 0.0210, 0.0237, 0.0273, 0.0373, 0.0598, 0.0497,
            0.0490, 0.0737, 0.0822, 0.1131, 0.1620, 0.3101, 0.3101, 0.3101,
            0.4000
        ]

        # re-interpolate b/c angles of attack are different
        cl3 = np.interp(alpha_blend, polar3.alpha, polar3.cl)
        cd3 = np.interp(alpha_blend, polar3.alpha, polar3.cd)

        # should be within 1e-3
        np.testing.assert_allclose(cl3, cl_blend, atol=1e-3)
        np.testing.assert_allclose(cd3, cd_blend, atol=1e-3)
Esempio n. 4
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)
Esempio n. 5
0
    def test_extrap1_w_airfoil(self):

        cdmax = 1.29
        af = Airfoil([self.polar2])
        newaf = af.extrapolate(cdmax=cdmax)
        newpolar = newaf.polars[0]

        alpha_extrap = [
            -180, -170, -160, -150, -140, -130, -120, -110, -100, -90, -80,
            -70, -60, -50, -40, -30, -20, -10.1, -8.2, -6.1, -4.1, -2.1, 0.1,
            2, 4.1, 6.2, 8.1, 10.2, 11.3, 12.1, 13.2, 14.2, 15.3, 16.3, 17.1,
            18.1, 19.1, 20.1, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130,
            140, 150, 160, 170, 180
        ]
        cl_extrap = [
            0.0000, 0.2299, 0.4597, 0.4907, 0.5053, 0.4805, 0.4102, 0.2985,
            0.1565, 0.0000, -0.1565, -0.2985, -0.4102, -0.4805, -0.5053,
            -0.4907, -0.4637, -0.6300, -0.5600, -0.6400, -0.4200, -0.2100,
            0.0500, 0.3000, 0.5400, 0.7900, 0.9000, 0.9300, 0.9200, 0.9500,
            0.9900, 1.0100, 1.0200, 1.0000, 0.9400, 0.8500, 0.7000, 0.6600,
            0.7010, 0.7219, 0.6864, 0.5860, 0.4264, 0.2235, 0.0000, -0.1565,
            -0.2985, -0.4102, -0.4805, -0.5053, -0.4907, -0.4597, -0.2299,
            0.0000
        ]
        cd_extrap = [
            0.1770, 0.2132, 0.3173, 0.4758, 0.6686, 0.8708, 1.0560, 1.1996,
            1.2818, 1.2900, 1.2818, 1.1996, 1.0560, 0.8708, 0.6686, 0.4758,
            0.3158, 0.0390, 0.0233, 0.0131, 0.0134, 0.0119, 0.0122, 0.0116,
            0.0144, 0.0146, 0.0162, 0.0274, 0.0303, 0.0369, 0.0509, 0.0648,
            0.0776, 0.0917, 0.0994, 0.2306, 0.3142, 0.3186, 0.4758, 0.6686,
            0.8708, 1.0560, 1.1996, 1.2818, 1.2900, 1.2818, 1.1996, 1.0560,
            0.8708, 0.6686, 0.4758, 0.3173, 0.2132, 0.1770
        ]
        cm_extrap = np.linspace(0, 0, len(cd_extrap))

        # re-interpolate b/c angles of attack are different
        cl = np.interp(alpha_extrap, newpolar.alpha, newpolar.cl)
        cd = np.interp(alpha_extrap, newpolar.alpha, newpolar.cd)
        cm = np.interp(alpha_extrap, newpolar.alpha, newpolar.cm)

        # test equality
        np.testing.assert_allclose(cl, cl_extrap, atol=1.5e-4)
        np.testing.assert_allclose(cd, cd_extrap, atol=1.5e-4)
        np.testing.assert_allclose(cm, cm_extrap, atol=5e-3)
Esempio n. 6
0
    def test_extrap1_w_airfoil(self):

        cdmax = 1.29
        af = Airfoil([self.polar])
        newaf = af.extrapolate(cdmax=cdmax)
        newpolar = newaf.polars[0]

        alpha_extrap = [-180, -170, -160, -150, -140, -130, -120, -110, -100,
                        -90, -80, -70, -60, -50, -40, -30, -20, -10.1, -8.2,
                        -6.1, -4.1, -2.1, 0.1, 2, 4.1, 6.2, 8.1, 10.2, 11.3,
                        12.1, 13.2, 14.2, 15.3, 16.3, 17.1, 18.1, 19.1, 20.1,
                        30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140,
                        150, 160, 170, 180]
        cl_extrap = [0.0000, 0.2299, 0.4597, 0.4907, 0.5053, 0.4805, 0.4102,
                     0.2985, 0.1565, 0.0000, -0.1565, -0.2985, -0.4102,
                     -0.4805, -0.5053, -0.4907, -0.4637, -0.6300, -0.5600,
                     -0.6400, -0.4200, -0.2100, 0.0500, 0.3000, 0.5400,
                     0.7900, 0.9000, 0.9300, 0.9200, 0.9500, 0.9900, 1.0100,
                     1.0200, 1.0000, 0.9400, 0.8500, 0.7000, 0.6600, 0.7010,
                     0.7219, 0.6864, 0.5860, 0.4264, 0.2235, 0.0000, -0.1565,
                     -0.2985, -0.4102, -0.4805, -0.5053, -0.4907, -0.4597,
                     -0.2299, 0.0000]
        cd_extrap = [0.1770, 0.2132, 0.3173, 0.4758, 0.6686, 0.8708, 1.0560,
                     1.1996, 1.2818, 1.2900, 1.2818, 1.1996, 1.0560, 0.8708,
                     0.6686, 0.4758, 0.3158, 0.0390, 0.0233, 0.0131, 0.0134,
                     0.0119, 0.0122, 0.0116, 0.0144, 0.0146, 0.0162, 0.0274,
                     0.0303, 0.0369, 0.0509, 0.0648, 0.0776, 0.0917, 0.0994,
                     0.2306, 0.3142, 0.3186, 0.4758, 0.6686, 0.8708, 1.0560,
                     1.1996, 1.2818, 1.2900, 1.2818, 1.1996, 1.0560, 0.8708,
                     0.6686, 0.4758, 0.3173, 0.2132, 0.1770]

        # re-interpolate b/c angles of attack are different
        cl = np.interp(alpha_extrap, newpolar.alpha, newpolar.cl)
        cd = np.interp(alpha_extrap, newpolar.alpha, newpolar.cd)

        # test equality
        np.testing.assert_allclose(cl, cl_extrap, atol=1.5e-4)
        np.testing.assert_allclose(cd, cd_extrap, atol=1.5e-4)
Esempio n. 7
0
    def initFromAerodynFile(cls, aerodynFile):
        """convenience method for initializing with AeroDyn formatted files
        Parameters
        ----------
        aerodynFile : str
            location of AeroDyn style airfoiil file
        Returns
        -------
        af : CCAirfoil
            a constructed CCAirfoil object
        """

        af = Airfoil.initFromAerodynFile(aerodynFile)
        alpha, Re, cl, cd, cm = af.createDataGrid()
        return cls(alpha, Re, cl, cd)
    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)
Esempio n. 9
0
 def __init__(self, path):
     fp = open(path)
     lines = fp.readlines()
     self.NumFoil = int(splitLine(lines[17])[0])
     self.foils = []
     for i in range(self.NumFoil):
         tt = splitLine(lines[18+i])[0][1:-1]
         path_af = os.path.join(os.path.dirname(path), tt)
         af = Airfoil.initFromAerodynFile(path_af)
         self.foils.append(af)
     nodeNum = int(splitLine(lines[22])[0])        
     self.cols = splitLine(lines[23])
     _data = []
     for i in range(nodeNum):
         values = self.splitLine(lines[24+i])
         _data.append(values)
     self.nodeData = pd.DataFrame(_data, columns=self.cols)
Esempio n. 10
0
    def initFromAerodynFile(cls, aerodynFile):
        """convenience method for initializing with AeroDyn formatted files

        Parameters
        ----------
        aerodynFile : str
            location of AeroDyn style airfoiil file

        Returns
        -------
        af : CCAirfoil
            a constructed CCAirfoil object

        """

        af = Airfoil.initFromAerodynFile(aerodynFile)
        alpha, Re, cl, cd, cm = af.createDataGrid()
        return cls(alpha, Re, cl, cd)
Esempio n. 11
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
Esempio n. 12
0
import os

basepath = os.path.join(os.path.expanduser("~"), "Dropbox", "NREL", "5MW_files", "5MW_AFFiles")
os.chdir(basepath)

# just to temporarily change PYTHONPATH without installing
import sys

sys.path.append(os.path.expanduser("~") + "/Dropbox/NREL/SysEng/TWISTER/src/twister/rotoraero")

# 1 ---------

from airfoilprep import Polar, Airfoil
import numpy as np

airfoil = Airfoil.initFromAerodynFile("DU21_A17.dat")

# 1 ---------

# 2 ---------

# first polar
Re = 7e6
alpha = [
    -14.50,
    -12.01,
    -11.00,
    -9.98,
    -8.12,
    -7.62,
    -7.11,
Esempio n. 13
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)
Esempio n. 14
0
                        '5MW_files', '5MW_AFFiles')
os.chdir(basepath)

# just to temporarily change PYTHONPATH without installing
import sys

sys.path.append(
    os.path.expanduser('~') +
    '/Dropbox/NREL/SysEng/TWISTER/src/twister/rotoraero')

# 1 ---------

from airfoilprep import Polar, Airfoil
import numpy as np

airfoil = Airfoil.initFromAerodynFile('DU21_A17.dat')

# 1 ---------

# 2 ---------

# first polar
Re = 7e6
alpha = [
    -14.50, -12.01, -11.00, -9.98, -8.12, -7.62, -7.11, -6.60, -6.50, -6.00,
    -5.50, -5.00, -4.50, -4.00, -3.50, -3.00, -2.50, -2.00, -1.50, -1.00,
    -0.50, 0.00, 0.50, 1.00, 1.50, 2.00, 2.50, 3.00, 3.50, 4.00, 4.50, 5.00,
    5.50, 6.00, 6.50, 7.00, 7.50, 8.00, 8.50, 9.00, 9.50, 10.00, 10.50, 11.00,
    11.50, 12.00, 12.50, 13.00, 13.50, 14.00, 14.50, 15.00, 15.50, 16.00,
    16.50, 17.00, 17.50, 18.00, 18.50, 19.00, 19.50, 20.00, 20.50
]
Esempio n. 15
0
    def solve_nonlinear(self, params, unknowns, resids):

        # determine aspect ratio = (rotor radius / chord_75% radius)\
        #    if provided, cdmax is computed from AR'
        bl = params['blade_length']
        dr = params['rotor_diameter']
        hr = 0.5 * dr - bl
        rotor_radius = 0.5 * dr
        chord = params['chord_st'] * bl
        s = params['s_st']
        r = (s * bl + hr) / rotor_radius
        chord_75 = np.interp(0.75, r, chord)
        AR = rotor_radius / chord_75

        # write aerodyn files
        af_name_base = 'cs_'
        af_name_suffix = '_aerodyn'
        tcs = params['cs_polars_tc']

        n_cs_alpha = params['n_cs_alpha']
        pol = params['cs_polars']
        nmet = 0
        # TODO: blend polars determined with different methods
        for i, tc in enumerate(self.blend_var):
            af_name = af_name_base + \
                '%03d_%04d' % (i, tc * 1000) + af_name_suffix
            re_polars = []
            for nre, re in enumerate(self.res):
                # create polar object
                p = Polar(re,
                          pol[:n_cs_alpha[i, nre, nmet], 0, i, nre, nmet],
                          pol[:n_cs_alpha[i, nre, nmet], 1, i, nre, nmet],
                          pol[:n_cs_alpha[i, nre, nmet], 2, i, nre, nmet],
                          pol[:n_cs_alpha[i, nre, nmet], 3, i, nre, nmet])

                # extrapolate polar
                if tc < self.tc_max:
                    p_extrap = p.extrapolate(self.cdmax,
                                             AR,
                                             self.cdmin,
                                             self.nalpha)
                else:
                    p_extrap = p.extrapolate_as_cylinder()
                p_extrap.useCM = self.useCM
                re_polars.append(p_extrap)

                # TODO: output as HAWC2/FAST format
                # See if HAWC can take several af tables with different Re
                # numbers
                '''
                unknowns['airfoildata:aoa%02d' % i] = p_extrap.alpha
                unknowns['airfoildata:cl%02d' % i] = p_extrap.cl
                unknowns['airfoildata:cd%02d' % i] = p_extrap.cd
                unknowns['airfoildata:cm%02d' % i] = p_extrap.cm
                '''

            # create airfoil object
            af = Airfoil(re_polars)
            af.interpToCommonAlpha()
            af.writeToAerodynFile(af_name + '.dat')

            if self.plot_polars:
                figs = af.plot(single_figure=True)
                titles = ['cl', 'cd', 'cm']
                for (fig, title) in zip(figs, titles):
                    fig.savefig(af_name + '_' + title + '.png', dpi=400)
                    fig.savefig(af_name + '_' + title + '.pdf')

        self._get_unknowns(unknowns)