Exemple #1
0
def test_read_iea_windfarm():
    x, y, aep = read_iea37_windfarm(iea37_path + 'iea37-ex16.yaml')
    assert len(x) == 16
    assert x[1] == 650
    assert y[2] == 618.1867
    assert aep[0] == 366941.57116
    assert aep[1][0] == 9444.60012
Exemple #2
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()
Exemple #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
Exemple #4
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)
Exemple #5
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)
Exemple #6
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)
Exemple #7
0
def main():
    if __name__ == '__main__':

        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:
                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 = IEA37Site(n_wt)
            windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')
            wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines)

            aep = wake_model(x, y, wd=np.arange(0, 360, 22.5), ws=[9.8]).aep()

            # Compare to reference results provided for IEA task 37
            print(n_wt, aep_ref[0] * 1e-3, aep)
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)
Exemple #9
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)
     7838.84383
 ])),
 (NOJLocalDeficit(), (335151.6404628441, [
     8355.71335, 7605.92379, 10654.172, 13047.6971, 19181.46408,
     23558.34198, 36738.52415, 38663.44595, 21056.39764, 12042.79324,
     13813.46269, 30999.42279, 63947.61202, 17180.40299, 11334.12323,
     6972.14345
 ])),
 (BastankhahGaussianDeficit(), (355971.9717035484, [
     9143.74048, 8156.71681, 11311.92915, 13955.06316, 19807.65346,
     25196.64182, 39006.65223, 41463.31044, 23042.22602, 12978.30551,
     14899.26913, 32320.21637, 67039.04091, 17912.40907, 12225.04134,
     7513.75582
 ])),
 (IEA37SimpleBastankhahGaussianDeficit(),
  read_iea37_windfarm(iea37_path + 'iea37-ex16.yaml')[2]),
 (FugaDeficit(LUT_path=tfp +
              'fuga/2MW/Z0=0.00408599Zi=00400Zeta0=0.00E+00/'),
  (404441.6306021485, [
      9912.33731, 9762.05717, 12510.14066, 15396.76584, 23017.66483,
      27799.7161, 43138.41606, 49623.79059, 24979.09001, 15460.45923,
      16723.02619, 35694.35526, 77969.14805, 19782.41376, 13721.45739,
      8950.79218
  ])),
 (GCLDeficit(), (370863.6246093183, [
     9385.75387, 8768.52105, 11450.13309, 14262.42186, 21178.74926,
     25751.59502, 39483.21753, 44573.31533, 23652.09976, 13924.58752,
     15106.11692, 32840.02909, 71830.22035, 18200.49805, 12394.7626,
     8061.6033
 ])),
 (GCLLocalDeficit(), (381187.36105425097, [
    # test that the result is equal to last run (no evidens that  these number are correct)
    [(NOJDeficit(), (367205.0846866496, [9833.86287, 8416.99088, 10820.37673, 13976.26422, 22169.66036,
                                         25234.9215, 37311.64388, 42786.37028, 24781.33444, 13539.82115,
                                         14285.22744, 31751.29488, 75140.15677, 17597.10319, 11721.21226,
                                         7838.84383])),
     (NOJLocalDeficit(), (335151.6404628441, [8355.71335, 7605.92379, 10654.172, 13047.6971, 19181.46408,
                                              23558.34198, 36738.52415, 38663.44595, 21056.39764, 12042.79324,
                                              13813.46269, 30999.42279, 63947.61202, 17180.40299, 11334.12323,
                                              6972.14345])),

     (BastankhahGaussianDeficit(), (355971.9717035484,
                                    [9143.74048, 8156.71681, 11311.92915, 13955.06316, 19807.65346,
                                        25196.64182, 39006.65223, 41463.31044, 23042.22602, 12978.30551,
                                        14899.26913, 32320.21637, 67039.04091, 17912.40907, 12225.04134,
                                        7513.75582])),
     (IEA37SimpleBastankhahGaussianDeficit(), read_iea37_windfarm(iea37_path + 'iea37-ex16.yaml')[2]),
     (FugaDeficit(LUT_path=tfp + 'fuga/2MW/Z0=0.00014617Zi=00399Zeta0=0.00E+0/'),
      (398938.8941139709, [9632.92248, 9733.98766, 12462.98413, 15332.30502, 22199.91899,
                           27683.32851, 42975.80734, 49481.10395, 24274.96466, 15416.63681,
                           16681.20957, 35508.27583, 75263.59612, 19679.2854, 13687.14632,
                           8925.42131])),
     (GCLDeficit(), (370863.6246093183,
                     [9385.75387, 8768.52105, 11450.13309, 14262.42186, 21178.74926,
                      25751.59502, 39483.21753, 44573.31533, 23652.09976, 13924.58752,
                      15106.11692, 32840.02909, 71830.22035, 18200.49805, 12394.7626,
                      8061.6033])),
     (GCLLocalDeficit(), (381187.36105425097,
                          [9678.85358, 9003.65526, 11775.06899, 14632.42259, 21915.85495,
                           26419.65189, 40603.68618, 45768.58091, 24390.71103, 14567.43106,
                           15197.82861, 32985.67922, 75062.92788, 18281.21981, 12470.01322,
                           8433.77587])),