From e028947497ce89c86462788de0f1a5695b0e1542 Mon Sep 17 00:00:00 2001 From: "Mads M. Pedersen" <mmpe@dtu.dk> Date: Wed, 25 Apr 2018 10:46:59 +0200 Subject: [PATCH] read wind climate from lib file for gcl to be consistent with fuga --- examples/irp_wind/optimization_3tb.py | 46 ++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/examples/irp_wind/optimization_3tb.py b/examples/irp_wind/optimization_3tb.py index 67adc61a..2da02686 100644 --- a/examples/irp_wind/optimization_3tb.py +++ b/examples/irp_wind/optimization_3tb.py @@ -7,50 +7,74 @@ from topfarm.cost_models.utils.aep_calculator import AEPCalculator from topfarm.cost_models.utils.wind_resource import WindResource from topfarm.plotting import PlotComp from topfarm.topfarm import TopFarm - +from topfarm.cost_models.fuga.lib_reader import read_lib +import matplotlib.pyplot as plt D = 80.0 D2 = 2 * D initial_position = np.array([(0, D2), (0, 0), (0, -D2)]) boundary = [(-D2, D2), (D2, D2), (D2, -D2), (-D2, -D2)] minSpacing = 2.0 +fuga_path = os.path.abspath(os.path.dirname(py_fuga.__file__)) + '/Colonel/' def optimize_AEP_FusedWake_GCL(): plot_comp = PlotComp() - f = [1, 0, 0, 0] - A = [9.176929, 9.782334, 9.531809, 9.909545] - k = [2.392578, 2.447266, 2.412109, 2.591797] - + f, A, k = read_lib(fuga_path + 'LUT/Farms/Horns Rev 1\hornsrev_north_only_pm45.lib') wr = WindResource(f, A, k, ti=np.zeros_like(f) + .1) - wm = FusedWakeGCLWakeModel(os.path.dirname(__file__) + "/3tb.yml") aep_calc = AEPCalculator(wr, wm) - aep_calc(np.array([[0, 0, 100], [160, 0, -160]]).T) init_pos = initial_position.copy() - init_pos[:, 0] += [-50, 0, 50] - print(aep_calc(np.array([[-160, 0, 160], [0, 0, 0]]).T)) + init_pos[:, 0] += [-20, 0, 20] tf = TopFarm(init_pos, aep_calc.get_TopFarm_cost_component(), minSpacing * D, boundary=boundary, plot_comp=plot_comp) + tf.evaluate() + print(tf.get_cost()) tf.optimize() + print(tf.get_cost()) + save_plot('final_gcl.png', tf, False) plot_comp.show() def optimize_AEP_Fuga(): plot_comp = PlotComp() - fuga_path = os.path.abspath(os.path.dirname(py_fuga.__file__)) + '/Colonel/' + pyFuga = PyFuga(farm_name='Horns Rev 1', turbine_model_path=fuga_path + 'LUT/', turbine_model_name='Vestas_V80_(2_MW_offshore)[h=67.00]', tb_x=initial_position[:, 0], tb_y=initial_position[:, 1], mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0, - farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1\hornsrev_north_only.lib') + farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1\hornsrev_north_only_pm45.lib', climate_interpolation=False) init_pos = initial_position.copy() init_pos[:, 0] += [-20, 0, 20] tf = TopFarm(init_pos, pyFuga.get_TopFarm_cost_component(), minSpacing * D, boundary=boundary, plot_comp=plot_comp) + + save_plot('initial.png', tf, True) + tf.evaluate() + print(tf.get_cost()) tf.optimize() + print(tf.get_cost()) + save_plot('final_fuga.png', tf, False) plot_comp.show() +def save_plot(filename, tf, initial=False): + import matplotlib.pyplot as plt + plt.figure(figsize=(3, 3)) + plt.axis('equal') + plt.xlabel('Distance [m]') + plt.ylabel('Distance [m]') + if initial: + pos = tf.initial_positions + else: + pos = tf.turbine_positions + plt.plot(tf.boundary[:, 0], tf.boundary[:, 1], label='Boundary') + plt.plot(pos[:, 0], pos[:, 1], '2', ms=15, label='%s turbine positions' % ('Optimized', 'initial')[initial]) + # plt.legend(loc=1) + plt.tight_layout() + plt.savefig(filename) + plt.show() + + if __name__ == '__main__': optimize_AEP_Fuga() optimize_AEP_FusedWake_GCL() -- GitLab