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 test_fuga_wriggles(): wts = HornsrevV80() path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+00/' site = hornsrev1.Hornsrev1Site() fuga = PropagateDownwind(site, wts, FugaDeficit(path, remove_wriggles=True)) D = 80 flow_map_cw = fuga([0], [0], wd=270, ws=10).flow_map( HorizontalGrid([0], np.arange(-20 * D, 20 * D))) y = np.linspace(-5 * D, 5 * D, 100) dw_lst = range(10) flow_map_cw_lst = np.array([ fuga([0], [0], wd=270, ws=10).flow_map(HorizontalGrid([dw * D], y)).WS_eff.squeeze() for dw in dw_lst ]) if 0: for flow_map_cw, dw in zip(flow_map_cw_lst, dw_lst): plt.plot(y, flow_map_cw, label="%dD" % dw) plt.xlabel('y [m]') plt.ylabel('ws [m/s') plt.ylim([9.9, 10.1]) plt.grid() plt.legend(loc=1) plt.show() assert np.all(flow_map_cw_lst > 0)
def test_fuga_table_edges(): wts = HornsrevV80() path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+00/' site = hornsrev1.Hornsrev1Site() fuga = FugaBlockage(path, site, wts) D = 80 flow_map_dw = fuga([0], [0], wd=270, ws=10).flow_map( HorizontalGrid(np.arange(-200 * D, 450 * D), y=[0])) flow_map_cw = fuga([0], [0], wd=270, ws=10).flow_map( HorizontalGrid([0], np.arange(-20 * D, 20 * D))) flow_map = fuga([0], [0], wd=270, ws=10).flow_map( HorizontalGrid(np.arange(-150, 400) * D, np.arange(-20, 21) * D)) if 0: plt.plot(flow_map_dw.x / D, flow_map_dw.WS_eff.squeeze()) plt.grid() plt.ylim([9.9, 10.1]) plt.figure() plt.plot(flow_map_cw.y / D, flow_map_cw.WS_eff.squeeze()) plt.grid() plt.ylim([9.9, 10.1]) plt.figure() flow_map.WS_eff.plot() plt.show() npt.assert_array_equal(flow_map.WS_eff.squeeze()[[0, -1], :], 10) npt.assert_array_equal(flow_map.WS_eff.squeeze()[:, [0, -1]], 10)
def test_interpolation(): wts = HornsrevV80() path = tfp + 'fuga/2MW/Z0=0.00408599Zi=00400Zeta0=0.00E+00/' site = UniformSite([1, 0, 0, 0], ti=0.075) plot = 0 if plot: ax1 = plt.gca() ax2 = plt.twinx() for wdm, n_d_values in ( (FugaDeficit(path, method='linear'), 4), (FugaDeficit(path, method='spline'), 20), (FugaYawDeficit(path, method='linear'), 4), (FugaYawDeficit(path, method='spline'), 20), ): wfm = PropagateDownwind(site, wts, wdm) sim_res = wfm(x=[0], y=[0], wd=[270], ws=[10], yaw=[[[10]]]) fm = sim_res.flow_map(XYGrid(x=[200], y=np.arange(-10, 11))) fm = sim_res.flow_map( XYGrid(x=np.arange(-100, 800, 10), y=np.arange(-10, 11))) # linear has 4 line segments with same gradient, while spline has 20 different gradient values npt.assert_equal( len(np.unique(np.round(np.diff(fm.WS_eff.sel(x=500).squeeze()), 6))), n_d_values) if plot: ax1.plot(fm.y, fm.WS_eff.sel(x=500).squeeze()) ax2.plot(fm.y[:-1], np.diff(fm.WS_eff.sel(x=500).squeeze()), '--') if plot: plt.show() plt.close('all')
def check_speed_Hornsrev(WFModel): assert getattr(sys, 'gettrace')() is None, "Skipping speed check, In debug mode!!!" wt = HornsrevV80() site = Hornsrev1Site() wf_model = WFModel(site, wt) aep, t_lst = timeit(lambda x, y: wf_model(x, y).aep().sum())(wt_x, wt_y) fn = tfp + "speed_check/%s.txt" % WFModel.__name__ if os.path.isfile(fn): with open(fn) as fid: lines = fid.readlines() # check aep npt.assert_almost_equal(float(lines[-1].split(";")[1]), aep) timings = np.array([(np.mean(eval(l.split(";")[2])), np.std(eval(l.split(";")[2]))) for l in lines]) dates = [np.datetime64(l.split(";")[0]) for l in lines] dates = np.r_[dates, datetime.now()] y = np.r_[timings[:, 0], np.mean(t_lst)] error = np.r_[timings[:, 1], np.std(t_lst)] fig, axes = plt.subplots(2, 1) fig.suptitle(WFModel.__name__) for x, ax in zip([dates, np.arange(len(dates))], axes): ax.fill_between(x, y - 2 * error, y + 2 * error) ax.plot(x, y, '.-k') ax.axhline(y[:-1].mean() + 2 * error[:-1].mean(), ls='--', color='gray') if y[-1] > (y[:-1].mean() + 2 * error[:-1].mean()): raise Exception("Simulation time too slow, %f > %f" % (y[-1], (y[:-1].mean() + 2 * error[:-1].mean()))) if getattr(sys, 'gettrace')() is None: with open(fn, 'a') as fid: fid.write("%s;%.10f;%s\n" % (datetime.now(), aep, t_lst))
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 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_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_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_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 main(): if __name__ == '__main__': import matplotlib.pyplot as plt wt = HornsrevV80() site = Hornsrev1Site() wt.plot(wt_x, wt_y) wf_model = NOJ(site, wt) aep = wf_model(wt_x, wt_y).aep() plt.title('AEP: %.1fGWh' % aep.sum()) plt.show()
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_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) wfm = BastankhahGaussian(site, wts) x_j = np.linspace(-1500, 1500, 500) y_j = np.linspace(-1500, 1500, 300) flow_map_wec1 = wfm(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] wfm.wec = 2 flow_map_wec2 = wfm(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, 2))) print(list(np.round(Z_wec2[140, 100:400:10].values, 2))) 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.0, 10.0, 10.0, 9.99, 9.8, 6.52, 1.47, 9.44, 9.98, 10.0, 10.0, 10.0, 10.0, 9.05, 0.03, 9.11, 10.0, 10.0, 10.0, 9.97, 9.25, 7.03, 2.35, 6.51, 9.99, 10.0, 10.0, 10.0, 10.0, 10.0 ], 2) npt.assert_array_almost_equal(Z_wec2[140, 100:400:10], [ 9.99, 9.96, 9.84, 9.47, 7.82, 2.24, 0.21, 6.21, 9.22, 9.82, 9.98, 9.92, 9.05, 4.45, 0.01, 4.53, 9.35, 9.95, 9.75, 9.13, 7.92, 5.14, 0.32, 2.2, 8.38, 9.94, 10.0, 10.0, 10.0, 10.0 ], 2)
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_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 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 main(): if __name__ == '__main__': site = UniformSite(p_wd=[1], ti=.1) # Dummy site (flat and uniform) # Validation cases: SingleWakecases = [{ 'name': 'Wieringermeer-West', 'U0': 10.7, 'CT': 0.63, 'TItot': 0.08, 'D': 80.0, 'zH': 80.0, 'xDown': np.array([2.5, 3.5, 7.5]), 'location': 'onshore' }, { 'name': 'Wieringermeer-East', 'U0': 10.9, 'CT': 0.63, 'TItot': 0.06, 'D': 80.0, 'zH': 80.0, 'xDown': np.array([2.5, 3.5, 7.5]), 'location': 'onshore' }, { 'name': 'Nibe', 'U0': 8.5, 'CT': 0.89, 'TItot': 0.08, 'D': 40.0, 'zH': 45.0, 'xDown': np.array([2.5, 4, 7.5]), 'location': 'onshore' }, { 'name': 'Nordtank-500', 'U0': 7.45, 'CT': 0.70, 'TItot': 0.112, 'D': 41.0, 'zH': 36.0, 'xDown': np.array([2, 5, 7.5]), 'location': 'onshore' }, { 'name': 'NREL-5MW_TIlow', 'U0': 8.0, 'CT': 0.79, 'TItot': 0.04, 'D': 126.0, 'zH': 90.0, 'xDown': np.array([2.5, 5, 7.5]), 'location': 'offshore' }, { 'name': 'NREL-5MW_TIhigh', 'U0': 8.0, 'CT': 0.79, 'TItot': 0.128, 'D': 126.0, 'zH': 90.0, 'xDown': np.array([2.5, 5, 7.5]), 'location': 'onshore' }] # If missing wind turbines need to be included in the plot, one should write np.nan in the wts list. hr_inner_rows = np.linspace(0, 79, 80).reshape(10, 8)[:, 1:7].flatten( ).tolist() # WTs representing the inner rows of Horns Rev 1 WFcases = [{ 'name': 'Wieringermeer', 'U0': 8.35, 'TItot': 0.096, 'wt': N80(), 'wt_x': wt_x_w, 'wt_y': wt_y_w, 'site': site, 'location': 'onshore', 'plots': [{ 'name': 'Row', 'wd': 275.0, 'wts': [0, 1, 2, 3, 4] }] }, { 'name': 'Lillgrund', 'U0': 9.0, 'TItot': 0.048, 'wt': SWT2p3_93_65(), 'wt_x': wt_x_l, 'wt_y': wt_y_l, 'site': LillgrundSite(), 'location': 'offshore', 'plots': [{ 'name': 'RowB', 'wd': 222.0, 'wts': [14, 13, 12, 11, 10, 9, 8, 7] }, { 'name': 'RowD', 'wd': 222.0, 'wts': [29, 28, 27, np.nan, 26, 25, 24, 23] }, { 'name': 'RowB', 'wd': 207.0, 'wts': [14, 13, 12, 11, 10, 9, 8, 7] }, { 'name': 'RowD', 'wd': 207.0, 'wts': [29, 28, 27, np.nan, 26, 25, 24, 23] }, { 'name': 'Row6', 'wd': 120.0, 'wts': [2, 9, 17, 25, 32, 37, 42, 46] }, { 'name': 'Row4', 'wd': 120.0, 'wts': [4, 11, 19, np.nan, np.nan, 39, 44] }, { 'name': 'Row6', 'wd': 105.0, 'wts': [2, 9, 17, 25, 32, 37, 42, 46] }, { 'name': 'Row4', 'wd': 105.0, 'wts': [4, 11, 19, np.nan, np.nan, 39, 44] }, { 'name': 'WFeff' }] }, { 'name': 'Hornsrev1', 'U0': 8.0, 'TItot': 0.056, 'wt': HornsrevV80(), 'wt_x': wt_x_hr, 'wt_y': wt_y_hr, 'site': Hornsrev1Site(), 'location': 'offshore', 'plots': [{ 'name': 'InnerRowMean', 'wd': 270.0, 'wts': hr_inner_rows }] }] # Revert back to old default style: mpl.style.use('classic') # Latex font plt.rcParams['font.family'] = 'STIXGeneral' linewidth = 1.5 cLES = 'c' cRANS = 'g' colors = ['r', 'b'] # Plot velocity deficit of single wake cases and calculate integrated velocity deficit UdefCases = deficitPlotSingleWakeCases(SingleWakecases, site, linewidth, cLES, cRANS, colors) # Plot bar plot of integrated velocity deficit of single wake cases barPlotSingleWakeCases(SingleWakecases, UdefCases, cLES, cRANS, colors) # Plot power deficit in a row of wind turbine or plot wind farm efficiency deficitPlotWFCases(WFcases, linewidth, cLES, cRANS, colors)
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)
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 __init__(self): self.windFarmModel_dict = {} # single wake cases swc = { 'Wieringermeer-West': {'U0': 10.7, 'CT': 0.63, 'TItot': 0.08, 'D': 80.0, 'zH': 80.0, 'xDown': np.array([2.5, 3.5, 7.5]), 'sDown': 80.0, 'location': 'onshore'}, 'Wieringermeer-East': {'U0': 10.9, 'CT': 0.63, 'TItot': 0.06, 'D': 80.0, 'zH': 80.0, 'xDown': np.array([2.5, 3.5, 7.5]), 'sDown': 80.0, 'location': 'onshore'}, 'Nibe': {'U0': 8.5, 'CT': 0.89, 'TItot': 0.08, 'D': 40.0, 'zH': 45.0, 'xDown': np.array([2.5, 4, 7.5]), 'sDown': 40.0, 'location': 'onshore'}, 'Nordtank-500': {'U0': 7.45, 'CT': 0.70, 'TItot': 0.112, 'D': 41.0, 'zH': 36.0, 'xDown': np.array([2, 5, 7.5]), 'sDown': 40.0, 'location': 'onshore'}, 'NREL-5MW_TIlow': {'U0': 8.0, 'CT': 0.79, 'TItot': 0.04, 'D': 126.0, 'zH': 90.0, 'xDown': np.array([2.5, 5, 7.5]), 'sDown': 126.0, 'location': 'offshore'}, 'NREL-5MW_TIhigh': {'U0': 8.0, 'CT': 0.79, 'TItot': 0.128, 'D': 126.0, 'zH': 90.0, 'xDown': np.array([2.5, 5, 7.5]), 'sDown': 126.0, 'location': 'onshore'} } self.single_wake_cases = [SingleWakeValidationCase.from_case_dict(k, v) for k, v in swc.items()] # multiwake cases from py_wake.examples.data.hornsrev1 import wt_x as wt_x_hr from py_wake.examples.data.hornsrev1 import wt_y as wt_y_hr from py_wake.validation.ecn_wieringermeer import wt_x as wt_x_w from py_wake.validation.ecn_wieringermeer import wt_y as wt_y_w from py_wake.validation.lillgrund import wt_x as wt_x_l from py_wake.validation.lillgrund import wt_y as wt_y_l def get_site(ti, ws, wt_x, wt_y): return UniformSite(p_wd=[1], ti=ti, ws=ws, initial_position=np.array([wt_x, wt_y]).T) hr_inner_rows = np.arange(80).reshape(10, 8)[:, 1:7].flatten().tolist() self.multi_wake_cases = [MultiWakeValidationCase('Wieringermeer', site=get_site( ti=0.096 / 0.8, ws=8.35, wt_x=wt_x_w, wt_y=wt_y_w), windTurbines=N80(), sigma=2.5 * np.ones(len(wt_x_w)), plots=[RowPlot(name='Row', wd=275.0, wts=[0, 1, 2, 3, 4])]), MultiWakeValidationCase('Lillgrund', site=get_site(ti=0.048, ws=9, wt_x=wt_x_l, wt_y=wt_y_l), windTurbines=SWT2p3_93_65(), sigma=3.3 * np.ones(len(wt_x_l)), plots=[RowPlot('RowB', 222.0, [14, 13, 12, 11, 10, 9, 8, 7]), RowPlot('RowD', 222.0, [ 29, 28, 27, np.nan, 26, 25, 24, 23]), RowPlot('RowB', 207.0, [14, 13, 12, 11, 10, 9, 8, 7]), RowPlot('RowD', 207.0, [ 29, 28, 27, np.nan, 26, 25, 24, 23]), RowPlot('Row6', 120.0, [2, 9, 17, 25, 32, 37, 42, 46]), RowPlot('Row4', 120.0, [ 4, 11, 19, np.nan, np.nan, 39, 44]), RowPlot('Row6', 105.0, [2, 9, 17, 25, 32, 37, 42, 46]), RowPlot('Row4', 105.0, [ 4, 11, 19, np.nan, np.nan, 39, 44]), WindRosePlot(), ]), MultiWakeValidationCase('Hornsrev1', site=get_site(ti=0.056, ws=8, wt_x=wt_x_hr, wt_y=wt_y_hr), windTurbines=HornsrevV80(), sigma=sigma_hornsrev('vanderLaan', wt_x_hr, wt_y_hr), plots=[RowPlot('InnerRowMean', 270.0, hr_inner_rows), WindRosePlot(), ]) ]