def test_deficitModel_wake_map_convection(deficitModel, ref): site = IEA37Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines() wf_model = PropagateDownwind(site, windTurbines, wake_deficitModel=deficitModel, superpositionModel=WeightedSum(), 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], label='Actual') plt.plot(ref, label='Reference') plt.plot(mean_ref, label='Mean ref') plt.legend() plt.show() # check that ref is reasonable npt.assert_allclose(ref[2:], mean_ref[2:], atol=2.6) npt.assert_array_almost_equal(Z[49, 100:133:2], ref, 2)
def test_wake_radius_not_implemented(): site = IEA37Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines() wfm = PropagateDownwind(site, windTurbines, wake_deficitModel=NoWakeDeficit(), turbulenceModel=GCLTurbulence()) with pytest.raises(NotImplementedError, match="wake_radius not implemented for NoWakeDeficit"): wfm(x, y)
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)
def main(): if __name__ == '__main__': from py_wake.examples.data.iea37._iea37 import IEA37Site from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines from py_wake.turbulence_models.gcl import GCLTurbulence 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 = GCL(site, windTurbines) wf_model_local = GCLLocal(site, windTurbines, turbulenceModel=GCLTurbulence()) # run wind farm simulation sim_res = wf_model(x, y) sim_res_local = wf_model_local(x, y) # calculate AEP aep = sim_res.aep().sum() aep_local = sim_res_local.aep().sum() # plot wake map fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4.5), tight_layout=True) levels = np.arange(0, 10.5, 0.5) print(wf_model) flow_map = sim_res.flow_map(wd=30, ws=9.8) flow_map.plot_wake_map(levels=levels, ax=ax1, plot_colorbar=False) flow_map.plot_windturbines(ax=ax1) ax1.set_title('Original Larsen, AEP: %.2f GWh' % aep) # plot wake map print(wf_model_local) flow_map = sim_res_local.flow_map(wd=30, ws=9.8) flow_map.plot_wake_map(levels=levels, ax=ax2, plot_colorbar=False) flow_map.plot_windturbines(ax=ax2) ax2.set_title('Local Larsen, AEP: %.2f GWh' % aep_local) plt.figure() flow_map.plot_ti_map(levels=np.arange(0, 1, .01)) plt.title('TI map for GCLLocal with GCL turbulence model') plt.show()
def test_wake_radius(deficitModel, wake_radius_ref): mean_ref = [105, 68, 135, 93, 123] # check that ref is reasonable npt.assert_allclose(wake_radius_ref, mean_ref, rtol=.5) npt.assert_array_almost_equal(deficitModel.wake_radius( D_src_il=np.reshape([100, 50, 100, 100, 100], (5, 1)), dw_ijlk=np.reshape([500, 500, 1000, 500, 500], (5, 1, 1, 1)), ct_ilk=np.reshape([.8, .8, .8, .4, .8], (5, 1, 1)), TI_ilk=np.reshape([.1, .1, .1, .1, .05], (5, 1, 1)), TI_eff_ilk=np.reshape([.1, .1, .1, .1, .05], (5, 1, 1)))[:, 0, 0, 0], wake_radius_ref) # Check that it works when called from WindFarmModel site = IEA37Site(16) windTurbines = IEA37_WindTurbines() wfm = PropagateDownwind(site, windTurbines, wake_deficitModel=deficitModel, turbulenceModel=GCLTurbulence()) wfm(x=[0, 500], y=[0, 0], wd=[30], ws=[10]) if 0: sim_res = wfm([0], [0], wd=[270], ws=10) sim_res.flow_map(HorizontalGrid(x=np.arange(-100, 1500, 10))).WS_eff.plot() x = np.arange(0, 1500, 10) wr = deficitModel.wake_radius( D_src_il=np.reshape([130], (1, 1)), dw_ijlk=np.reshape(x, (1, len(x), 1, 1)), ct_ilk=sim_res.CT.values, TI_ilk=np.reshape(sim_res.TI.values, (1, 1, 1)), TI_eff_ilk=sim_res.TI_eff.values)[0, :, 0, 0] plt.title(deficitModel.__class__.__name__) plt.plot(x, wr) plt.plot(x, -wr) plt.axis('equal') plt.show()
from py_wake.turbulence_models.crespo import CrespoHernandez from py_wake.deficit_models.gaussian import BastankhahGaussian import xarray as xr @pytest.mark.parametrize( 'turbulence_model,ref_ti', [(STF2005TurbulenceModel(), [ 0.075, 0.075, 0.075, 0.104, 0.167, 0.124, 0.075, 0.075, 0.075, 0.075, 0.075, 0.075, 0.104, 0.136, 0.098, 0.104 ]), (STF2017TurbulenceModel(), [ 0.075, 0.075, 0.075, 0.114, 0.197, 0.142, 0.075, 0.075, 0.075, 0.075, 0.075, 0.075, 0.115, 0.158, 0.108, 0.115 ]), (GCLTurbulence(), [ 0.075, 0.075, 0.075, 0.117, 0.151, 0.135, 0.075, 0.075, 0.075, 0.075, 0.075, 0.075, 0.128, 0.127, 0.117, 0.128 ]), (CrespoHernandez(), [ 0.075, 0.075, 0.075, 0.129, 0.17, 0.151, 0.075, 0.075, 0.075, 0.075, 0.075, 0.075, 0.143, 0.141, 0.13, 0.143 ])]) 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),