def test_aep_map(): site = IEA37Site(16) x = [0, 0] y = [0, 200] windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml') wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines) aep = AEPCalculator(wake_model) # print(aep.calculate_AEP([0], [0]).sum()) x_j = np.arange(-150, 150, 20) y_j = np.arange(-250, 250, 20) X, Y, Z = aep.aep_map(x_j, y_j, 0, x, y, wd=[0], ws=np.arange(3, 25)) m = 17 if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z, 100) # , np.arange(2, 10, .01)) plt.colorbar(c) windTurbines.plot(x, y) plt.plot(X[m], Y[m], '.-r') plt.show() # print(np.round(Z[m], 2).tolist()) # ref ref = [ 21.5, 21.4, 21.02, 20.34, 18.95, 16.54, 13.17, 10.17, 10.17, 13.17, 16.54, 18.95, 20.34, 21.02, 21.4 ] npt.assert_array_almost_equal(Z[m], ref, 2)
def get_iea37_cost(n_wt=9): """Cost component that wraps the IEA 37 AEP calculator""" wd = npa(range(16)) * 22.5 # only 16 bins site = IEA37Site(n_wt) wind_turbines = IEA37_WindTurbines() wake_model = IEA37SimpleBastankhahGaussian(wind_turbines) aep_calc = PyWakeAEP(site, wind_turbines, wake_model) return aep_calc.get_TopFarm_cost_component(n_wt, wd=wd)
def main(): if __name__ == '__main__': try: import matplotlib.pyplot as plt plt.gcf() plot_comp = XYPlotComp() plot = True except RuntimeError: plot_comp = NoPlot() plot = False n_wt = 16 site = IEA37Site(n_wt) windTurbines = IEA37_WindTurbines() wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines) Drotor_vector = [windTurbines.diameter()] * n_wt power_rated_vector = [float(windTurbines.power(20) / 1000)] * n_wt hub_height_vector = [windTurbines.hub_height()] * n_wt AEPCalc = AEPCalculator(wake_model) def aep_func(x, y, **kwargs): return AEPCalc.calculate_AEP(x_i=x, y_i=y).sum(-1).sum(-1) * 10**6 def irr_func(aep, **kwargs): my_irr = economic_evaluation(Drotor_vector, power_rated_vector, hub_height_vector, aep).calculate_irr() print(my_irr) return my_irr aep_comp = CostModelComponent(input_keys=['x', 'y'], n_wt=n_wt, cost_function=aep_func, output_key="aep", output_unit="GWh", objective=False, output_val=np.zeros(n_wt)) irr_comp = CostModelComponent(input_keys=['aep'], n_wt=n_wt, cost_function=irr_func, output_key="irr", output_unit="%", objective=True, income_model=True) group = TopFarmGroup([aep_comp, irr_comp]) problem = TopFarmProblem( design_vars=dict(zip('xy', site.initial_position.T)), cost_comp=group, driver=EasyRandomSearchDriver( randomize_func=RandomizeTurbinePosition_Circle(), max_iter=50), constraints=[ SpacingConstraint(200), CircleBoundaryConstraint([0, 0], 1300.1) ], plot_comp=plot_comp) cost, state, recorder = problem.optimize()
def test_aep_map_no_turbines(): _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml") site = UniformSite(freq, ti=0.075) windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml') wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines) aep = AEPCalculator(wake_model) x_j = np.arange(-150, 150, 20) y_j = np.arange(-250, 250, 20) X, Y, Z = aep.aep_map(x_j, y_j, 0, [], [], wd=[0]) expect = (3.35 * 1e6) * 24 * 365 * (1e-9) npt.assert_array_almost_equal(Z, expect, 2)
def test_aep_map_no_turbines(): _, _, 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 = IEA37SimpleBastankhahGaussian(windTurbines) aep = AEPCalculator(site, windTurbines, wake_model) x_j = np.arange(-150, 150, 20) y_j = np.arange(-250, 250, 20) X, Y, Z = aep.aep_map(x_j, y_j, 0, [], [], wd=[0]) npt.assert_array_almost_equal(Z, 21.89, 2)
def main(): if __name__ == '__main__': site = IEA37Site(16) windTurbines = IEA37_WindTurbines() wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines) aep_calc = PyWakeAEP(wake_model) tf = TopFarmProblem( design_vars=dict(zip('xy', site.initial_position.T)), cost_comp=aep_calc.get_TopFarm_cost_component(16), driver=EasyRandomSearchDriver( randomize_func=RandomizeTurbinePosition_Circle(), max_iter=5), constraints=[CircleBoundaryConstraint([0, 0], 1300.1)], plot_comp=XYPlotComp()) tf.optimize() tf.plot_comp.show()
def main(): if __name__ == '__main__': plot_comp = XYPlotComp() site = get_site() n_wt = len(site.initial_position) windTurbines = DTU10MW() min_spacing = 2 * windTurbines.diameter(0) wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines) Drotor_vector = [windTurbines.diameter()] * n_wt power_rated_vector = [float(windTurbines.power(20) / 1000)] * n_wt hub_height_vector = [windTurbines.hub_height()] * n_wt AEPCalc = AEPCalculator(wake_model) def aep_func(x, y, **kwargs): return AEPCalc.calculate_AEP(x_i=x, y_i=y).sum(-1).sum(-1) * 10**6 def irr_func(aep, **kwargs): return economic_evaluation(Drotor_vector, power_rated_vector, hub_height_vector, aep).calculate_irr() aep_comp = CostModelComponent(input_keys=['x', 'y'], n_wt=n_wt, cost_function=aep_func, output_key="aep", output_unit="GWh", objective=False, output_val=np.zeros(n_wt)) irr_comp = CostModelComponent(input_keys=['aep'], n_wt=n_wt, cost_function=irr_func, output_key="irr", output_unit="%", objective=True, income_model=True) group = TopFarmGroup([aep_comp, irr_comp]) problem = TopFarmProblem( design_vars=dict(zip('xy', site.initial_position.T)), cost_comp=group, driver=EasyRandomSearchDriver( randomize_func=RandomizeTurbinePosition_Circle(), max_iter=50), constraints=[ SpacingConstraint(min_spacing), XYBoundaryConstraint(site.boundary), ], plot_comp=plot_comp) cost, state, recorder = problem.optimize()
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)
def test_IEA37SimpleBastankhahGaussian_wake_map(): site = IEA37_Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml') wake_model = IEA37SimpleBastankhahGaussian(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]) # test that the result is equal to last run (no evidens that these number are correct) ref = [ 3.32, 4.86, 7.0, 8.1, 7.8, 7.23, 6.86, 6.9, 7.3, 7.82, 8.11, 8.04, 7.87, 7.79, 7.85, 8.04, 8.28 ] npt.assert_array_almost_equal(Z[49, 100:133:2], ref, 2) if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z, np.arange(2, 9.1, .01)) plt.colorbar(c) site.plot_windturbines(x, y) plt.plot(X[49, 100:133:2], Y[49, 100:133:2], '-.') plt.show()