def test_smart_start_aep_map_PyWakeAEP(): site = IEA37Site(16) n_wt = 4 x, y = site.initial_position[:n_wt].T wd_lst = np.arange(0, 360, 45) ws_lst = [10] turbines = hornsrev1.HornsrevV80() site = UniformSite([1], .75) site.default_ws = ws_lst site.default_wd = wd_lst aep = PyWakeAEP(wake_model=NOJ(site, turbines)) aep_1wt = aep.calculate_AEP([0], [0]).sum() tf = TopFarmProblem(design_vars={ 'x': x, 'y': y }, cost_comp=aep.get_TopFarm_cost_component(n_wt), driver=EasyScipyOptimizeDriver(), constraints=[ SpacingConstraint(160), CircleBoundaryConstraint((0, 0), 500) ]) x = np.arange(-500, 500, 10) y = np.arange(-500, 500, 10) XX, YY = np.meshgrid(x, y) tf.smart_start(XX, YY, aep.get_aep4smart_start(wd=wd_lst, ws=ws_lst), radius=40, seed=1) tf.evaluate() if 0: wt_x, wt_y = tf['x'], tf['y'] for i, _ in enumerate(wt_x, 1): print(aep.calculate_AEP(wt_x[:i], wt_y[:i]).sum((1, 2))) X_j, Y_j, aep_map = aep.aep_map(x, y, 0, wt_x, wt_y, ws=ws_lst, wd=wd_lst) print(tf.evaluate()) import matplotlib.pyplot as plt c = plt.contourf(X_j, Y_j, aep_map, 100) plt.colorbar(c) plt.plot(wt_x, wt_y, '2r') for c in tf.model.constraint_components: c.plot() plt.axis('equal') plt.show() npt.assert_almost_equal(aep_1wt * n_wt, tf['AEP'], 5)
def test_smart_start_aep_map(seed, radius, resolution, tol): site = IEA37Site(16) n_wt = 4 x, y = site.initial_position[:n_wt].T wd_lst = np.arange(0, 360, 45) ws_lst = [10] turbines = hornsrev1.HornsrevV80() site = UniformSite([1], .75) site.default_ws = ws_lst site.default_wd = wd_lst wfm = NOJ(site, turbines) aep_comp = PyWakeAEPCostModelComponent(wfm, n_wt=n_wt) aep_1wt = wfm([0], [0]).aep().sum() tf = TopFarmProblem(design_vars={ 'x': x, 'y': y }, cost_comp=aep_comp, driver=EasyScipyOptimizeDriver(), constraints=[ SpacingConstraint(160), CircleBoundaryConstraint((0, 0), radius) ]) x = np.arange(-radius, radius, resolution) y = np.arange(-radius, radius, resolution) XX, YY = np.meshgrid(x, y) tf.smart_start(XX, YY, aep_comp.get_aep4smart_start(wd=wd_lst, ws=ws_lst), radius=40, plot=0, seed=seed) tf.evaluate() if 0: wt_x, wt_y = tf['x'], tf['y'] for i, _ in enumerate(wt_x, 1): print(wfm(wt_x[:i], wt_y[:i]).aep().sum(['wd', 'ws'])) aep_comp.windFarmModel(wt_x, wt_y, ws=ws_lst, wd=wd_lst).flow_map().aep_xy().plot() print(tf.evaluate()) import matplotlib.pyplot as plt plt.plot(wt_x, wt_y, '2r') for c in tf.model.constraint_components: c.plot() plt.axis('equal') plt.show() npt.assert_almost_equal(aep_1wt * n_wt, tf['AEP'], tol)