def test_from_flow_box_2wt(): site = Hornsrev1Site() windTurbines = V80() # simulate current and neighbour wt wfm = BastankhahGaussian(site, windTurbines) wd = np.arange(30) sim_res = wfm([0, 0], [0, 500], wd=wd) ref_aep = sim_res.aep().sel(wt=0) wt_x, wt_y = [0], [0] neighbour_x, neighbour_y = [0], [500] # make site with effects of neighbour wt sim_res = wfm(neighbour_x, neighbour_y, wd=wd) e = 100 box = sim_res.flow_box(x=np.linspace(min(wt_x) - e, max(wt_x) + e, 21), y=np.linspace(min(wt_y) - e, max(wt_y) + e, 21), h=windTurbines.hub_height(windTurbines.types())) site = XRSite.from_flow_box(box) # Simujlate current wt and compare aep wfm = BastankhahGaussian(site, windTurbines) sim_res = wfm(wt_x, wt_y, wd=wd) aep = sim_res.aep() if 0: site.ds.WS.sel(ws=10, wd=3).plot() windTurbines.plot(wt_x, wt_y) windTurbines.plot(neighbour_x, neighbour_y) plt.show() npt.assert_array_almost_equal(ref_aep, aep.sel(wt=0))
def test_neighbour_farm_speed(): # import and setup site and windTurbines site = IEA37Site(16) # setup current, neighbour and all positions wt_x, wt_y = site.initial_position.T neighbour_x, neighbour_y = wt_x - 4000, wt_y all_x, all_y = np.r_[wt_x, neighbour_x], np.r_[wt_y, neighbour_y] windTurbines = WindTurbines.from_WindTurbines([IEA37_WindTurbines(), IEA37_WindTurbines()]) windTurbines._names = ["Current wind farm", "Neighbour wind farm"] types = [0] * len(wt_x) + [1] * len(neighbour_x) wf_model = PropagateDownwind(site, windTurbines, wake_deficitModel=BastankhahGaussianDeficit(use_effective_ws=True), superpositionModel=LinearSum()) # Consider wd=270 +/- 30 deg only wd_lst = np.arange(240, 301) sim_res, t = timeit(wf_model, verbose=False)(all_x, all_y, type=types, ws=9.8, wd=wd_lst) if 1: ext = 100 flow_box = wf_model(neighbour_x, neighbour_y, wd=wd_lst).flow_box( x=np.linspace(min(wt_x) - ext, max(wt_x) + ext, 53), y=np.linspace(min(wt_y) - ext, max(wt_y) + ext, 51), h=[100, 110, 120]) wake_site = XRSite.from_flow_box(flow_box) wake_site.save('tmp.nc') else: wake_site = XRSite.load('tmp.nc') wf_model_wake_site = PropagateDownwind(wake_site, windTurbines, wake_deficitModel=BastankhahGaussianDeficit(use_effective_ws=True), superpositionModel=LinearSum()) sim_res_wake_site, _ = timeit(wf_model_wake_site, verbose=False)(wt_x, wt_y, ws=9.8, wd=wd_lst) npt.assert_allclose(sim_res.aep().sel(wt=np.arange(len(wt_x))).sum(), sim_res_wake_site.aep().sum(), rtol=0.0005) npt.assert_array_almost_equal(sim_res.aep().sel(wt=np.arange(len(wt_x))), sim_res_wake_site.aep(), 2)