From 8a2bdd0318dd60b14fb3053cf92e93c35aa56007 Mon Sep 17 00:00:00 2001 From: misi9170 <39596329+misi9170@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:03:10 -0400 Subject: [PATCH] Add flow visualization to wake steering example (#1006) * Visualize flows under yaw misalignment * isort fix. --- .../001_opt_yaw_single_ws.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/examples_control_optimization/001_opt_yaw_single_ws.py b/examples/examples_control_optimization/001_opt_yaw_single_ws.py index 533347a78..32fc42621 100644 --- a/examples/examples_control_optimization/001_opt_yaw_single_ws.py +++ b/examples/examples_control_optimization/001_opt_yaw_single_ws.py @@ -8,6 +8,8 @@ import matplotlib.pyplot as plt import numpy as np +import floris.flow_visualization as flowviz +import floris.layout_visualization as layoutviz from floris import FlorisModel, TimeSeries from floris.optimization.yaw_optimization.yaw_optimizer_sr import YawOptimizationSR @@ -63,4 +65,27 @@ ax.legend() ax.grid(True) +# Visualize results for a single wind direction (270 deg) and wind speed (8 m/s) +fig, axarr = plt.subplots(2, 1, figsize=(10, 5), sharex=False) +ax = axarr[0] # Baseline aligned operation +fmodel.reset_operation() +fmodel.set(wind_directions=[270.0], wind_speeds=[8.0], turbulence_intensities=[0.06]) +fmodel.run() +horizontal_plane = fmodel.calculate_horizontal_plane(height=90.0) +flowviz.visualize_cut_plane(horizontal_plane, ax=ax) +layoutviz.plot_turbine_rotors(fmodel, ax=ax) +ax.set_title("Turbines aligned") + +ax = axarr[1] # Optimized yaw angles +optimal_yaw_angles = ( + df_opt[(df_opt["wind_direction"] == 270.0) & (df_opt["wind_speed"] == 8.0)] + .yaw_angles_opt.values[0] +).reshape(1,-1) +fmodel.set(yaw_angles=optimal_yaw_angles) +fmodel.run() +horizontal_plane = fmodel.calculate_horizontal_plane(height=90.0) +flowviz.visualize_cut_plane(horizontal_plane, ax=ax) +layoutviz.plot_turbine_rotors(fmodel, ax=ax, yaw_angles=optimal_yaw_angles) +ax.set_title("Optimized yaw angles") + plt.show()