Пример #1
0
def main():
    if __name__ == '__main__':
        from py_wake.examples.data.iea37 import iea37_path
        from py_wake.examples.data.iea37.iea37_reader import read_iea37_windfarm,\
            read_iea37_windrose
        from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines
        from py_wake.site._site import UniformSite
        from py_wake.aep_calculator import AEPCalculator

        class MyWakeModel(SquaredSum, WakeModel):
            args4deficit = ['WS_lk', 'dw_jl']

            def calc_deficit(self, WS_lk, dw_jl):
                # 10% deficit downstream
                return (WS_lk * .1)[na] * (dw_jl > 0)[:, :, na]

        _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
        n_wt = 16
        x, y, _ = read_iea37_windfarm(iea37_path + 'iea37-ex%d.yaml' % n_wt)

        site = UniformSite(freq, ti=0.75)
        windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')

        wake_model = MyWakeModel(windTurbines)
        aep_calculator = AEPCalculator(site, windTurbines, wake_model)

        import matplotlib.pyplot as plt
        aep_calculator.plot_wake_map(wt_x=x,
                                     wt_y=y,
                                     wd=[0, 30],
                                     ws=[9],
                                     levels=np.linspace(5, 9, 100))
        windTurbines.plot(x, y)

        plt.show()
Пример #2
0
def test_wake_model():
    _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
    site = UniformSite(freq, ti=0.75)
    windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')
    wake_model = NOJ(windTurbines)
    aep = AEPCalculator(site, windTurbines, wake_model)
    with pytest.raises(ValueError, match="Turbines 0 and 1 are at the same position"):
        aep.calculate_AEP([0, 0], [0, 0], wd=np.arange(0, 360, 22.5), ws=[9.8])
Пример #3
0
    def __init__(self, n_wt, ti=.075, shear=None):
        assert n_wt in [9, 16, 36, 64]

        from py_wake.examples.data.iea37.iea37_reader import \
            read_iea37_windfarm, read_iea37_windrose

        _, wsp, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
        UniformSite.__init__(self, freq, ti, ws=wsp, shear=shear)
        self.initial_position = np.array(read_iea37_windfarm(iea37_path + 'iea37-ex%d.yaml' % n_wt)[:2]).T
Пример #4
0
    def __init__(self, n_wt, ti=.75):
        assert n_wt in [16, 36, 64]

        from py_wake.examples.data.iea37.iea37_reader import read_iea37_windfarm,\
            read_iea37_windrose

        _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
        self.initial_position = np.array(
            read_iea37_windfarm(iea37_path + 'iea37-ex%d.yaml' % n_wt)[:2]).T

        UniformSite.__init__(self, freq, ti)
Пример #5
0
def test_aep_map_no_turbines():
    _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
    site = UniformSite(freq, ti=0.075)
    windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')
    wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines)
    aep = AEPCalculator(wake_model)
    x_j = np.arange(-150, 150, 20)
    y_j = np.arange(-250, 250, 20)
    X, Y, Z = aep.aep_map(x_j, y_j, 0, [], [], wd=[0])
    expect = (3.35 * 1e6) * 24 * 365 * (1e-9)

    npt.assert_array_almost_equal(Z, expect, 2)
Пример #6
0
def test_aep_map_no_turbines():

    _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
    # n_wt = 16
    # x, y, _ = read_iea37_windfarm(iea37_path + 'iea37-ex%d.yaml' % n_wt)

    site = UniformSite(freq, ti=0.75)
    windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')
    wake_model = IEA37SimpleBastankhahGaussian(windTurbines)
    aep = AEPCalculator(site, windTurbines, wake_model)
    x_j = np.arange(-150, 150, 20)
    y_j = np.arange(-250, 250, 20)
    X, Y, Z = aep.aep_map(x_j, y_j, 0, [], [], wd=[0])

    npt.assert_array_almost_equal(Z, 21.89, 2)
Пример #7
0
def test_IEA37SimpleBastankhahGaussian_ex16():
    _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
    n_wt = 16
    x, y, aep_ref = read_iea37_windfarm(iea37_path + 'iea37-ex%d.yaml' % n_wt)
    if 0:
        import matplotlib.pyplot as plt
        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 = UniformSite(freq, ti=0.75)
    windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')
    wake_model = IEA37SimpleBastankhahGaussian(windTurbines)

    aep = AEPCalculator(site, windTurbines, wake_model)
    aep_ilk = aep.calculate_AEP(x, y, wd=np.arange(0, 360, 22.5), ws=[9.8])
    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)
Пример #8
0
def test_wake_map():
    _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
    n_wt = 16
    x, y, _ = read_iea37_windfarm(iea37_path + 'iea37-ex%d.yaml' % n_wt)

    site = UniformSite(freq, ti=0.75)
    windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')
    wake_model = NOJ(windTurbines)
    aep = AEPCalculator(site, windTurbines, wake_model)
    x_j = np.linspace(-1500, 1500, 200)
    y_j = np.linspace(-1500, 1500, 100)
    X, Y, Z = aep.wake_map(x_j, y_j, 110, x, y, wd=[0], ws=[9])

    if 0:
        import matplotlib.pyplot as plt
        c = plt.contourf(X, Y, Z)  # , np.arange(2, 10, .01))
        plt.colorbar(c)
        site.plot_windturbines(x, y)

        plt.show()

    ref = [3.27, 3.27, 9.0, 7.46, 7.46, 7.46, 7.46, 7.31, 7.31, 7.31, 7.31, 8.3, 8.3, 8.3, 8.3, 8.3, 8.3]
    npt.assert_array_almost_equal(Z[49, 100:133:2], ref, 2)
Пример #9
0
def test_read_iea37_windrose():
    wdir, wsp, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml")
    assert wdir[1] == 22.5
    assert wsp[0] == 9.8
    assert freq[1] == .024