Example #1
0
def test_multiprocessing_wd():
    pool = multiprocessing.Pool(4)
    aep1, t_lst1 = timeit(aep_wd, min_runs=1)((wt_x, wt_y, wd_lst))
    aep2, t_lst2 = timeit(aep_all_multiprocessing, min_runs=1)(pool, wt_x, wt_y)
    t1, t2 = np.mean(t_lst1), np.mean(t_lst2)
    print("1 CPU: %.2fs, %d CPUs: %.2fs, speedup: %d%%" % (t1, pool._processes, t2, (t1 - t2) / t1 * 100))
    npt.assert_almost_equal(aep1, aep2 / 36)
Example #2
0
def test_local_wind(site):
    x_i = y_i = np.arange(5)
    wdir_lst = np.arange(0, 360, 90)
    wsp_lst = np.arange(3, 6)
    lw = site.local_wind(x_i=x_i, y_i=y_i, wd=wdir_lst, ws=wsp_lst)
    npt.assert_array_equal(lw.WS_ilk.shape, (5, 4, 3))

    lw = site.local_wind(x_i=x_i, y_i=y_i)
    npt.assert_array_equal(lw.WS_ilk.shape, (5, 360, 23))

    # check probability local_wind()[-1]
    npt.assert_equal(site.local_wind(x_i=x_i, y_i=y_i, wd=[0], ws=[10], wd_bin_size=1).P_ilk,
                     site.local_wind(x_i=x_i, y_i=y_i, wd=[0], ws=[10], wd_bin_size=2).P_ilk / 2)
    npt.assert_almost_equal(site.local_wind(x_i=x_i, y_i=y_i, wd=[0], ws=[9, 10, 11]).P_ilk.sum((1, 2)),
                            site.local_wind(x_i=x_i, y_i=y_i, wd=[0], ws=[10], ws_bins=3).P_ilk[:, 0, 0], 5)

    z = np.arange(1, 100)
    zero = [0] * len(z)

    ws = site.local_wind(x_i=zero, y_i=zero, h_i=z, wd=[0], ws=[10]).WS_ilk[:, 0, 0]
    site2 = UniformWeibullSite(f, A, k, ti, shear=PowerShear(70, alpha=np.zeros_like(f) + .3))
    ws70 = site2.local_wind(x_i=zero, y_i=zero, h_i=z, wd=[0], ws=[10]).WS_ilk[:, 0, 0]
    if 0:
        import matplotlib.pyplot as plt
        plt.plot(ws, z)
        plt.plot(ws70, z)
        plt.show()
    npt.assert_array_equal(10 * (z / 50)**.3, ws)
    npt.assert_array_equal(10 * (z / 70)**.3, ws70)
Example #3
0
def test_local_wind(site):
    x_i, y_i = site.initial_position.T
    h_i = x_i * 0 + 70
    wdir_lst = np.arange(0, 360, 90)
    wsp_lst = np.arange(3, 6)
    WS_ilk = site.local_wind(x_i=x_i,
                             y_i=y_i,
                             h_i=h_i,
                             wd=wdir_lst,
                             ws=wsp_lst).WS_ilk
    npt.assert_array_equal(WS_ilk.shape, (8, 4, 3))

    WS_ilk = site.local_wind(x_i=x_i, y_i=y_i, h_i=h_i).WS_ilk
    npt.assert_array_equal(WS_ilk.shape, (8, 360, 23))

    # check probability local_wind()[-1]
    npt.assert_almost_equal(
        site.local_wind(x_i=x_i,
                        y_i=y_i,
                        h_i=h_i,
                        wd=[0],
                        ws=[10],
                        wd_bin_size=1).P_ilk,
        site.local_wind(
            x_i=x_i, y_i=y_i, h_i=h_i, wd=[0], ws=[10], wd_bin_size=2).P_ilk /
        2, 6)
Example #4
0
def test_IEA37_ex16(deficitModel, aep_ref):
    site = IEA37Site(16)
    x, y = site.initial_position.T
    windTurbines = IEA37_WindTurbines()
    wf_model = PropagateDownwind(site,
                                 windTurbines,
                                 wake_deficitModel=deficitModel,
                                 superpositionModel=SquaredSum(),
                                 turbulenceModel=GCLTurbulence())

    aep_ilk = wf_model(x, y, wd=np.arange(0, 360, 22.5),
                       ws=[9.8]).aep_ilk(normalize_probabilities=True)
    aep_MW_l = aep_ilk.sum((0, 2)) * 1000

    # check if ref is reasonable
    aep_est = 16 * 3.35 * 24 * 365 * .8  # n_wt * P_rated * hours_pr_year - 20% wake loss = 375628.8
    npt.assert_allclose(aep_ref[0], aep_est, rtol=.11)
    npt.assert_allclose(aep_ref[1], [
        9500, 8700, 11500, 14300, 21300, 25900, 39600, 44300, 23900, 13900,
        15200, 33000, 72100, 18300, 12500, 8000
    ],
                        rtol=.15)

    npt.assert_almost_equal(aep_MW_l.sum(), aep_ref[0], 5)
    npt.assert_array_almost_equal(aep_MW_l, aep_ref[1], 5)
Example #5
0
def test_GCL_ex80():
    site = Hornsrev1Site()

    x, y = site.initial_position.T
    windTurbines = V80()
    wfm = PropagateDownwind(site,
                            windTurbines,
                            wake_deficitModel=GCLDeficit(),
                            superpositionModel=LinearSum())
    if 0:
        windTurbines.plot(x, y)
        plt.show()

    sim_res = timeit(wfm.__call__,
                     line_profile=0,
                     profile_funcs=[get_dU],
                     verbose=0)(x, y, ws=np.arange(10, 15))[0]

    # test that the result is equal to previuos runs (no evidens that  these number are correct)
    aep_ref = 1055.956615887197
    npt.assert_almost_equal(
        sim_res.aep_ilk(normalize_probabilities=True).sum(), aep_ref, 5)

    sim_res = wfm(x, y, ws=np.arange(3, 10))
    npt.assert_array_almost_equal(
        sim_res.aep_ilk(normalize_probabilities=True).sum(), 261.6143039016946,
        5)
Example #6
0
def test_IEA37WindTurbines():
    wt = IEA37WindTurbines()
    site = IEA37Site(16)
    x, y = site.initial_position.T
    for wfm in get_wfms(wt, site, IEA37SimpleBastankhahGaussianDeficit(), SquaredSum()):
        sim_res = wfm(x, y, ws=9.8, wd=np.arange(0, 360, 22.5))
        npt.assert_almost_equal(sim_res.aep(normalize_probabilities=True).sum() * 1e3, 366941.57116, 5)
Example #7
0
def test_fuga_blockage_wt_row():
    wts = HornsrevV80()
    path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+00/'
    site = hornsrev1.Hornsrev1Site()
    fuga_pdw = Fuga(path, site, wts)
    fuga_a2a = FugaBlockage(path, site, wts)

    x, y = [
        np.asarray(xy)[np.arange(0, 73, 8)]
        for xy in (hornsrev1.wt_x, hornsrev1.wt_y)
    ]

    sim_res_pdw = fuga_pdw(x, y, wd=[270])
    aep = sim_res_pdw.aep_ilk()[:, 0, :]
    sim_res_a2a = fuga_a2a(x, y, wd=[270])
    aep_blockage = sim_res_a2a.aep_ilk()[:, 0, :]

    # blockage reduce aep(wd=270) by .24%
    npt.assert_almost_equal((aep.sum() - aep_blockage.sum()) / aep.sum() * 100,
                            0.2433161515321294)

    if 0:
        plt.plot(
            (sim_res_pdw.WS_eff_ilk[:, 0, 7] - sim_res_a2a.WS_eff_ilk[:, 0, 7])
            / sim_res_pdw.WS_eff_ilk[:, 0, 7] * 100)
        plt.grid()
        plt.show()
Example #8
0
def check_speed_Hornsrev(WFModel):
    assert getattr(sys, 'gettrace')() is None, "Skipping speed check, In debug mode!!!"
    wt = HornsrevV80()
    site = Hornsrev1Site()
    wf_model = WFModel(site, wt)
    aep, t_lst = timeit(lambda x, y: wf_model(x, y).aep().sum())(wt_x, wt_y)

    fn = tfp + "speed_check/%s.txt" % WFModel.__name__
    if os.path.isfile(fn):
        with open(fn) as fid:
            lines = fid.readlines()

        # check aep
        npt.assert_almost_equal(float(lines[-1].split(";")[1]), aep)

        timings = np.array([(np.mean(eval(l.split(";")[2])), np.std(eval(l.split(";")[2]))) for l in lines])
        dates = [np.datetime64(l.split(";")[0]) for l in lines]
        dates = np.r_[dates, datetime.now()]
        y = np.r_[timings[:, 0], np.mean(t_lst)]

        error = np.r_[timings[:, 1], np.std(t_lst)]
        fig, axes = plt.subplots(2, 1)
        fig.suptitle(WFModel.__name__)
        for x, ax in zip([dates, np.arange(len(dates))], axes):
            ax.fill_between(x, y - 2 * error, y + 2 * error)
            ax.plot(x, y, '.-k')
            ax.axhline(y[:-1].mean() + 2 * error[:-1].mean(), ls='--', color='gray')

        if y[-1] > (y[:-1].mean() + 2 * error[:-1].mean()):
            raise Exception("Simulation time too slow, %f > %f" % (y[-1], (y[:-1].mean() + 2 * error[:-1].mean())))

    if getattr(sys, 'gettrace')() is None:
        with open(fn, 'a') as fid:
            fid.write("%s;%.10f;%s\n" % (datetime.now(), aep, t_lst))
Example #9
0
def test_aep_wind_atlas_method():
    site = Hornsrev1Site()

    wt = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site, wt)
    x, y = [0], [0]
    wd = np.arange(360)
    aep_lps = wfm(x, y, wd=wd,
                  ws=np.arange(3, 27)).aep(linear_power_segments=True)
    aep = wfm(x, y, wd=wd, ws=np.r_[3, np.arange(3.5, 27)]).aep()
    if 0:
        plt.plot(aep_lps.ws,
                 np.cumsum(aep_lps.sum(['wt', 'wd'])),
                 '.-',
                 label='Linear power segments')
        plt.plot(aep.ws,
                 np.cumsum(aep.sum(['wt', 'wd'])),
                 '.-',
                 label='Constant power segments')
        plt.ylabel('Cumulated AEP [GWh]')
        plt.xlabel('Wind speed [m/s]')
        plt.legend()
        plt.show()
    npt.assert_almost_equal(aep_lps.sum(), 16.73490444)
    npt.assert_almost_equal(aep.sum(), 16.69320343)
Example #10
0
def test_multiprocessing_xy():
    pool = multiprocessing.Pool(2)
    arg_lst = [(np.array(wt_x) + i, wt_y) for i in range(4)]
    aep1, t_lst1 = timeit(lambda arg_lst: [aep_xy(arg) for arg in arg_lst], min_time=0, min_runs=1)(arg_lst)
    aep2, t_lst2 = timeit(lambda arg_lst: pool.map(aep_xy, arg_lst), min_time=0, min_runs=1)(arg_lst)
    t1, t2 = np.mean(t_lst1), np.mean(t_lst2)
    print("1 CPU: %.2fs, %d CPUs: %.2fs, speedup: %d%%" % (t1, pool._processes, t2, (t1 - t2) / t1 * 100))
    npt.assert_almost_equal(aep1, aep2)
Example #11
0
 def plot(wfm, yaw, ax, min_ws):
     levels = np.arange(6.5, 10.5, .5)
     sim_res = wfm([0], [0], wd=270, ws=10, yaw=[[[yaw]]])
     fm = sim_res.flow_map(XYGrid(x=np.arange(-100, 500, 5)))
     npt.assert_almost_equal(fm.WS_eff.min(), min_ws)
     fm.plot_wake_map(ax=ax, levels=levels)
     fm.min_WS_eff(fm.x, 70).plot(ax=ax, color='r')
     plt.axhline(0, color='k')
Example #12
0
def test_multiprocessing_wfm_xy():
    pool = multiprocessing.Pool(2)
    arg_lst = [(get_wfm(grad=False), np.array(wt_x) + i, wt_y) for i in range(4)]
    aep1, t_lst1 = timeit(lambda arg_lst: [aep_wfm_xy(arg) for arg in arg_lst])(arg_lst)
    aep2, t_lst2 = timeit(lambda arg_lst: pool.map(aep_wfm_xy, arg_lst))(arg_lst)
    t1, t2 = np.mean(t_lst1), np.mean(t_lst2)
    if debug:
        print("1 CPU: %.2fs, %d CPUs: %.2fs, speedup: %d%%" % (t1, pool._processes, t2, (t1 - t2) / t1 * 100))
    npt.assert_almost_equal(aep1, aep2)
Example #13
0
def test_iea37_aep_file():
    """Compare AEP values in file to those calculated by task 37 code"""
    n_wts = [9, 16, 36, 64]  # diff wind farm sizes
    for n_wt in n_wts:
        iea37_aep = IEA37AEPCalc(n_wt).get_aep()  # task 37's code
        _, _, file_aep = read_iea37_windfarm(iea37_path +
                                             'iea37-ex%d.yaml' % n_wt)
        npt.assert_almost_equal(file_aep[0], iea37_aep.sum(), 5)
        npt.assert_almost_equal(file_aep[1], iea37_aep, 5)
def test_aep():
    site = UniformSite([1], ti=0)
    windTurbines = IEA37_WindTurbines()
    wake_model = NOJ(site, windTurbines)
    sim_res = wake_model([0], [0], wd=270)

    npt.assert_almost_equal(sim_res.aep(), 3.35 * 24 * 365 / 360 / 1000)
    npt.assert_almost_equal(sim_res.aep(normalize_probabilities=True),
                            3.35 * 24 * 365 / 1000)
Example #15
0
def test_multiprocessing_wd(pool):
    # compare result of vectorized call 12wd with result of multiprocessing 1wd/cpu
    # Slow down is expected
    aep1, t_lst1 = timeit(aep_wd, min_runs=1)((wt_x, wt_y, wd_lst))
    aep2, t_lst2 = timeit(aep_all_multiprocessing, min_runs=1)(pool, wt_x, wt_y)
    t1, t2 = np.mean(t_lst1), np.mean(t_lst2)
    if debug:
        print("1 CPU, 12wd/CPU: %.2fs, %d CPUs, 1wd/CPU: %.2fs, speedup: %d%%" %
              (t1, pool._processes, t2, (t1 - t2) / t1 * 100))
    npt.assert_almost_equal(aep1, aep2 / len(wd_lst))
Example #16
0
def test_plot_ws_distribution_iea37():
    from py_wake.examples.data.iea37 import IEA37Site

    n_wt = 16  # must be 16, 32 or 64
    site = IEA37Site(n_wt)
    p = site.plot_ws_distribution(wd=[0])
    npt.assert_almost_equal(p, [[1 / 300] * 300])

    if 0:
        plt.show()
Example #17
0
def test_scalar2scalar():
    def f(x):
        return x**2 + 1

    x = np.array([3])
    npt.assert_equal(cs(f)(x), 6)
    npt.assert_almost_equal(fd(f)(x), 6, 5)
    npt.assert_equal(autograd(f)(x), 6)
    pf = primitive(f)
    defvjp(pf, lambda ans, x: lambda g: g * 2 * x)
    npt.assert_array_equal(autograd(pf, False)(x), 6)
Example #18
0
def test_DeprecatedWindTurbines():
    v80 = V80Deprecated()

    for wts in [v80,
                WindTurbines(names=['V80'], diameters=[80], hub_heights=[70],
                             ct_funcs=v80._ct_funcs, power_funcs=v80._power_funcs, power_unit='w')]:

        types0 = [0] * 9
        for wfm in get_wfms(wts):
            # wfm = NOJ(Hornsrev1Site(), wts)
            npt.assert_array_equal(wts.types(), [0])
            npt.assert_almost_equal(wfm.aep(wt9_x, wt9_y, type=types0), 81.2066072392765)
Example #19
0
def test_aep_no_wake_loss_hornsrev():
    wt = hornsrev1.V80()
    x, y = hornsrev1.wt_x, hornsrev1.wt_y
    site = UniformWeibullSite([1], [10], [2], .75)
    site.default_ws = np.arange(3, 25)

    aep = AEPCalculator(site, wt, NOJ(wt))

    npt.assert_almost_equal(aep.calculate_AEP_no_wake_loss(x, y).sum() / 80, 8.260757098)
    cap_factor = aep.calculate_AEP(x, y).sum() / aep.calculate_AEP_no_wake_loss(x, y).sum()
    # print(cap_factor)
    npt.assert_almost_equal(cap_factor, 0.947175839142014)
Example #20
0
def test_Elliptic_property():
    # Useful vector, m \in ]-infty,0[ U ]0,1[
    nn = 6
    m = np.concatenate(
        (-np.linspace(10**-6, 10**6, nn), np.linspace(10**-6, 1 - 10**-6, nn)))

    # --- Property C.75, as given in book: Branlard - Wind Turbine Aerodynamics, p.627
    npt.assert_almost_equal(ellipticPiCarlson(m, m),
                            1 / (1 - m) * ellipe(m),
                            decimal=7)
    # --- PI(0,m) = K(m)
    npt.assert_almost_equal(ellipticPiCarlson(0 * m, m), ellipk(m), decimal=9)
Example #21
0
def test_aep_mixed_type():
    site = UniformSite([1], ti=0)
    wt = WindTurbines.from_WindTurbines(
        [IEA37_WindTurbines(), IEA37_WindTurbines()])

    wfm = NOJ(site, wt)

    sim_res = wfm([0, 500], [0, 0], type=[0, 1], wd=270)

    npt.assert_almost_equal(
        sim_res.aep(with_wake_loss=False).sum(),
        2 * wfm([0], [0], wd=270).aep(with_wake_loss=False).sum())
Example #22
0
def test_multimode_wasp_wtg():
    wt = WindTurbine.from_WAsP_wtg(os.path.join(wtg_path, 'Vestas V112-3.0 MW.wtg'))
    u = np.linspace(0, 30, 100)
    rho1225 = wt.power(ws=10, mode=0)

    for mode in range(14):
        rho = wt.wt_data[mode]['AirDensity']
        npt.assert_almost_equal(wt.power(ws=10, mode=mode) / rho1225 * 1.225, rho, 0.02)
    if 0:
        for mode in range(14):
            plt.plot(u, wt.power(ws=u, mode=mode), label='mode %d, rho: %f' % (mode, rho))
        plt.legend()
        plt.show()
Example #23
0
def test_WindTurbines():
    u_p, p = np.asarray(hornsrev1.power_curve).T.copy()

    u_ct, ct = hornsrev1.ct_curve.T
    npt.assert_array_equal(u_p, u_ct)
    curve = PowerCtTabular(ws=u_p, power=p, power_unit='w', ct=ct)

    for wts in [WindTurbine(name='V80', diameter=80, hub_height=70, powerCtFunction=curve),
                WindTurbines(names=['V80'], diameters=[80], hub_heights=[70], powerCtFunctions=[curve])]:
        types0 = [0] * 9
        for wfm in get_wfms(wts):
            npt.assert_array_equal(wts.types(), [0])
            npt.assert_almost_equal(wfm.aep(wt9_x, wt9_y, type=types0), 81.2066072392765)
def test_dAEP_2wt():
    site = Hornsrev1Site()
    iea37_site = IEA37Site(16)

    wt = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site, wt)
    x, y = iea37_site.initial_position[np.array([0, 2, 5, 8, 14])].T

    # plot 2 wt case
    x, y = np.array([[0, 130 * 4], [0, 0]], dtype=np.float)
    x_lst = np.array([0., 1.]) * np.arange(1, 600, 10)[:, na]
    kwargs = {'ws': [10], 'wd': [270]}

    _, (ax1, ax2) = plt.subplots(1, 2, sharey=False)
    ax1.plot(x_lst[:, 1], [wfm.aep(x_, y, **kwargs) for x_ in x_lst])
    ax1.set_xlabel('Downwind distance [m]')
    ax1.set_ylabel('AEP [GWh]')

    x_ = x_lst[20]
    ax1.set_title("Center line")
    for grad in [fd, cs, autograd]:
        dAEPdx = wfm.dAEPdn(0, grad)(x_, y, **kwargs)[1]
        npt.assert_almost_equal(dAEPdx / 360, 3.976975605364392e-06,
                                (10, 5)[grad == fd])
        plot_gradients(wfm.aep(x_, y, **kwargs),
                       dAEPdx,
                       x_[1],
                       grad.__name__,
                       step=100,
                       ax=ax1)
    y_lst = np.array([0, 1.]) * np.arange(-100, 100, 5)[:, na]
    ax2.plot(y_lst[:, 1], [wfm.aep(x, y_, **kwargs) for y_ in y_lst])
    ax2.set_xlabel('Crosswind distance [m]')
    ax2.set_ylabel('AEP [GWh]')
    y_ = y_lst[25]
    ax2.set_title("%d m downstream" % x[1])
    for grad in [fd, cs, autograd]:
        dAEPdy = wfm.dAEPdn(1, grad)(x, y_, **kwargs)[1]
        plot_gradients(wfm.aep(x, y_, **kwargs),
                       dAEPdy,
                       y_[1],
                       grad.__name__,
                       step=50,
                       ax=ax2)
        npt.assert_almost_equal(dAEPdy / 360, 3.794435973860448e-05,
                                (10, 5)[grad == fd])

    if 0:
        plt.legend()
        plt.show()
    plt.close()
Example #25
0
def test_CGIRotorAvg(n, x, y, w):
    m = CGIRotorAvg(n)

    if 0:
        for v in [m.nodes_x, m.nodes_y, m.nodes_weight]:
            print(np.round(v, 2).tolist())
        plt.scatter(m.nodes_x, m.nodes_y, c=m.nodes_weight)
        plt.axis('equal')
        plt.gca().add_artist(plt.Circle((0, 0), 1, fill=False))
        plt.ylim([-1, 1])
        plt.show()

    assert (len(m.nodes_weight) == len(m.nodes_x) == len(m.nodes_y) == n)
    npt.assert_almost_equal(m.nodes_weight.sum(), 1)
    npt.assert_array_almost_equal(m.nodes_x, x, 2)
    npt.assert_array_almost_equal(m.nodes_y, y, 2)
    npt.assert_array_almost_equal(m.nodes_weight, w, 2)
Example #26
0
def test_aep_two_turbines(setup, blockage_model, blockage_loss):
    site, windTurbines = setup

    nwm_ss = All2AllIterative(site, windTurbines, wake_deficitModel=NoWakeDeficit(),
                              blockage_deficitModel=blockage_model(), superpositionModel=LinearSum())

    sim_res = nwm_ss(x=[0, 80 * 3], y=[0, 0])
    aep_no_blockage = sim_res.aep_ilk(with_wake_loss=False).sum(2)
    aep = sim_res.aep_ilk().sum(2)

    # blockage reduce aep(wd=270) by .5%
    npt.assert_almost_equal((aep_no_blockage[0, 270] - aep[0, 270]) / aep_no_blockage[0, 270] * 100, blockage_loss)

    if debug:
        plt.plot(sim_res.WS_eff_ilk[:, :, 7].T)
        plt.title(blockage_model.__name__)
        plt.show()
Example #27
0
def test_IEA37SimpleBastankhahGaussian_all_ex():
    """check SBG matches IEA37 value in file"""
    for n_wt in [9, 16, 36, 64]:
        x, y, aep_ref = read_iea37_windfarm(iea37_path + 'iea37-ex%d.yaml' % n_wt)
        if 0:
            plt.plot(x, y, '2k')
            for i, (x_, y_) in enumerate(zip(x, y)):
                plt.annotate(i, (x_, y_))
            plt.axis('equal')
            plt.show()
        site = IEA37Site(n_wt)
        windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')
        wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines)

        aep_ilk = wake_model(x, y, wd=np.arange(0, 360, 22.5), ws=[9.8]).aep_ilk(normalize_probabilities=True)
        aep_MW_l = aep_ilk.sum((0, 2)) * 1000
        # test that the result is equal to results provided for IEA task 37
        npt.assert_almost_equal(aep_ref[0], aep_MW_l.sum(), 5)
        npt.assert_array_almost_equal(aep_ref[1], aep_MW_l, 5)
Example #28
0
def test_RotorGridAvg_deficit():
    site = IEA37Site(16)
    x, y = site.initial_position.T
    windTurbines = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site,
                                        windTurbines)
    flow_map = wfm([0, 500], [0, 0], wd=270, ws=10).flow_map(HorizontalGrid(x=[500], y=np.arange(-100, 100)))
    plt.plot(flow_map.Y[:, 0], flow_map.WS_eff_xylk[:, 0, 0, 0])
    R = windTurbines.diameter() / 2

    for name, rotorAvgModel, ref1 in [
            ('RotorCenter', RotorCenter(), 7.172723970425709),
            ('RotorGrid2', EqGridRotorAvg(2), 7.495889360682771),
            ('RotorGrid3', EqGridRotorAvg(3), 7.633415167369133),
            ('RotorGrid4', EqGridRotorAvg(4), 7.710215921858325),
            ('RotorGrid100', EqGridRotorAvg(100), 7.820762402628349),
            ('RotorGQGrid_4,3', GQGridRotorAvg(4, 3), 7.826105012683896),
            ('RotorCGI4', CGIRotorAvg(4), 7.848406907726826),
            ('RotorCGI4', CGIRotorAvg(7), 7.819900693605533),
            ('RotorCGI4', CGIRotorAvg(9), 7.82149363932618),
            ('RotorCGI4', CGIRotorAvg(21), 7.821558905416136)]:

        # test with PropagateDownwind
        wfm = IEA37SimpleBastankhahGaussian(site,
                                            windTurbines,
                                            rotorAvgModel=rotorAvgModel)
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.WS_eff_ilk[1, 0, 0], ref1)

        # test with All2AllIterative
        wfm = All2AllIterative(site, windTurbines,
                               IEA37SimpleBastankhahGaussianDeficit(),
                               rotorAvgModel=rotorAvgModel,
                               superpositionModel=SquaredSum())
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.WS_eff_ilk[1, 0, 0], ref1)

        plt.plot([-R, R], [sim_res.WS_eff_ilk[1, 0, 0]] * 2, label=name)
    if 0:
        plt.legend()
        plt.show()
    plt.close('all')
Example #29
0
def test_read_iea_windturbine():
    wt_id, hubheight, diameter, ct, power, dct, dpower = read_iea37_windturbine(
        iea37_path + 'iea37-335mw.yaml')
    assert wt_id == "3.35MW"
    assert hubheight == 110
    assert diameter == 130

    u = np.arange(30)
    p_r = 3350000
    npt.assert_array_almost_equal([0, 1 / 5.8**3 * p_r, p_r, p_r, 0],
                                  power([4, 5, 9.8, 25, 25.1]))
    ct_ = 4 * 1 / 3 * (1 - 1 / 3)
    npt.assert_array_almost_equal([0, ct_, ct_, 0], ct([3.9, 4, 25, 25.1]))
    npt.assert_almost_equal(dpower(7), cs(power)(7))
    npt.assert_equal(dct(7), 0)
    if 0:
        import matplotlib.pyplot as plt
        plt.plot(u, power(u) / 1e6)
        plt.plot(u, ct(u))
        plt.show()
Example #30
0
def test_RotorGridAvg_ti():
    site = IEA37Site(16)
    x, y = site.initial_position.T
    windTurbines = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site,
                                        windTurbines,
                                        turbulenceModel=STF2017TurbulenceModel())
    flow_map = wfm([0, 500], [0, 0], wd=270, ws=10).flow_map(HorizontalGrid(x=[500], y=np.arange(-100, 100)))
    plt.plot(flow_map.Y[:, 0], flow_map.TI_eff_xylk[:, 0, 0, 0])
    R = windTurbines.diameter() / 2

    for name, rotorAvgModel, ref1 in [
            ('RotorCenter', RotorCenter(), 0.22292190804089568),
            ('RotorGrid2', EqGridRotorAvg(2), 0.2111162769995657),
            ('RotorGrid3', EqGridRotorAvg(3), 0.2058616982653193),
            ('RotorGrid4', EqGridRotorAvg(4), 0.2028701990648858),
            ('RotorGrid100', EqGridRotorAvg(100), 0.1985255601976247),
            ('RotorGQGrid_4,3', GQGridRotorAvg(4, 3), 0.1982984399750206)]:

        # test with PropagateDownwind
        wfm = IEA37SimpleBastankhahGaussian(site,
                                            windTurbines,
                                            rotorAvgModel=rotorAvgModel,
                                            turbulenceModel=STF2017TurbulenceModel())
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.TI_eff_ilk[1, 0, 0], ref1)

        # test with All2AllIterative
        wfm = All2AllIterative(site, windTurbines,
                               IEA37SimpleBastankhahGaussianDeficit(),
                               rotorAvgModel=rotorAvgModel,
                               superpositionModel=SquaredSum(),
                               turbulenceModel=STF2017TurbulenceModel())
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.TI_eff_ilk[1, 0, 0], ref1)

        plt.plot([-R, R], [sim_res.TI_eff_ilk[1, 0, 0]] * 2, label=name)
    if 0:
        plt.legend()
        plt.show()
    plt.close('all')