diff --git a/examples/irp_wind/Hornsrev_aep.py b/examples/irp_wind/Hornsrev_aep.py index 47d6c5e30d8d39c221ae5112bc9cfa61eca8d4ea..a4e036509faa2256a7a9e09c740aa8cc9007b65a 100644 --- a/examples/irp_wind/Hornsrev_aep.py +++ b/examples/irp_wind/Hornsrev_aep.py @@ -6,23 +6,23 @@ from topfarm.cost_models.fuga.py_fuga import PyFuga from topfarm.cost_models.fused_wake_wrappers import FusedWakeGCLWakeModel from topfarm.cost_models.utils.aep_calculator import AEPCalculator from topfarm.cost_models.utils.wind_resource import WindResource +from topfarm.cost_models.fuga.lib_reader import read_lib + +fuga_path = os.path.abspath(os.path.dirname(py_fuga.__file__)) + '/Colonel/' def HornsrevAEP_FUSEDWake_GCL(): # wind parameters from "Horns Rev 1\hornsrev2.lib - wdir_freq = [0.035972, 0.039487, 0.051674, 0.070002, 0.083645, 0.064348, 0.086432, 0.117705, 0.151576, 0.147379, 0.10012, 0.05166] - weibull_A = [9.176929, 9.782334, 9.531809, 9.909545, 10.04269, 9.593921, 9.584007, 10.51499, 11.39895, 11.68746, 11.63732, 10.08803] - weibull_k = [2.392578, 2.447266, 2.412109, 2.591797, 2.755859, 2.595703, 2.583984, 2.548828, 2.470703, 2.607422, 2.626953, 2.326172] + wdir_freq, weibull_A, weibull_k = read_lib(fuga_path + 'LUT/Farms/Horns Rev 1\hornsrev2.lib') ti = np.zeros_like(wdir_freq) + .1 wr = WindResource(wdir_freq, weibull_A, weibull_k, ti) hornsrev_yml = os.path.dirname(fusedwake.__file__) + "/../examples/hornsrev.yml" wm = FusedWakeGCLWakeModel(hornsrev_yml) aep_calc = AEPCalculator(wr, wm) - return aep_calc(wm.windFarm.pos) + return aep_calc(wm.windFarm.pos.T) def HornsrevAEP_Fuga(): - fuga_path = os.path.abspath(os.path.dirname(py_fuga.__file__)) + '/Colonel/' hornsrev_yml = os.path.dirname(fusedwake.__file__) + "/../examples/hornsrev.yml" wm = FusedWakeGCLWakeModel(hornsrev_yml) tb_x, tb_y = wm.windFarm.pos @@ -31,9 +31,9 @@ def HornsrevAEP_Fuga(): tb_x=tb_x, tb_y=tb_y, mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0, farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1\hornsrev2.lib') - return pyFuga.get_aep(tb_x, tb_x)[0] + return pyFuga.get_aep(wm.windFarm.pos.T)[0] if __name__ == '__main__': - print(HornsrevAEP_FUSEDWake_GCL()) print(HornsrevAEP_Fuga()) + print(HornsrevAEP_FUSEDWake_GCL()) diff --git a/examples/irp_wind/optimization_3tb.py b/examples/irp_wind/optimization_3tb.py index 2da02686db9ad9a010c020e7ba7f8e19282ba8d8..b80b597bec4e10d3accb0874eee5bf6d0b9ce6c0 100644 --- a/examples/irp_wind/optimization_3tb.py +++ b/examples/irp_wind/optimization_3tb.py @@ -26,7 +26,8 @@ def optimize_AEP_FusedWake_GCL(): aep_calc = AEPCalculator(wr, wm) init_pos = initial_position.copy() 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 = TopFarm(init_pos, aep_calc.get_TopFarm_cost_component(), minSpacing * D, boundary=boundary, plot_comp=plot_comp, + driver_options={'optimizer': 'SLSQP'}) tf.evaluate() print(tf.get_cost()) tf.optimize() @@ -46,8 +47,9 @@ def optimize_AEP_Fuga(): 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) - + tf = TopFarm(init_pos, pyFuga.get_TopFarm_cost_component(), minSpacing * D, boundary=boundary, plot_comp=plot_comp, + driver_options={'optimizer': 'SLSQP'}) + print (pyFuga.get_aep_gradients()) save_plot('initial.png', tf, True) tf.evaluate() print(tf.get_cost()) @@ -58,6 +60,7 @@ def optimize_AEP_Fuga(): def save_plot(filename, tf, initial=False): + return import matplotlib.pyplot as plt plt.figure(figsize=(3, 3)) plt.axis('equal') diff --git a/topfarm/cost_models/fuga/Colonel b/topfarm/cost_models/fuga/Colonel index 0f0015c52e0a30dbef8d2674df8dd69b1ee521e3..63f215a900395ad7d8880d7783e57c0835e45c9b 160000 --- a/topfarm/cost_models/fuga/Colonel +++ b/topfarm/cost_models/fuga/Colonel @@ -1 +1 @@ -Subproject commit 0f0015c52e0a30dbef8d2674df8dd69b1ee521e3 +Subproject commit 63f215a900395ad7d8880d7783e57c0835e45c9b diff --git a/topfarm/cost_models/fuga/py_fuga.py b/topfarm/cost_models/fuga/py_fuga.py index 83bb90e58d3f2cb9a874b285bcbe1f68469cf6cf..a026b8ff3b986aec18776c17e014f67773a29c0e 100644 --- a/topfarm/cost_models/fuga/py_fuga.py +++ b/topfarm/cost_models/fuga/py_fuga.py @@ -107,7 +107,7 @@ class PyFuga(object): if turbine_positions is not None: self.move_turbines(turbine_positions[:,0], turbine_positions[:,1]) - n_wt = turbine_positions.shape[0] + n_wt = self.get_no_tubines() dAEPdxyz = np.zeros(n_wt), np.zeros(n_wt), np.zeros(n_wt) dAEPdxyz_ctype = [dAEP.ctypes for dAEP in dAEPdxyz] self.lib.GetAEPGradients(*[dAEP_ctype.data_as(c_double_p) for dAEP_ctype in dAEPdxyz_ctype])