def test_wake_map(): site = IEA37Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml') wake_model = NOJ(site, windTurbines) aep = AEPCalculator(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]) if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z) # , np.arange(2, 10, .01)) plt.colorbar(c) windTurbines.plot(x, y) plt.show() ref = [ 3.27, 3.27, 9.0, 7.46, 7.46, 7.46, 7.46, 7.31, 7.31, 7.31, 7.31, 8.3, 8.3, 8.3, 8.3, 8.3, 8.3 ] npt.assert_array_almost_equal(Z[49, 100:133:2], ref, 2)
def test_ti_map(): site = IEA37Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines() wake_model = NOJ(site, windTurbines, turbulenceModel=STF2017TurbulenceModel()) aep = AEPCalculator(wake_model) x_j = np.linspace(-1500, 1500, 200) y_j = np.linspace(-1500, 1500, 100) X, Y, Z = aep.ti_map(x_j, y_j, 110, x, y, wd=[0], ws=[9]) m = 49, slice(100, 133, 2) if 0: print(np.round(Z[m], 2).tolist()) # ref import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z, np.arange(.075, .50, .001)) plt.colorbar(c) windTurbines.plot(x, y) plt.plot(X[m], Y[m], '.-r') plt.show() ref = [ 0.48, 0.08, 0.08, 0.13, 0.16, 0.18, 0.19, 0.19, 0.2, 0.18, 0.17, 0.12, 0.13, 0.13, 0.13, 0.12, 0.12 ] npt.assert_array_almost_equal(Z[m], ref, 2)
def main(): if __name__ == '__main__': from py_wake.examples.data.iea37 import iea37_path from py_wake.examples.data.iea37.iea37_reader import read_iea37_windfarm,\ read_iea37_windrose from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines from py_wake.site._site import UniformSite from py_wake.aep_calculator import AEPCalculator class MyWakeModel(SquaredSum, WakeModel): args4deficit = ['WS_lk', 'dw_jl'] def calc_deficit(self, WS_lk, dw_jl): # 10% deficit downstream return (WS_lk * .1)[na] * (dw_jl > 0)[:, :, na] _, _, 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 = MyWakeModel(windTurbines) aep_calculator = AEPCalculator(site, windTurbines, wake_model) import matplotlib.pyplot as plt aep_calculator.plot_wake_map(wt_x=x, wt_y=y, wd=[0, 30], ws=[9], levels=np.linspace(5, 9, 100)) windTurbines.plot(x, y) plt.show()
def main(): if __name__ == '__main__': from py_wake.aep_calculator import AEPCalculator from py_wake.examples.data.iea37 import iea37_path from py_wake.examples.data.iea37._iea37 import IEA37Site from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines # setup site, turbines and wakemodel site = IEA37Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml') from py_wake.tests.test_files import tfp path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+0/' wake_model = Fuga(path, site, windTurbines) # calculate AEP aep_calculator = AEPCalculator(wake_model) aep = aep_calculator.calculate_AEP(x, y)[0].sum() # plot wake map import matplotlib.pyplot as plt aep_calculator.plot_wake_map(wt_x=x, wt_y=y, wd=[0], ws=[9]) plt.title('AEP: %.2f GWh' % aep) windTurbines.plot(x, y) plt.show()
def main(): if __name__ == '__main__': from py_wake.aep_calculator import AEPCalculator from py_wake.examples.data.iea37 import iea37_path from py_wake.examples.data.iea37._iea37 import IEA37Site from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines # setup site, turbines and wakemodel site = IEA37Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines() wake_model = NOJ(windTurbines) # calculate AEP aep_calculator = AEPCalculator(site, windTurbines, wake_model) aep = aep_calculator.calculate_AEP(x, y)[0].sum() # plot wake mape import matplotlib.pyplot as plt aep_calculator.plot_wake_map(wt_x=x, wt_y=y, wd=[0], ws=[9]) plt.title('AEP: %.2f GWh' % aep) windTurbines.plot(x, y) plt.show()
def test_distance_over_rectangle(): x, y = [-100, 50], [200, -100] windTurbines = IEA37_WindTurbines() site = Rectangle(height=200, width=100, distance_resolution=100) wake_model = NOJ(site, windTurbines) aep = AEPCalculator(wake_model) x_j = np.linspace(-100, 500, 100) y_j = np.linspace(-200, 300, 100) X, Y, Z = aep.wake_map(x_j, y_j, 110, x, y, wd=[270], ws=[9]) my = np.argmin(np.abs(Y[:, 0] - 200)) my2 = np.argmin(np.abs(Y[:, 0] + 100)) if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z, cmap='Blues_r', levels=100) # , np.arange(2, 10, .01)) plt.colorbar(c) windTurbines.plot(x, y) H = site.elevation(X, Y) plt.plot(X[my], Z[my] * 10, label='wsp*10') plt.plot(X[my2], Z[my2] * 10, label='wsp*10') plt.contour(X, Y, H) plt.plot(X[my, :50:4], Z[my, :50:4] * 10, '.') plt.plot(x_j, site.elevation(x_j, x_j * 0), label='terrain level') plt.legend() plt.show() ref = [ 9., 3.42, 3.8, 6.02, 6.17, 6.31, 6.43, 7.29, 7.35, 7.41, 7.47, 7.53, 7.58 ] npt.assert_array_almost_equal(Z[my, :50:4], ref, 2)
def test_aep_map(): site = IEA37Site(16) x = [0, 0] y = [0, 200] windTurbines = IEA37_WindTurbines() 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].squeeze('h'), ref, 2)
def test_twotype_windturbines(): from py_wake.wind_turbines import WindTurbines v80 = V80() def power(ws, types): power = v80.power(ws) # add 10% type 1 turbines power[types == 1] *= 1.1 return power wts = WindTurbines(names=['V80', 'V88'], diameters=[80, 88], hub_heights=[70, 77], ct_funcs=[v80.ct_funcs[0], v80.ct_funcs[0]], power_funcs=[v80.power, lambda ws: v80.power(ws) * 1.1], power_unit='w') import matplotlib.pyplot as plt types0 = [0] * 9 types1 = [0, 0, 0, 1, 1, 1, 0, 0, 0] types2 = [1] * 9 wts.plot(wt9_x, wt9_y, types1) aep_calculator = AEPCalculator(NOJ(Hornsrev1Site(), wts)) npt.assert_almost_equal( aep_calculator.calculate_AEP(wt9_x, wt9_y, type_i=types0).sum(), 81.2066072392765) npt.assert_almost_equal( aep_calculator.calculate_AEP(wt9_x, wt9_y, type_i=types1).sum(), 83.72420504573488) npt.assert_almost_equal( aep_calculator.calculate_AEP(wt9_x, wt9_y, type_i=types2).sum(), 88.87227386796884) if 0: plt.show()
def run_NOJ(): windTurbines = IEA37_WindTurbines() site = IEA37Site(64) wake_model = NOJ(windTurbines) aep_calculator = AEPCalculator(site, windTurbines, wake_model) x, y = site.initial_position.T print(aep_calculator.calculate_AEP(x, y).sum())
def test_wake_model(): _, _, freq = read_iea37_windrose(iea37_path + "iea37-windrose.yaml") site = UniformSite(freq, ti=0.75) windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml') wake_model = NOJ(windTurbines) aep = AEPCalculator(site, windTurbines, wake_model) with pytest.raises(ValueError, match="Turbines 0 and 1 are at the same position"): aep.calculate_AEP([0, 0], [0, 0], wd=np.arange(0, 360, 22.5), ws=[9.8])
def main(): if __name__ == '__main__': import matplotlib.pyplot as plt wt = HornsrevV80() wt.plot(wt_x, wt_y) aep_calculator = AEPCalculator(Hornsrev1Site(), wt, NOJ(wt)) print('AEP', aep_calculator.calculate_AEP(wt_x, wt_y)[0].sum()) plt.show()
def test_fuga(): # move turbine 1 600 300 wt_x = [-250, 600, -500, 0, 500, -250, 250] wt_y = [433, 300, 0, 0, 0, -433, -433] wts = HornsrevV80() path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+0/' site = UniformSite([1, 0, 0, 0], ti=0.75) wake_model = Fuga(path, wts) aep = AEPCalculator(site, wts, wake_model) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) _, _, Z70 = aep.wake_map(x_j, y_j, 70, wt_x, wt_y, wt_height=70, wd=[30], ws=[10]) X, Y, Z73 = aep.wake_map(x_j, y_j, 73, wt_x, wt_y, wt_height=70, wd=[30], ws=[10]) if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z70, np.arange(6, 10.5, .1)) plt.colorbar(c) plt.plot(X[0], Y[140]) wts.plot(wt_x, wt_y) plt.figure() plt.plot(X[0], Z70[140, :], label="Z=70m") plt.plot(X[0], Z73[140, :], label="Z=73m") plt.plot(X[0, 100:400:10], Z70[140, 100:400:10], '.') plt.legend() plt.show() npt.assert_array_almost_equal(Z70[140, 100:400:10], [ 10.0547, 10.0519, 10.0718, 10.0093, 9.6786, 7.8589, 6.8539, 9.2199, 9.9837, 10.036, 10.0796, 10.0469, 10.0439, 9.1866, 7.2552, 9.1518, 10.0449, 10.0261, 10.0353, 9.9256, 9.319, 8.0062, 6.789, 8.3578, 9.9393, 10.0332, 10.0191, 10.0186, 10.0191, 10.0139 ], 4) npt.assert_array_almost_equal(Z73[140, 100:400:10], [ 10.0542, 10.0514, 10.0706, 10.0075, 9.6778, 7.9006, 6.9218, 9.228, 9.9808, 10.0354, 10.0786, 10.0464, 10.0414, 9.1973, 7.3099, 9.1629, 10.0432, 10.0257, 10.0344, 9.9236, 9.3274, 8.0502, 6.8512, 8.3813, 9.9379, 10.0325, 10.0188, 10.0183, 10.019, 10.0138 ], 4)
def test_aep_map_no_turbines(): site = IEA37Site(16) windTurbines = IEA37_WindTurbines() wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines) aep = AEPCalculator(wake_model) x_j = np.arange(-150, 150, 20) y_j = np.arange(-250, 250, 20) _, _, 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 cmp_fuga_with_colonel(): # move turbine 1 600 300 wt_x = [-250, 600, -500, 0, 500, -250, 250] wt_y = [433, 300, 0, 0, 0, -433, -433] wts = HornsrevV80() xy, Z = [ v for _, v in np.load(tfp + "fuga/U_XY_70m_.txt_30deg.npz").items() ] x_min, x_max, x_step, y_min, y_max, y_step = xy x_j = np.arange( x_min, np.round((x_max - x_min) / x_step) * x_step + x_min + x_step, x_step) y_j = np.arange( y_min, np.round((y_max - y_min) / y_step) * y_step + y_min + y_step, y_step) path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+0/' site = UniformSite([1, 0, 0, 0], ti=0.75) wake_model = Fuga(path, wts) aep = AEPCalculator(site, wts, wake_model) X, Y, Z2 = aep.wake_map(x_j, y_j, 70, wt_x, wt_y, h_i=70, wd=[30], ws=[10]) print(x_j) print(y_j) m = (X == 500) & (Y == -880) print(Z[m]) print(Z2[m]) if 1: import matplotlib.pyplot as plt plt.clf() c = plt.contourf(X, Y, Z, np.arange(6, 10.5, .1)) plt.colorbar(c, label="m/s") plt.axis('equal') plt.tight_layout() wts.plot(wt_x, wt_y) plt.figure() c = plt.contourf(X, Y, Z2, np.arange(6, 10.5, .1)) plt.colorbar(c) wts.plot(wt_x, wt_y) plt.figure() c = plt.contourf(X, Y, Z2 - Z, np.arange(-.01, .01, .001)) plt.colorbar(c, label="m/s") wts.plot(wt_x, wt_y) plt.show() npt.assert_array_almost_equal(Z, Z2, 2)
def test_stf(WakeModel, ref_ti): # setup site, turbines and wakemodel site = IEA37Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines() wake_model = WakeModel(site, windTurbines) aep_calculator = AEPCalculator(wake_model) aep_calculator.calculate_AEP(x, y) # print(np.round(aep_calculator.TI_eff_ilk[:, 0, 0], 3).tolist()) npt.assert_array_almost_equal(aep_calculator.TI_eff_ilk[:, 0, 0], ref_ti, 3)
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_no_wake_loss_hornsrev(): wt = hornsrev1.V80() x, y = hornsrev1.wt_x, hornsrev1.wt_y site = UniformWeibullSite([1], [10], [2], .75) site.default_ws = np.arange(3, 25) aep = AEPCalculator(site, wt, NOJ(wt)) npt.assert_almost_equal(aep.calculate_AEP_no_wake_loss(x, y).sum() / 80, 8.260757098) cap_factor = aep.calculate_AEP(x, y).sum() / aep.calculate_AEP_no_wake_loss(x, y).sum() # print(cap_factor) npt.assert_almost_equal(cap_factor, 0.947175839142014)
def test_NOJ_Nibe_result_wake_map(): # Replicate result from: Jensen, Niels Otto. "A note on wind generator interaction." (1983). def ct_func(_): return 8 / 9 def power_func(*_): return 0 windTurbines = NibeA0 wake_model = NOJ(windTurbines) site = UniformSite([1], 0.1) aep = AEPCalculator(site, windTurbines, wake_model) _, _, WS_eff_yx = aep.wake_map(x_j=[0], y_j=[0, -40, -100], h=50, wt_x=[0], wt_y=[0], wd=[0], ws=[8.1]) npt.assert_array_almost_equal(WS_eff_yx[:, 0], [8.1, 4.35, 5.7])
def test_wec(): # move turbine 1 600 300 wt_x = [-250, 600, -500, 0, 500, -250, 250] wt_y = [433, 300, 0, 0, 0, -433, -433] wts = HornsrevV80() site = UniformSite([1, 0, 0, 0], ti=0.75) wake_model = Fuga(LUT_path_2MW_z0_0_03, wts) aep = AEPCalculator(site, wts, wake_model) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) _, _, Z_wec1 = aep.wake_map(x_j, y_j, 70, wt_x, wt_y, wt_height=70, wd=[30], ws=[10]) aep.wake_model.wec = 2 X, Y, Z_wec2 = aep.wake_map(x_j, y_j, 70, wt_x, wt_y, wt_height=70, wd=[30], ws=[10]) if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z_wec1, np.arange(6, 10.5, .1)) plt.colorbar(c) plt.plot(X[0], Y[140]) wts.plot(wt_x, wt_y) plt.figure() c = plt.contourf(X, Y, Z_wec2, np.arange(6, 10.5, .1)) plt.colorbar(c) plt.plot(X[0], Y[140]) wts.plot(wt_x, wt_y) plt.figure() plt.plot(X[0], Z_wec1[140, :], label="Z=70m") plt.plot(X[0], Z_wec2[140, :], label="Z=70m") plt.plot(X[0, 100:400:10], Z_wec1[140, 100:400:10], '.') plt.plot(X[0, 100:400:10], Z_wec2[140, 100:400:10], '.') plt.legend() plt.show() npt.assert_array_almost_equal( Z_wec1[140, 100:400:10], [10.0547, 10.0519, 10.0718, 10.0093, 9.6786, 7.8589, 6.8539, 9.2199, 9.9837, 10.036, 10.0796, 10.0469, 10.0439, 9.1866, 7.2552, 9.1518, 10.0449, 10.0261, 10.0353, 9.9256, 9.319, 8.0062, 6.789, 8.3578, 9.9393, 10.0332, 10.0191, 10.0186, 10.0191, 10.0139], 4) npt.assert_array_almost_equal( Z_wec2[140, 100:400:10], [10.0297, 9.9626, 9.7579, 9.2434, 8.2318, 7.008, 6.7039, 7.7303, 9.0101, 9.6877, 9.9068, 9.7497, 9.1127, 7.9505, 7.26, 7.9551, 9.2104, 9.7458, 9.6637, 9.1425, 8.2403, 7.1034, 6.5109, 7.2764, 8.7653, 9.7139, 9.9718, 10.01, 10.0252, 10.0357], 4)
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 = WaspGridSiteBase.from_wasp_grd(ParqueFicticio_path, speedup_using_pickle=False) site.initial_position = np.array([ [263655.0, 6506601.0], [263891.1, 6506394.0], [264022.2, 6506124.0], [264058.9, 6505891.0], [264095.6, 6505585.0], [264022.2, 6505365.0], [264022.2, 6505145.0], [263936.5, 6504802.0], ]) windTurbines = IEA37_WindTurbines() wake_model = NOJ(site, windTurbines) x, y = site.initial_position.T aep_calculator = AEPCalculator(wake_model) print(aep_calculator.calculate_AEP(x, y).sum())
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_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_BastankhahGaussian_ex16(): site = IEA37_Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml') wake_model = BastankhahGaussian(windTurbines) if 0: import matplotlib.pyplot as plt windTurbines.plot(x, y) plt.show() 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 last run (no evidens that these number are correct) aep_ref = (355971.9717035484, [ 9143.74048, 8156.71681, 11311.92915, 13955.06316, 19807.65346, 25196.64182, 39006.65223, 41463.31044, 23042.22602, 12978.30551, 14899.26913, 32320.21637, 67039.04091, 17912.40907, 12225.04134, 7513.75582 ]) 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 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()
def test_wake_map(): _, _, 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 = NOJ(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]) if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z) # , np.arange(2, 10, .01)) plt.colorbar(c) site.plot_windturbines(x, y) plt.show() ref = [3.27, 3.27, 9.0, 7.46, 7.46, 7.46, 7.46, 7.31, 7.31, 7.31, 7.31, 8.3, 8.3, 8.3, 8.3, 8.3, 8.3] npt.assert_array_almost_equal(Z[49, 100:133:2], ref, 2)
def test_BastankhahGaussian_wake_map(): site = IEA37_Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml') wake_model = BastankhahGaussian(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 = [ 0.18, 3.6, 7.27, 8.32, 7.61, 6.64, 5.96, 6.04, 6.8, 7.69, 8.08, 7.87, 7.59, 7.46, 7.55, 7.84, 8.19 ] if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z, np.arange(-.25, 9.1, .01)) plt.colorbar(c) windTurbines.plot(x, y) plt.show() npt.assert_array_almost_equal(Z[49, 100:133:2], ref, 2)
def test_wake_map(): site = IEA37Site(16) x, y = site.initial_position.T windTurbines = IEA37_WindTurbines() wake_model = NOJ(site, windTurbines) aep = AEPCalculator(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]) m = 49, slice(100, 133, 2) # print(np.round(Z[m], 2).tolist()) # ref if 0: import matplotlib.pyplot as plt c = plt.contourf(X, Y, Z) # , np.arange(2, 10, .01)) plt.colorbar(c) windTurbines.plot(x, y) plt.plot(X[m], Y[m], '.-r') plt.show() ref = [ 3.27, 3.27, 9.0, 7.46, 7.46, 7.46, 7.46, 7.31, 7.31, 7.31, 7.31, 8.3, 8.3, 8.3, 8.3, 8.3, 8.3 ] npt.assert_array_almost_equal(Z[m], ref, 2)
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_aep_no_wake(): site = UniformWeibullSite([1], [10], [2], .75) V80 = hornsrev1.V80() aep = AEPCalculator(NOJ(site, V80)) npt.assert_almost_equal( aep.calculate_AEP([0], [0], ws=np.arange(3, 25)).sum(), 8.260757098, 9)