def test_fuga_new_format(): # 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.00408599Zi=00400Zeta0=0.00E+00/' site = UniformSite([1, 0, 0, 0], ti=0.075) wake_model = Fuga(path, site, wts) res = wake_model(x=wt_x, y=wt_y, wd=[30], ws=[10]) npt.assert_array_almost_equal(res.WS_eff_ilk.flatten(), [ 10.00647891, 10., 8.21713928, 10.03038884, 9.36889964, 8.23084088, 7.80662141 ], 8) npt.assert_array_almost_equal(res.ct_ilk.flatten(), [ 0.79265014, 0.793, 0.80621714, 0.791359, 0.80183541, 0.80623084, 0.80580662 ], 8) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) wake_model = Fuga(path, site, wts) sim_res = wake_model(wt_x, wt_y, wd=[30], ws=[10]) flow_map70 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=70)) flow_map73 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=73)) X, Y = flow_map70.XY Z70 = flow_map70.WS_eff_xylk[:, :, 0, 0] Z73 = flow_map73.WS_eff_xylk[:, :, 0, 0] if 0: flow_map70.plot_wake_map(levels=np.arange(6, 10.5, .1)) plt.plot(X[0], Y[140]) 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], '.') print(list(np.round(Z70.values[140, 100:400:10], 4))) print(list(np.round(Z73.values[140, 100:400:10], 4))) plt.legend() plt.show() npt.assert_array_almost_equal(Z70[140, 100:400:10], [ 10.0384, 10.042, 10.044, 10.0253, 9.7194, 7.7561, 6.7421, 9.2308, 9.9894, 10.0413, 10.0499, 10.0579, 10.0437, 9.1626, 7.2334, 9.1208, 10.0396, 10.0322, 10.0276, 9.9504, 9.2861, 7.8375, 6.6608, 8.3343, 9.9756, 10.0229, 10.0136, 10.0142, 10.0118, 10.0094 ], 4) npt.assert_array_almost_equal(Z73[140, 100:400:10], [ 10.0384, 10.042, 10.044, 10.0253, 9.7194, 7.7561, 6.7421, 9.2308, 9.9894, 10.0413, 10.0499, 10.0579, 10.0437, 9.1626, 7.2334, 9.1208, 10.0396, 10.0322, 10.0276, 9.9504, 9.2861, 7.8375, 6.6608, 8.3343, 9.9756, 10.0229, 10.0136, 10.0142, 10.0118, 10.0094 ], 4)
def test_fuga_new_format(): # 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.00014617Zi=00399Zeta0=0.00E+0/' site = UniformSite([1, 0, 0, 0], ti=0.075) wake_model = Fuga(path, site, wts) res = wake_model(x=wt_x, y=wt_y, wd=[30], ws=[10]) npt.assert_array_almost_equal(res.WS_eff_ilk.flatten(), [ 10.00725165, 10., 7.92176401, 10.02054952, 9.40501317, 7.92609363, 7.52384558 ], 8) npt.assert_array_almost_equal(res.ct_ilk.flatten(), [ 0.79260841, 0.793, 0.80592176, 0.79189033, 0.80132982, 0.80592609, 0.80552385 ], 8) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) wake_model = Fuga(path, site, wts) sim_res = wake_model(wt_x, wt_y, wd=[30], ws=[10]) flow_map70 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=70)) flow_map73 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=73)) X, Y = flow_map70.XY Z70 = flow_map70.WS_eff_xylk[:, :, 0, 0] Z73 = flow_map73.WS_eff_xylk[:, :, 0, 0] if 0: flow_map70.plot_wake_map(levels=np.arange(6, 10.5, .1)) plt.plot(X[0], Y[140]) 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], '.') print(list(np.round(Z70.values[140, 100:400:10], 4))) print(list(np.round(Z73.values[140, 100:400:10], 4))) plt.legend() plt.show() npt.assert_array_almost_equal(Z70[140, 100:400:10], [ 10.0458, 10.0309, 10.065, 10.0374, 9.7865, 7.7119, 6.4956, 9.2753, 10.0047, 10.0689, 10.0444, 10.0752, 10.0699, 9.1852, 6.9783, 9.152, 10.0707, 10.0477, 10.0365, 9.9884, 9.2867, 7.5714, 6.4451, 8.3276, 9.9976, 10.0251, 10.0264, 10.023, 10.0154, 9.9996 ], 4) npt.assert_array_almost_equal(Z73[140, 100:400:10], [ 10.0458, 10.0309, 10.065, 10.0374, 9.7865, 7.7119, 6.4956, 9.2753, 10.0047, 10.0689, 10.0444, 10.0752, 10.0699, 9.1852, 6.9783, 9.152, 10.0707, 10.0477, 10.0365, 9.9884, 9.2867, 7.5714, 6.4451, 8.3276, 9.9976, 10.0251, 10.0264, 10.023, 10.0154, 9.9996 ], 4)
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.075) wake_model = Fuga(LUT_path_2MW_z0_0_03, site, wts) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) flow_map_wec1 = wake_model(wt_x, wt_y, 70, wd=[30], ws=[10]).flow_map(HorizontalGrid(x_j, y_j)) Z_wec1 = flow_map_wec1.WS_eff_xylk[:, :, 0, 0] wake_model.wec = 2 flow_map_wec2 = wake_model(wt_x, wt_y, 70, wd=[30], ws=[10]).flow_map(HorizontalGrid(x_j, y_j)) X, Y = flow_map_wec1.XY Z_wec2 = flow_map_wec2.WS_eff_xylk[:, :, 0, 0] if 0: print(list(np.round(Z_wec1[140, 100:400:10].values, 4))) print(list(np.round(Z_wec2[140, 100:400:10].values, 4))) flow_map_wec1.plot_wake_map(levels=np.arange(6, 10.5, .1), plot_colorbar=False) plt.plot(X[0], Y[140]) wts.plot(wt_x, wt_y) plt.figure() c = flow_map_wec2.plot_wake_map(levels=np.arange(6, 10.5, .1), plot_colorbar=False) 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.0467, 10.0473, 10.0699, 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.0183, 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_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.075) wake_model = Fuga(path, site, wts) res, _ = timeit(wake_model.__call__, verbose=0, line_profile=0, profile_funcs=[FugaDeficit.interpolate, LUTInterpolator.__call__, GridInterpolator.__call__])(x=wt_x, y=wt_y, wd=[30], ws=[10]) npt.assert_array_almost_equal(res.WS_eff_ilk.flatten(), [10.002683492812844, 10.0, 8.413483643142389, 10.036952526815286, 9.371203842245153, 8.437429367715435, 8.012759083790058], 8) npt.assert_array_almost_equal(res.ct_ilk.flatten(), [0.79285509, 0.793, 0.80641348, 0.79100456, 0.80180315, 0.80643743, 0.80601276], 8) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) wake_model = Fuga(path, site, wts) sim_res = wake_model(wt_x, wt_y, wd=[30], ws=[10]) flow_map70 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=70)) flow_map73 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=73)) X, Y = flow_map70.XY Z70 = flow_map70.WS_eff_xylk[:, :, 0, 0] Z73 = flow_map73.WS_eff_xylk[:, :, 0, 0] if 0: flow_map70.plot_wake_map(levels=np.arange(6, 10.5, .1)) plt.plot(X[0], Y[140]) 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], '.') print(list(np.round(Z70.data[140, 100:400:10], 4))) print(list(np.round(Z73.data[140, 100:400:10], 4))) plt.legend() plt.show() npt.assert_array_almost_equal( Z70[140, 100:400:10], [10.0467, 10.0473, 10.0699, 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.0183, 10.0186, 10.0191, 10.0139], 4) npt.assert_array_almost_equal( Z73[140, 100:400:10], [10.0463, 10.0468, 10.0688, 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.018, 10.0183, 10.019, 10.0138], 4)
def test_fuga_blockage_wt_row(): wts = HornsrevV80() path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+00/' site = hornsrev1.Hornsrev1Site() fuga_pdw = Fuga(path, site, wts) fuga_a2a = FugaBlockage(path, site, wts) x, y = [ np.asarray(xy)[np.arange(0, 73, 8)] for xy in (hornsrev1.wt_x, hornsrev1.wt_y) ] sim_res_pdw = fuga_pdw(x, y, wd=[270]) aep = sim_res_pdw.aep_ilk()[:, 0, :] sim_res_a2a = fuga_a2a(x, y, wd=[270]) aep_blockage = sim_res_a2a.aep_ilk()[:, 0, :] # blockage reduce aep(wd=270) by .24% npt.assert_almost_equal((aep.sum() - aep_blockage.sum()) / aep.sum() * 100, 0.2433161515321294) if 0: plt.plot( (sim_res_pdw.WS_eff_ilk[:, 0, 7] - sim_res_a2a.WS_eff_ilk[:, 0, 7]) / sim_res_pdw.WS_eff_ilk[:, 0, 7] * 100) plt.grid() plt.show()
def test_fuga_downwind(): wts = HornsrevV80() path = tfp + 'fuga/2MW/Z0=0.00408599Zi=00400Zeta0=0.00E+00' site = UniformSite([1, 0, 0, 0], ti=0.075) wfm_UL = Fuga(path, site, wts) wfm_ULT = PropagateDownwind(site, wts, FugaYawDeficit(path)) (ax1, ax2), (ax3, ax4) = plt.subplots(2, 2)[1] def plot(wfm, yaw, ax, min_ws): levels = np.arange(6.5, 10.5, .5) sim_res = wfm([0], [0], wd=270, ws=10, yaw=[[[yaw]]]) fm = sim_res.flow_map(XYGrid(x=np.arange(-100, 500, 5))) npt.assert_almost_equal(fm.WS_eff.min(), min_ws) fm.plot_wake_map(ax=ax, levels=levels) fm.min_WS_eff(fm.x, 70).plot(ax=ax, color='r') plt.axhline(0, color='k') plot(wfm_UL, 0, ax1, 7.15853738) plot(wfm_UL, 30, ax2, 7.83219266) plot(wfm_ULT, 0, ax3, 7.15853738) plot(wfm_ULT, 30, ax4, 8.12261872) if 0: plt.show() plt.close('all')
def main(): if __name__ == '__main__': from py_wake import Fuga from py_wake.examples.data.iea37._iea37 import IEA37Site, IEA37_WindTurbines site = IEA37Site(16) x, y = [0, 600, 1200], [0, 0, 0] # site.initial_position[:2].T windTurbines = IEA37_WindTurbines() from py_wake.tests.test_files import tfp path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+00/' noj = Fuga(path, site, windTurbines, deflectionModel=JimenezWakeDeflection()) yaw = [-30, 30, 0] noj(x, y, yaw=yaw, wd=270, ws=10).flow_map().plot_wake_map() import matplotlib.pyplot as plt plt.show()
def main(): if __name__ == '__main__': from py_wake import NOJ from py_wake import IEA37SimpleBastankhahGaussian, Fuga import py_wake import os import matplotlib.pyplot as plt from py_wake.examples.data.hornsrev1 import HornsrevV80, Hornsrev1Site from py_wake.examples.data.iea37._iea37 import IEA37Site LUT_path = os.path.dirname( py_wake.__file__ ) + '/tests/test_files/fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+00/' wt_x, wt_y = IEA37Site(16).initial_position.T windTurbines = HornsrevV80() site = Hornsrev1Site() wake_models = [ NOJ(site, windTurbines), IEA37SimpleBastankhahGaussian(site, windTurbines), Fuga(LUT_path, site, windTurbines) ] for wake_model in wake_models: # Calculate AEP sim_res = wake_model(wt_x, wt_y) # Plot wake map plt.figure(wake_model.__class__.__name__) plt.title('AEP: %.2f GWh' % sim_res.aep().sum()) flow_map = sim_res.flow_map(wd=[0], ws=[9]) flow_map.plot_wake_map() flow_map.plot_windturbines() 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+00/' site = UniformSite([1, 0, 0, 0], ti=0.075) wake_model = Fuga(path, site, wts) res, _ = timeit(wake_model.__call__, verbose=0, line_profile=0, profile_funcs=[ FugaDeficit.interpolate, LUTInterpolator.__call__, GridInterpolator.__call__ ])(x=wt_x, y=wt_y, wd=[30], ws=[10]) npt.assert_array_almost_equal(res.WS_eff_ilk.flatten(), [ 10.00669629, 10., 8.47606501, 10.03143097, 9.37288077, 8.49301941, 8.07462708 ], 8) npt.assert_array_almost_equal(res.ct_ilk.flatten(), [ 0.7926384, 0.793, 0.80647607, 0.79130273, 0.80177967, 0.80649302, 0.80607463 ], 8) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) wake_model = Fuga(path, site, wts) sim_res = wake_model(wt_x, wt_y, wd=[30], ws=[10]) flow_map70 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=70)) flow_map73 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=73)) X, Y = flow_map70.XY Z70 = flow_map70.WS_eff_xylk[:, :, 0, 0] Z73 = flow_map73.WS_eff_xylk[:, :, 0, 0] if 0: flow_map70.plot_wake_map(levels=np.arange(6, 10.5, .1)) plt.plot(X[0], Y[140]) 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], '.') print(list(np.round(Z70.data[140, 100:400:10], 4))) print(list(np.round(Z73.data[140, 100:400:10], 4))) plt.legend() plt.show() npt.assert_array_almost_equal(Z70[140, 100:400:10], [ 10.0407, 10.0438, 10.0438, 10.013, 9.6847, 7.8787, 6.9561, 9.2251, 9.9686, 10.0382, 10.0498, 10.0569, 10.0325, 9.1787, 7.4004, 9.1384, 10.0329, 10.0297, 10.0232, 9.9265, 9.3163, 8.0768, 6.8858, 8.3754, 9.9592, 10.0197, 10.0118, 10.0141, 10.0118, 10.0095 ], 4) npt.assert_array_almost_equal(Z73[140, 100:400:10], [ 10.0404, 10.0435, 10.0433, 10.0113, 9.6836, 7.9206, 7.0218, 9.2326, 9.9665, 10.0376, 10.0494, 10.0563, 10.0304, 9.1896, 7.4515, 9.15, 10.0317, 10.0294, 10.0226, 9.9245, 9.3252, 8.1192, 6.9462, 8.3988, 9.9574, 10.0194, 10.0117, 10.014, 10.0117, 10.0094 ], 4)
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.075) wake_model = Fuga(path, site, wts) res = wake_model(x=wt_x, y=wt_y, wd=[30], ws=[10]) npt.assert_array_almost_equal(res.WS_eff_ilk.flatten(), [ 10.002683492812844, 10.0, 8.413483643142389, 10.036952526815286, 9.371203842245153, 8.437429367715435, 8.012759083790058 ], 8) npt.assert_array_almost_equal(res.ct_ilk.flatten(), [ 0.79285509, 0.793, 0.80641348, 0.79100456, 0.80180315, 0.80643743, 0.80601276 ], 8) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) wake_model = Fuga(path, site, wts) sim_res = wake_model(wt_x, wt_y, wd=[30], ws=[10]) flow_map70 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=70)) flow_map73 = sim_res.flow_map(HorizontalGrid(x_j, y_j, h=73)) X, Y = flow_map70.XY Z70 = flow_map70.WS_eff_xylk[:, :, 0, 0] Z73 = flow_map73.WS_eff_xylk[:, :, 0, 0] if 0: import matplotlib.pyplot as plt flow_map70.plot_wake_map(levels=np.arange(6, 10.5, .1)) plt.plot(X[0], Y[140]) 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], '.') print(list(np.round(Z70[140, 100:400:10], 4))) print(list(np.round(Z73[140, 100:400:10], 4))) plt.legend() plt.show() # npt.assert_array_almost_equal( # Z70[140, 100:400:10], # [10.0547, 10.0519, 10.0741, 10.0099, 9.6774, 7.8538, 6.8484, 9.2134, 9.9749, 10.0232, 10.0658, 10.0189, 10.0187, # 9.1496, 7.2077, 9.1154, 10.0183, 10.0008, 10.0146, 9.8838, 9.2848, 7.9681, 6.7412, 8.3149, 9.9114, 10.0119, # 10.0011, 9.9979, 10.0002, 9.9981], 4) 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)