Пример #1
0
def test_twotype_windturbines():
    v80 = V80Deprecated()

    v88 = OneTypeWindTurbines(
        'V88', 88, 77, lambda ws: np.interp(ws, hornsrev1.ct_curve[:, 0],
                                            hornsrev1.ct_curve[:, 1]),
        lambda ws: np.interp(ws, hornsrev1.power_curve[:, 0], hornsrev1.
                             power_curve[:, 1] * 1.1), 'w')

    wts = DeprecatedWindTurbines.from_WindTurbines([v80, v88])
    ws = np.reshape([4, 6, 8, 10] * 2, (2, 4))
    types = np.asarray([0, 1])
    p = wts.power(ws, type=types)
    npt.assert_array_equal(p[0], p[1] / 1.1)
Пример #2
0
 def from_case_dict(name, case_dict):
     site = UniformSite(p_wd=[1],
                        ti=case_dict['TItot'] / 0.8,
                        ws=case_dict['U0'])
     site.default_wd = np.linspace(-30, 30, 61) % 360
     windTurbines = OneTypeWindTurbines(
         name="",
         diameter=case_dict['D'],
         hub_height=case_dict['zH'],
         ct_func=lambda ws, ct=case_dict['CT']: ws * 0 + ct,
         power_func=lambda ws: ws * 0 + 1,
         power_unit='W')
     xD = case_dict['xDown']
     x = xD * case_dict['sDown']
     return SingleWakeValidationCase(name, site, windTurbines, xD, x)
Пример #3
0
def deficitPlotSingleWakeCases(SingleWakecases, site, linewidth, cLES, cRANS,
                               colors):
    # Plot velocity deficit for each single wake case

    UdefCases = []
    for case in SingleWakecases:

        def ct(ws):
            # ct function for wind turbine
            ct = case['CT']
            return ct

        wt = OneTypeWindTurbines(name=case['name'],
                                 diameter=case['D'],
                                 hub_height=case['zH'],
                                 ct_func=ct,
                                 power_func=p,
                                 power_unit='W')

        if case['name'] == 'Nordtank-500':
            xDown = case['xDown'] * 40.0
        else:
            xDown = case['xDown'] * wt._diameters
        wds = np.linspace(-30, 30, 61)

        kNOJ = NOJ_k_from_location(case['location'])
        kGAU = Gau_k_from_Iu(case['TItot'] / 0.8)
        print(case['name'], case['TItot'], kNOJ, kGAU)
        wakemodels = [
            NOJ(site, wt, k=kGAU),
            BastankhahGaussian(site, wt, k=kGAU)
        ]
        wake_ws = np.zeros((len(wakemodels), len(wds), len(xDown)))
        for k in range(len(wakemodels)):
            aep_calc = AEPCalculator(wakemodels[k])
            # The velocity deficit at an arc is calculated by running the iwake_map for each point.
            # because it is only possible to provide a x and y array that define a rectangular plane.
            # This should be improved, where one can use a list of points and run wake_map once.
            for i in range(len(wds)):
                for j in range(len(xDown)):
                    x = xDown[j] * np.cos(wds[i] / 180.0 * np.pi)
                    y = xDown[j] * np.sin(wds[i] / 180.0 * np.pi)
                    X, Y, WS_eff = aep_calc.wake_map(x_j=x,
                                                     y_j=y,
                                                     wt_x=[0.0],
                                                     wt_y=[0.0],
                                                     wd=[270.0],
                                                     ws=case['U0'])
                    wake_ws[k, i, j] = WS_eff
        lines = []
        fig, ax = plt.subplots(1,
                               len(xDown),
                               sharey=False,
                               figsize=(3 * len(xDown), 3))

        Udef = np.zeros((len(xDown), len(wakemodels) + 3))
        Udef[:, :] = np.nan
        for j in range(len(xDown)):
            if case['xDown'][j] % 2 == 0 or (case['xDown'][j] + 1) % 2 == 0:
                xDownlabel = str(int(case['xDown'][j]))
            else:
                xDownlabel = str(case['xDown'][j]).replace('.', 'p')
            # References, based on field measurements
            if case['name'] == 'Wieringermeer-West' and j == 1:
                data = np.genfromtxt('data/' + case['name'] + '_data_' +
                                     xDownlabel + 'D.dat')
                ldata = ax[j].errorbar(data[:, 0] - 315,
                                       data[:, 1] / case['U0'],
                                       yerr=data[:, 2] / case['U0'] /
                                       np.sqrt(data[:, 3]),
                                       color='k',
                                       elinewidth=1.0,
                                       linewidth=0,
                                       marker='o',
                                       zorder=0,
                                       markersize=4)
                fdata = interp1d(data[:, 0] - 315, data[:, 1])
                Udef[j, 0] = integrate_velocity_deficit_arc(
                    wds, fdata(wds), case['xDown'][j], case['U0'])
            elif case['name'] == 'Wieringermeer-East' and j == 0:
                data = np.genfromtxt('data/' + case['name'] + '_data_' +
                                     xDownlabel + 'D.dat')
                ldata = ax[j].errorbar(data[:, 0] - 31,
                                       data[:, 1] / case['U0'],
                                       yerr=data[:, 2] / case['U0'] /
                                       np.sqrt(data[:, 3]),
                                       color='k',
                                       elinewidth=1.0,
                                       linewidth=0,
                                       marker='o',
                                       zorder=0,
                                       markersize=4)
                fdata = interp1d(data[:, 0] - 31, data[:, 1])
                Udef[j, 0] = integrate_velocity_deficit_arc(
                    wds, fdata(wds), case['xDown'][j], case['U0'])
            elif case['name'] == 'Nibe':
                # No standard deviation of the 10 min. available.
                data = np.genfromtxt('data/' + case['name'] + '_data_' +
                                     xDownlabel + 'D.dat')
                ldata = ax[j].scatter(data[:, 0],
                                      data[:, 1],
                                      color='k',
                                      marker='o',
                                      zorder=0,
                                      s=10)
                fdata = interp1d(data[:, 0], data[:, 1])
                Udef[j, 0] = integrate_velocity_deficit_arc(
                    wds,
                    fdata(wds) * case['U0'], case['xDown'][j], case['U0'])
            elif case['name'] == 'Nordtank-500' and j < 2:
                data = np.genfromtxt('data/' + case['name'] + '_data_' +
                                     xDownlabel + 'D.dat')
                ldata = ax[j].errorbar(data[:, 0],
                                       data[:, 2],
                                       yerr=data[:, 3] / np.sqrt(74.0),
                                       color='k',
                                       elinewidth=1.0,
                                       linewidth=0,
                                       marker='o',
                                       zorder=0,
                                       markersize=4)
            # LES, based on EllipSys3D AD
            LES = np.genfromtxt('data/' + case['name'] + '_LES_' + xDownlabel +
                                'D.dat')
            # Shaded area represent the standard error of the mean
            lLES = ax[j].fill_between(
                LES[:, 0],
                LES[:, 1] - LES[:, 2] / np.sqrt(LES[:, 3]),
                LES[:, 1] + LES[:, 2] / np.sqrt(LES[:, 3]),
                color=cLES,
                alpha=0.5)
            # RANS,  based on EllipSys3D AD k-epsilon-fP
            RANS = np.genfromtxt('data/' + case['name'] + '_RANS_' +
                                 xDownlabel + 'D.dat')
            lRANS, = ax[j].plot(RANS[:, 0],
                                RANS[:, 1],
                                color=cRANS,
                                linewidth=linewidth)
            for k in range(len(wakemodels)):
                l1, = ax[j].plot(wds,
                                 wake_ws[k, :, j] / case['U0'],
                                 color=colors[k],
                                 linewidth=linewidth)
                lines.append(l1)
                if case['name'] == 'Nordtank-500':
                    title = '%s %g %s' % ('$x=', case['xDown'][j], 'D^*$')
                else:
                    title = '%s %g %s' % ('$x=', case['xDown'][j], 'D$')
                ax[j].set_title(title)
                ax[j].set_xticks(np.arange(min(wds), max(wds) + 10.0, 10.0))
            if case['xDown'][j] < 7.0:
                ax[j].set_xlim(-30, 30)
            else:
                ax[j].set_xlim(-20, 20)
            ax[j].grid(True)
            ax[j].set_ylim(None, ymax=1.1)
            # Momemtum deficit wake models
            for k in range(len(wakemodels)):
                Udef[j, 3 + k] = integrate_velocity_deficit_arc(
                    wds, wake_ws[k, :, j], case['xDown'][j], case['U0'])
            Udef[j,
                 1] = integrate_velocity_deficit_arc(LES[:, 0],
                                                     LES[:, 1] * case['U0'],
                                                     case['xDown'][j],
                                                     case['U0'])
            Udef[j,
                 2] = integrate_velocity_deficit_arc(RANS[:, 0],
                                                     RANS[:, 1] * case['U0'],
                                                     case['xDown'][j],
                                                     case['U0'])
        ax[0].set_ylabel('$U/U_0$', rotation=0)
        ax[0].yaxis.labelpad = 20
        ax[1].set_xlabel('Relative wind direction [deg]')
        fig.tight_layout(rect=[0, 0, 1, 0.9])
        NOJlabel = 'NOJ ($k=%g$)' % (kNOJ)
        GAUlabel = 'GAU ($k=%g$)' % (kGAU)
        if case['name'] in [
                'Nibe', 'Nordtank-500', 'Wieringermeer-West',
                'Wieringermeer-East'
        ]:
            fig.legend((ldata, lLES, lRANS, lines[0], lines[1]),
                       ('Data', 'LES', 'RANS', NOJlabel, GAUlabel),
                       ncol=5,
                       loc='upper center',
                       bbox_to_anchor=(0, 0, 1, 1),
                       numpoints=1,
                       scatterpoints=1)
        else:
            fig.legend((lLES, lRANS, lines[0], lines[1]),
                       ('LES', 'RANS', NOJlabel, GAUlabel),
                       ncol=4,
                       loc='upper center',
                       bbox_to_anchor=(0, 0, 1, 1),
                       numpoints=1,
                       scatterpoints=1)
        filename = case['name'] + '.pdf'
        fig.savefig(filename)
        os.system('mv ' + filename + ' report/figures/')
        UdefCases.append(Udef)
    return UdefCases