Skip to content

Commit

Permalink
Rotate turbine lines and ID annotations with wind
Browse files Browse the repository at this point in the history
  • Loading branch information
rafmudaf committed Nov 14, 2022
1 parent a73eb46 commit 93cee31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions examples/03_making_adjustments.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
5.0 * fi.floris.farm.rotor_diameters[0][0][0] * np.arange(0, N, 1),
5.0 * fi.floris.farm.rotor_diameters[0][0][0] * np.arange(0, N, 1),
)
fi.reinitialize(layout_x=X.flatten(), layout_y=Y.flatten())
fi.reinitialize(layout_x=X.flatten(), layout_y=Y.flatten(), wind_directions=[360.0])
horizontal_plane = fi.calculate_horizontal_plane(height=90.0)
wakeviz.visualize_cut_plane(horizontal_plane, ax=axarr[3], title="3x3 Farm", min_speed=MIN_WS, max_speed=MAX_WS)
wakeviz.add_turbine_id_labels(fi, axarr[3], color="w", backgroundcolor="k")

wakeviz.plot_turbines_with_fi(fi, axarr[3])

# Change the yaw angles and configure the plot differently
yaw_angles = np.zeros((1, 1, N * N))
Expand Down
26 changes: 19 additions & 7 deletions floris/tools/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@
from matplotlib import rcParams

from floris.tools.floris_interface import FlorisInterface
from floris.utilities import rotate_coordinates_rel_west

def show_plots():
plt.show()

def plot_turbines(ax, layout_x, layout_y, yaw_angles, rotor_diameters, color=None, wind_direction=270.0):
def plot_turbines(
ax,
layout_x,
layout_y,
yaw_angles,
rotor_diameters,
color: str | None = None,
wind_direction: float = 270.0
):
"""
Plot wind plant layout from turbine locations.
Expand All @@ -39,13 +48,13 @@ def plot_turbines(ax, layout_x, layout_y, yaw_angles, rotor_diameters, color=Non
color (str): Pyplot color option to plot the turbines.
wind_direction (float): Wind direction (rotates farm)
"""

# Correct for the wind direction
yaw_angles = np.array(yaw_angles) # - wind_direction - 270

if color is None:
color = "k"
for x, y, yaw, d in zip(layout_x, layout_y, yaw_angles, rotor_diameters):

coordinates_array = np.array([[x, y, 0.0] for x, y in list(zip(layout_x, layout_y))])
layout_x, layout_y, _ = rotate_coordinates_rel_west(np.array([wind_direction]), coordinates_array)

for x, y, yaw, d in zip(layout_x[0,0], layout_y[0,0], yaw_angles, rotor_diameters):
R = d / 2.0
x_0 = x + np.sin(np.deg2rad(yaw)) * R
x_1 = x - np.sin(np.deg2rad(yaw)) * R
Expand Down Expand Up @@ -90,9 +99,12 @@ def add_turbine_id_labels(fi: FlorisInterface, ax: plt.Axes, **kwargs):
fi (FlorisInterface): Simulation object to get the layout and index information.
ax (plt.Axes): Axes object to add the labels.
"""
coordinates_array = np.array([[x, y, 0.0] for x, y in list(zip(fi.layout_x, fi.layout_y))])
wind_direction = fi.floris.flow_field.wind_directions[0]
layout_x, layout_y, _ = rotate_coordinates_rel_west(np.array([wind_direction]), coordinates_array)

for i in range(fi.floris.farm.n_turbines):
ax.annotate(i, (fi.layout_x[i], fi.layout_y[i]), xytext=(0,10), textcoords="offset points", **kwargs)
ax.annotate(i, (layout_x[0,0,i], layout_y[0,0,i]), xytext=(0,10), textcoords="offset points", **kwargs)


def line_contour_cut_plane(cut_plane, ax=None, levels=None, colors=None, **kwargs):
Expand Down

0 comments on commit 93cee31

Please sign in to comment.