Ejemplo n.º 1
0
def main():
    if __name__ == '__main__':
        from py_wake.examples.data.iea37 import IEA37Site, IEA37_WindTurbines
        from py_wake.deficit_models.selfsimilarity import SelfSimilarityDeficit

        import matplotlib.pyplot as plt

        site = IEA37Site(16)
        x, y = site.initial_position.T

        windTurbines = IEA37_WindTurbines()
        from py_wake.deficit_models.noj import NOJDeficit
        from py_wake.superposition_models import SquaredSum

        # NOJ wake model
        noj = PropagateDownwind(site,
                                windTurbines,
                                wake_deficitModel=NOJDeficit(),
                                superpositionModel=SquaredSum())

        # NOJ wake and selfsimilarity blockage
        noj_ss = All2AllIterative(
            site,
            windTurbines,
            wake_deficitModel=NOJDeficit(),
            superpositionModel=SquaredSum(),
            blockage_deficitModel=SelfSimilarityDeficit())

        for wm in [noj, noj_ss]:
            plt.figure()
            wm(x=x, y=y, wd=[30], ws=[9]).flow_map().plot_wake_map()
        plt.show()
Ejemplo n.º 2
0
def main():
    if __name__ == '__main__':
        from py_wake.examples.data.iea37 import IEA37Site, IEA37_WindTurbines
        from py_wake.deficit_models.selfsimilarity import SelfSimilarityDeficit
        from py_wake.deficit_models.gaussian import ZongGaussianDeficit
        from py_wake.turbulence_models.stf import STF2017TurbulenceModel
        from py_wake.flow_map import XYGrid
        import matplotlib.pyplot as plt

        site = IEA37Site(16)
        x, y = site.initial_position.T

        windTurbines = IEA37_WindTurbines()
        from py_wake.deficit_models.noj import NOJDeficit
        from py_wake.superposition_models import SquaredSum

        # NOJ wake model
        noj = PropagateDownwind(site,
                                windTurbines,
                                wake_deficitModel=NOJDeficit(),
                                superpositionModel=SquaredSum())

        # NOJ wake and selfsimilarity blockage
        noj_ss = All2AllIterative(
            site,
            windTurbines,
            wake_deficitModel=NOJDeficit(),
            superpositionModel=SquaredSum(),
            blockage_deficitModel=SelfSimilarityDeficit())

        # Zong convection superposition
        zongp_ss = PropagateDownwind(site,
                                     windTurbines,
                                     wake_deficitModel=ZongGaussianDeficit(),
                                     superpositionModel=WeightedSum(),
                                     turbulenceModel=STF2017TurbulenceModel())

        # Zong convection superposition
        zong_ss = All2AllIterative(
            site,
            windTurbines,
            wake_deficitModel=ZongGaussianDeficit(),
            superpositionModel=WeightedSum(),
            blockage_deficitModel=SelfSimilarityDeficit(),
            turbulenceModel=STF2017TurbulenceModel())

        for wm in [noj, noj_ss, zongp_ss, zong_ss]:
            sim = wm(x=x, y=y, wd=[30], ws=[9])
            plt.figure()
            sim.flow_map(XYGrid(resolution=200)).plot_wake_map()
            plt.title(' AEP: %.3f GWh' % sim.aep().sum())
        plt.show()
Ejemplo n.º 3
0
 def __init__(self,
              site,
              windTurbines,
              rotorAvgModel=RotorCenter(),
              superpositionModel=SquaredSum(),
              deflectionModel=None,
              turbulenceModel=None):
     """
     Parameters
     ----------
     site : Site
         Site object
     windTurbines : WindTurbines
         WindTurbines object representing the wake generating wind turbines
     rotorAvgModel : RotorAvgModel
         Model defining one or more points at the down stream rotors to
         calculate the rotor average wind speeds from.\n
         Defaults to RotorCenter that uses the rotor center wind speed (i.e. one point) only
     superpositionModel : SuperpositionModel, default SquaredSum
         Model defining how deficits sum up
     deflectionModel : DeflectionModel, default None
         Model describing the deflection of the wake due to yaw misalignment, sheared inflow, etc.
     turbulenceModel : TurbulenceModel, default None
         Model describing the amount of added turbulence in the wake
     """
     PropagateDownwind.__init__(
         self,
         site,
         windTurbines,
         wake_deficitModel=IEA37SimpleBastankhahGaussianDeficit(),
         rotorAvgModel=rotorAvgModel,
         superpositionModel=superpositionModel,
         deflectionModel=deflectionModel,
         turbulenceModel=turbulenceModel)
Ejemplo n.º 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)
Ejemplo n.º 5
0
 def __init__(self,
              site,
              windTurbines,
              a=[0.38, 4e-3],
              superpositionModel=SquaredSum(),
              deflectionModel=None,
              turbulenceModel=None,
              groundModel=None):
     """
     Parameters
     ----------
     site : Site
         Site object
     windTurbines : WindTurbines
         WindTurbines object representing the wake generating wind turbines
     superpositionModel : SuperpositionModel, default SquaredSum
         Model defining how deficits sum up
     deflectionModel : DeflectionModel, default None
         Model describing the deflection of the wake due to yaw misalignment, sheared inflow, etc.
     turbulenceModel : TurbulenceModel, default None
         Model describing the amount of added turbulence in the wake
     """
     PropagateDownwind.__init__(self,
                                site,
                                windTurbines,
                                wake_deficitModel=ZongGaussianDeficit(a=a),
                                superpositionModel=superpositionModel,
                                deflectionModel=deflectionModel,
                                turbulenceModel=turbulenceModel,
                                groundModel=groundModel)
Ejemplo n.º 6
0
 def __init__(self, site, windTurbines, k=.1, superpositionModel=SquaredSum(),
              deflectionModel=None, turbulenceModel=None):
     """
     Parameters
     ----------
     site : Site
         Site object
     windTurbines : WindTurbines
         WindTurbines object representing the wake generating wind turbines
     k : float, default 0.1
         wake expansion factor
     superpositionModel : SuperpositionModel, default SquaredSum
         Model defining how deficits sum up
     blockage_deficitModel : DeficitModel, default None
         Model describing the blockage(upstream) deficit
     deflectionModel : DeflectionModel, default None
         Model describing the deflection of the wake due to yaw misalignment, sheared inflow, etc.
     turbulenceModel : TurbulenceModel, default None
         Model describing the amount of added turbulence in the wake
     """
     PropagateDownwind.__init__(self, site, windTurbines,
                                wake_deficitModel=NOJDeficit(k),
                                superpositionModel=superpositionModel,
                                deflectionModel=deflectionModel,
                                turbulenceModel=turbulenceModel)
Ejemplo n.º 7
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)
def test_All2AllIterativeDeflection():
    site = IEA37Site(16)
    windTurbines = IEA37_WindTurbines()
    wf_model = All2AllIterative(site, windTurbines,
                                wake_deficitModel=NOJDeficit(),
                                superpositionModel=SquaredSum(),
                                deflectionModel=JimenezWakeDeflection())
    wf_model([0], [0])
Ejemplo n.º 9
0
def run_wfm(mwc,
            test_cases=['Wieringermeer', 'Lillgrund', 'Hornsrev1'],
            deficit_setups=[{
                'deficit_model': NOJDeficit(),
                'superpositionModel': SquaredSum(),
                'rotorAvgModel': RotorCenter(),
                'turbulenceModel': STF2017TurbulenceModel()
            }],
            gaussian_filter=True):
    '''
        Evaluate wake models for the different test cases
    '''
    mwc_out = {}

    for i in range(len(deficit_setups)):
        deficit_setups[i]['setup_name'] = get_setup_name(deficit_setups[i])

    for case in test_cases:
        mwc_out[case] = mwc[case]
        mwc_out[case]['deficit_setups'] = deficit_setups
        # mwc_out[case]['deficit_models'] = []
        if case == 'Wieringermeer':
            sigma = 2.5 * np.ones((len(mwc[case]['wt_x'])))
        elif case == 'Lillgrund':
            sigma = 3.3 * np.ones((len(mwc[case]['wt_x'])))
        elif case == 'Hornsrev1':
            sigma = sigma_hornsrev('vanderLaan', mwc[case]['wt_x'],
                                   mwc[case]['wt_y'])

        for i in range(len(deficit_setups)):
            # set up model
            wfm = PropagateDownwind(
                mwc[case]['site'],
                mwc[case]['wt'],
                deficit_setups[i]['deficit_model'],
                superpositionModel=deficit_setups[i]['superpositionModel'],
                rotorAvgModel=deficit_setups[i]['rotorAvgModel'],
                turbulenceModel=deficit_setups[i]['turbulenceModel'])
            # simulation
            sim_res = wfm(mwc[case]['wt_x'],
                          mwc[case]['wt_y'],
                          ws=mwc[case]['U0'])
            # Gaussian averaging
            if gaussian_filter:
                powerGA = np.zeros(sim_res.Power.shape)
                for iAD in range(len(mwc[case]['wt_x'])):
                    powerGA[iAD, :, 0] = GaussianFilter(
                        sim_res.Power.values[iAD, :,
                                             0], np.arange(0, 360.0, 1),
                        int(np.ceil(3 * sigma[iAD])), sigma[iAD])
                sim_res['PowerGA'] = xr.DataArray(powerGA,
                                                  dims=['wt', 'wd', 'ws'])
                sim_res['PowerGA'].attrs[
                    'Description'] = 'Gaussian averaged power production [W]'

            mwc_out[case][deficit_setups[i]['setup_name']] = sim_res
            mwc_out[case][deficit_setups[i]
                          ['setup_name']]['gaussian_filter'] = gaussian_filter
def test_str():
    site = IEA37Site(16)
    windTurbines = IEA37_WindTurbines()
    wf_model = All2AllIterative(site, windTurbines,
                                wake_deficitModel=NOJDeficit(),
                                superpositionModel=SquaredSum(),
                                blockage_deficitModel=SelfSimilarityDeficit(),
                                deflectionModel=JimenezWakeDeflection(),
                                turbulenceModel=STF2005TurbulenceModel())
    assert str(wf_model) == "All2AllIterative(EngineeringWindFarmModel, NOJDeficit-wake, SelfSimilarityDeficit-blockage, RotorCenter-rotor-average, SquaredSum-superposition, JimenezWakeDeflection-deflection, STF2005TurbulenceModel-turbulence)"
Ejemplo n.º 11
0
def test_All2AllIterativeDeflection():
    site = IEA37Site(16)
    windTurbines = IEA37_WindTurbines()
    wf_model = All2AllIterative(site,
                                windTurbines,
                                wake_deficitModel=NOJDeficit(),
                                superpositionModel=SquaredSum(),
                                deflectionModel=JimenezWakeDeflection())
    sim_res = wf_model([0, 500], [0, 0], wd=270, ws=10, yaw=30)
    if 0:
        sim_res.flow_map(
            XYGrid(x=np.linspace(-200, 1000, 100))).plot_wake_map()
        plt.show()
Ejemplo n.º 12
0
def run_wms(swc,
            test_cases=[
                'Wieringermeer-West', 'Wieringermeer-East', 'Nibe',
                'Nordtank-500', 'NREL-5MW_TIlow', 'NREL-5MW_TIhigh'
            ],
            deficit_models=[NOJDeficit(),
                            BastankhahGaussianDeficit()],
            wds=np.linspace(-30, 30, 61)):
    '''
        Run the different wake models for the specified sites and output simulation results
    '''
    swc_out = {}
    for case in test_cases:
        swc_out[case] = swc[case]
        x_j = swc[case]['sDown'] * (np.dot(
            swc[case]['xDown'][:, na],
            np.cos(wds / 180.0 * np.pi)[na, :])).flatten()
        y_j = swc[case]['sDown'] * (np.dot(
            swc[case]['xDown'][:, na],
            np.sin(wds / 180.0 * np.pi)[na, :])).flatten()
        ii, jj = len(swc[case]['xDown']), len(wds)
        swc_out[case]['x'] = x_j.reshape(ii, jj)
        swc_out[case]['y'] = y_j.reshape(ii, jj)
        swc_out[case]['wds'] = wds
        swc_out[case]['deficit_models'] = []
        for model in deficit_models:
            # set up model
            tmp = {}
            wfm = PropagateDownwind(swc[case]['site'],
                                    swc[case]['wt'],
                                    model,
                                    superpositionModel=SquaredSum(),
                                    rotorAvgModel=RotorCenter(),
                                    turbulenceModel=STF2017TurbulenceModel())
            # simulation
            sim_res = wfm([0], [0], h=[100], wd=[270])
            lw_j, WS_eff_jlk, TI_eff_jlk = wfm._flow_map(
                x_j, y_j,
                np.ones_like(x_j) * 100, sim_res)
            deficit_name = modify_deficit_name_sw(wfm.wake_deficitModel,
                                                  TI_eff_jlk)
            tmp['bar_label'] = modify_deficit_name(wfm.wake_deficitModel)
            tmp['WS_eff'] = WS_eff_jlk[:, 0, 0].reshape(ii, jj)
            tmp['TI_eff'] = TI_eff_jlk[:, 0, 0].reshape(ii, jj)
            swc_out[case][deficit_name] = tmp
            swc_out[case]['deficit_models'].append(deficit_name)

    return swc_out
Ejemplo n.º 13
0
def test_stf(turbulence_model, ref_ti):
    # setup site, turbines and wind farm model
    site = IEA37Site(16)
    x, y = site.initial_position.T
    windTurbines = IEA37_WindTurbines()

    for wake_model in [
            NOJ(site, windTurbines, turbulenceModel=turbulence_model),
            All2AllIterative(site,
                             windTurbines,
                             wake_deficitModel=NOJDeficit(),
                             superpositionModel=SquaredSum(),
                             turbulenceModel=turbulence_model)
    ]:

        res = wake_model(x, y)
        # print(np.round(res.TI_eff_ilk[:, 0, 0], 3).tolist())
        npt.assert_array_almost_equal(res.TI_eff_ilk[:, 0, 0], ref_ti, 3)
Ejemplo n.º 14
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')
Ejemplo n.º 15
0
def test_models_with_noj(turbulence_model, ref_ti):
    # setup site, turbines and wind farm model
    site = IEA37Site(16)
    x, y = site.initial_position.T
    windTurbines = IEA37_WindTurbines()

    for wake_model in [NOJ(site, windTurbines, turbulenceModel=turbulence_model),
                       All2AllIterative(site, windTurbines,
                                        wake_deficitModel=NOJDeficit(),
                                        superpositionModel=SquaredSum(),
                                        turbulenceModel=turbulence_model),
                       ]:

        res = wake_model(x, y)
        # print(turbulence_model.__class__.__name__, np.round(res.TI_eff_ilk[:, 0, 0], 3).tolist())
        if 0:
            res.flow_map(wd=0).plot_ti_map()
            plt.show()

        npt.assert_array_almost_equal(res.TI_eff_ilk[:, 0, 0], ref_ti, 3)
Ejemplo n.º 16
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')
Ejemplo n.º 17
0
def test_RotorAvg_deficit():
    site = IEA37Site(16)
    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 [
            ('None', None, 0.22292190804089568),
            ('RotorCenter', RotorCenter(), 0.22292190804089568),
            ('RotorGrid100', EqGridRotorAvg(100), 0.1989725533174574),
            ('RotorGQGrid_4,3', GQGridRotorAvg(4, 3), 0.19874837617113356),
            ('RotorCGI4', CGIRotorAvg(4), 0.19822024411411204),
            ('RotorCGI4', CGIRotorAvg(21), 0.1989414764606653)]:

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

        # test with All2AllIterative
        wfm = All2AllIterative(site, windTurbines,
                               IEA37SimpleBastankhahGaussianDeficit(),
                               turbulenceModel=STF2017TurbulenceModel(rotorAvgModel=rotorAvgModel),
                               superpositionModel=SquaredSum())
        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.WS_eff_ilk[1, 0, 0]] * 2, label=name)
    if 0:
        plt.legend()
        plt.show()
    plt.close()
Ejemplo n.º 18
0
def test_deficitModel_wake_map(deficitModel, 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())

    x_j = np.linspace(-1500, 1500, 200)
    y_j = np.linspace(-1500, 1500, 100)

    flow_map = wf_model(x, y, wd=0, ws=9).flow_map(HorizontalGrid(x_j, y_j))
    X, Y = flow_map.X, flow_map.Y
    Z = flow_map.WS_eff_xylk[:, :, 0, 0]

    mean_ref = [
        3.2, 4.9, 8., 8.2, 7.9, 7.4, 7., 7., 7.4, 7.9, 8.1, 8.1, 8., 7.8, 7.9,
        8.1, 8.4
    ]

    if 0:
        flow_map.plot_wake_map()
        plt.plot(X[49, 100:133:2], Y[49, 100:133:2], '.-')
        windTurbines.plot(x, y)
        plt.figure()
        plt.plot(Z[49, 100:133:2])
        plt.plot(ref, label='ref')
        plt.plot(mean_ref, label='Mean ref')
        plt.legend()
        plt.show()

    npt.assert_array_almost_equal(ref, Z[49, 100:133:2], 2)

    # check that ref is reasonable
    npt.assert_allclose(ref[2:], mean_ref[2:], atol=2.6)
Ejemplo n.º 19
0
def get_wfms(wt, site=Hornsrev1Site(), wake_model=NOJDeficit(), superpositionModel=SquaredSum()):
    wfm1 = PropagateDownwind(site, wt, wake_model, superpositionModel=superpositionModel)
    wfm2 = All2AllIterative(site, wt, wake_model, superpositionModel=superpositionModel)
    wfm2.verbose = False
    wfm1.verbose = False
    return wfm1, wfm2
Ejemplo n.º 20
0
from py_wake.site._site import UniformSite
from py_wake.superposition_models import LinearSum, SquaredSum, MaxSum
from py_wake.tests import npt
from py_wake.wind_turbines import WindTurbines

# Two turbines, 0: Nibe-A, 1:Ct=0
NibeA0 = WindTurbines(names=['Nibe-A'] * 2,
                      diameters=[40] * 2,
                      hub_heights=[50] * 2,
                      ct_funcs=[lambda _: 8 / 9, lambda _: 0],
                      power_funcs=[lambda _: 0] * 2,
                      power_unit='w')

d02 = 8.1 - 5.7
d12 = 8.1 - 4.90473373


@pytest.mark.parametrize('superpositionModel,res',
                         [(LinearSum(), 8.1 - (d02 + d12)),
                          (SquaredSum(), 8.1 - np.hypot(d02, d12)),
                          (MaxSum(), 8.1 - d12)])
def test_superposition_models(superpositionModel, res):
    site = UniformSite([1], 0.1)
    wake_model = NOJ(site, NibeA0, superpositionModel=superpositionModel)
    x_i = [0, 0, 0]
    y_i = [0, -40, -100]
    h_i = [50, 50, 50]
    WS_eff_ilk = wake_model.calc_wt_interaction(x_i, y_i, h_i, [0, 0, 1], 0.0,
                                                8.1)[0]
    npt.assert_array_almost_equal(WS_eff_ilk[-1, 0, 0], res)
Ejemplo n.º 21
0
from py_wake.site._site import UniformSite
from py_wake.superposition_models import LinearSum, SquaredSum, MaxSum
from py_wake.tests import npt
from py_wake.wind_farm_models.engineering_models import PropagateDownwind, All2AllIterative
from py_wake.deficit_models.noj import NOJDeficit
from py_wake.flow_map import HorizontalGrid
from py_wake.tests.test_deficit_models.test_noj import NibeA0
import xarray as xr

d02 = 8.1 - 5.7
d12 = 8.1 - 4.90473373


@pytest.mark.parametrize('superpositionModel,res',
                         [(LinearSum(), 8.1 - (d02 + d12)),
                          (SquaredSum(), 8.1 - np.hypot(d02, d12)),
                          (MaxSum(), 8.1 - d12)])
def test_superposition_models(superpositionModel, res):
    site = UniformSite([1], 0.1)
    wake_model = NOJ(site, NibeA0, superpositionModel=superpositionModel)
    x_i = [0, 0, 0]
    y_i = [0, -40, -100]
    h_i = [50, 50, 50]
    WS_eff_ilk = wake_model.calc_wt_interaction(x_i, y_i, h_i, [0, 0, 1], 0.0,
                                                8.1)[0]
    npt.assert_array_almost_equal(WS_eff_ilk[-1, 0, 0], res)


@pytest.mark.parametrize('superpositionModel,sum_func',
                         [(LinearSum(), np.sum),
                          (SquaredSum(), lambda x: np.hypot(*x)),
Ejemplo n.º 22
0
                                   superpositionModel=superpositionModel,
                                   deflectionModel=deflectionModel,
                                   turbulenceModel=turbulenceModel)


if __name__ == '__main__':
    from py_wake.examples.data.iea37._iea37 import IEA37Site
    from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines
    import matplotlib.pyplot as plt

    # setup site, turbines and wind farm model
    site = IEA37Site(16)
    x, y = site.initial_position.T
    windTurbines = IEA37_WindTurbines()

    wf_model_ss = NOJ(site, windTurbines, k=0.05, superpositionModel=SquaredSum())
    print(wf_model_ss)
    wf_model_ls = NOJ(site, windTurbines, k=0.05, superpositionModel=LinearSum())
    print(wf_model_ls)
    wf_model_ms = NOJ(site, windTurbines, k=0.05, superpositionModel=MaxSum())
    print(wf_model_ms)

    # run wind farm simulation
    sim_res_ss = wf_model_ss(x, y)
    # return SimulationResult(self, localWind=localWind,
    #                         x_i=x, y_i=y, h_i=h, type_i=type, yaw_ilk=yaw_ilk,
    #                         wd=wd, ws=ws,
    #                         WS_eff_ilk=WS_eff_ilk, TI_eff_ilk=TI_eff_ilk,
    #                         power_ilk=power_ilk, ct_ilk=ct_ilk)
    sim_res_ls = wf_model_ls(x, y)
    sim_res_ms = wf_model_ms(x, y)
Ejemplo n.º 23
0
        fm_res = sim_res.flow_map(YZGrid(x=0, y=np.arange(-100, 10, 1)))
        fm_res.plot_wake_map()
        plt.plot(fm_ref.X[0], fm_ref.Y[0], '.')
        plt.plot(fm_ref.X[0], ref * 10, label='ref, WS*10')
        plt.plot(fm_ref.X[0], res * 10, label='Res, WS*10')

        plt.legend()
        plt.show()
    plt.close()
    npt.assert_array_equal(res, ref)


@pytest.mark.parametrize('wfm_cls', [PropagateDownwind, All2AllIterative])
@pytest.mark.parametrize('groundModel,superpositionModel',
                         [(Mirror(), LinearSum()),
                          (MirrorSquaredSum(), SquaredSum())])
def test_Mirror_flow_map(wfm_cls, groundModel, superpositionModel):
    site = UniformSite([1], ti=0.1)
    wt = V80()
    wfm = NOJ(site, wt, k=.5, superpositionModel=superpositionModel)

    fm_ref = wfm([0, 0 + 1e-20], [0, 0 + 1e-20], wd=0, h=[50, -50]).flow_map(
        YZGrid(x=0, y=np.arange(-100, 100, 1) + .1, z=np.arange(1, 100)))
    fm_ref.plot_wake_map()
    plt.title("Underground WT added manually")

    plt.figure()
    wfm = wfm_cls(site,
                  wt,
                  NOJDeficit(k=.5),
                  groundModel=groundModel,
    windTurbines = IEA37_WindTurbines()
    wf_model = All2AllIterative(site,
                                windTurbines,
                                wake_deficitModel=NOJDeficit(),
                                superpositionModel=SquaredSum(),
                                blockage_deficitModel=SelfSimilarityDeficit(),
                                deflectionModel=JimenezWakeDeflection(),
                                turbulenceModel=STF2005TurbulenceModel())
    assert str(
        wf_model
    ) == "All2AllIterative(EngineeringWindFarmModel, NOJDeficit-wake, SelfSimilarityDeficit-blockage, RotorCenter-rotor-average, SquaredSum-superposition, JimenezWakeDeflection-deflection, STF2005TurbulenceModel-turbulence)"


@pytest.mark.parametrize(
    'wake_deficitModel,deflectionModel,superpositionModel',
    [(NOJDeficit(), None, SquaredSum()),
     (IEA37SimpleBastankhahGaussianDeficit(), JimenezWakeDeflection(),
      WeightedSum())])
def test_huge_flow_map(wake_deficitModel, deflectionModel, superpositionModel):
    site = IEA37Site(16)
    windTurbines = IEA37_WindTurbines()
    wake_model = PropagateDownwind(site,
                                   windTurbines,
                                   wake_deficitModel=wake_deficitModel,
                                   superpositionModel=superpositionModel,
                                   deflectionModel=deflectionModel,
                                   turbulenceModel=STF2005TurbulenceModel())
    n_wt = 2
    flow_map = wake_model(*site.initial_position[:n_wt].T,
                          wd=[0, 90]).flow_map(HorizontalGrid(resolution=1000))
    # check that deficit matrix > 10MB (i.e. it enters the memory saving loop)