Skip to content

Commit

Permalink
Collect all layout visualization tools in FLORIS (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulf81 committed Mar 6, 2024
1 parent 57ec83c commit 8ac93bf
Show file tree
Hide file tree
Showing 19 changed files with 781 additions and 639 deletions.
23 changes: 14 additions & 9 deletions examples/02_visualizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import matplotlib.pyplot as plt
import numpy as np

import floris.tools.visualization as wakeviz
import floris.tools.flow_visualization as flowviz
from floris.tools import FlorisInterface


Expand Down Expand Up @@ -60,19 +60,19 @@
# Create the plots
fig, ax_list = plt.subplots(3, 1, figsize=(10, 8))
ax_list = ax_list.flatten()
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
horizontal_plane,
ax=ax_list[0],
label_contours=True,
title="Horizontal"
)
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
y_plane,
ax=ax_list[1],
label_contours=True,
title="Streamwise profile"
)
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
cross_plane,
ax=ax_list[2],
label_contours=True,
Expand All @@ -81,15 +81,15 @@

# Some wake models may not yet have a visualization method included, for these cases can use
# a slower version which scans a turbine model to produce the horizontal flow
horizontal_plane_scan_turbine = wakeviz.calculate_horizontal_plane_with_turbines(
horizontal_plane_scan_turbine = flowviz.calculate_horizontal_plane_with_turbines(
fi,
x_resolution=20,
y_resolution=10,
yaw_angles=np.array([[25.,0.,0.]]),
)

fig, ax = plt.subplots()
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
horizontal_plane_scan_turbine,
ax=ax,
label_contours=True,
Expand All @@ -104,7 +104,7 @@
fi.run()

# Plot the values at each rotor
fig, axes, _ , _ = wakeviz.plot_rotor_values(
fig, axes, _ , _ = flowviz.plot_rotor_values(
fi.floris.flow_field.u,
findex=0,
n_rows=1,
Expand Down Expand Up @@ -132,7 +132,7 @@
fi.run()

# Plot the values at each rotor
fig, axes, _ , _ = wakeviz.plot_rotor_values(
fig, axes, _ , _ = flowviz.plot_rotor_values(
fi.floris.flow_field.u,
findex=0,
n_rows=1,
Expand All @@ -141,4 +141,9 @@
)
fig.suptitle("Rotor Plane Visualization, 10x10 Resolution")

wakeviz.show_plots()
# Show plots
plt.show()

# Note if the user doesn't import matplotlib.pyplot as plt, the user can
# use the following to show the plots:
# flowviz.show()
23 changes: 12 additions & 11 deletions examples/03_making_adjustments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import matplotlib.pyplot as plt
import numpy as np

import floris.tools.visualization as wakeviz
import floris.tools.flow_visualization as flowviz
import floris.tools.layout_visualization as layoutviz
from floris.tools import FlorisInterface


Expand All @@ -25,7 +26,7 @@

# Plot a horizatonal slice of the initial configuration
horizontal_plane = fi.calculate_horizontal_plane(height=90.0)
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
horizontal_plane,
ax=axarr[0],
title="Initial setup",
Expand All @@ -35,7 +36,7 @@

# Change the wind speed
horizontal_plane = fi.calculate_horizontal_plane(ws=[7.0], height=90.0)
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
horizontal_plane,
ax=axarr[1],
title="Wind speed at 7 m/s",
Expand All @@ -47,7 +48,7 @@
# Change the wind shear, reset the wind speed, and plot a vertical slice
fi.set(wind_shear=0.2, wind_speeds=[8.0])
y_plane = fi.calculate_y_plane(crossstream_dist=0.0)
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
y_plane,
ax=axarr[2],
title="Wind shear at 0.2",
Expand All @@ -63,15 +64,15 @@
)
fi.set(layout_x=X.flatten(), layout_y=Y.flatten(), wind_directions=[270.0])
horizontal_plane = fi.calculate_horizontal_plane(height=90.0)
wakeviz.visualize_cut_plane(
flowviz.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])
layoutviz.plot_turbine_labels(fi, axarr[3],plotting_dict={'color':"w"})#, backgroundcolor="k")
layoutviz.plot_turbine_rotors(fi, axarr[3])

# Change the yaw angles and configure the plot differently
yaw_angles = np.zeros((1, N * N))
Expand All @@ -87,20 +88,20 @@
yaw_angles[:,7] = -30.0

horizontal_plane = fi.calculate_horizontal_plane(yaw_angles=yaw_angles, height=90.0)
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
horizontal_plane,
ax=axarr[4],
title="Yawesome art",
cmap="PuOr",
min_speed=MIN_WS,
max_speed=MAX_WS
)
wakeviz.plot_turbines_with_fi(fi, axarr[4], yaw_angles=yaw_angles, color="c")
layoutviz.plot_turbine_rotors(fi, axarr[4], yaw_angles=yaw_angles, color="c")


# Plot the cross-plane of the 3x3 configuration
cross_plane = fi.calculate_cross_plane(yaw_angles=yaw_angles, downstream_dist=610.0)
wakeviz.visualize_cut_plane(
flowviz.visualize_cut_plane(
cross_plane,
ax=axarr[5],
title="Cross section at 610 m",
Expand All @@ -110,4 +111,4 @@
axarr[5].invert_xaxis()


wakeviz.show_plots()
plt.show()
2 changes: 1 addition & 1 deletion examples/16_heterogeneous_inflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import matplotlib.pyplot as plt

from floris.tools import FlorisInterface
from floris.tools.visualization import visualize_cut_plane
from floris.tools.flow_visualization import visualize_cut_plane


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/16b_heterogeneity_multiple_ws_wd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.visualization import visualize_cut_plane
from floris.tools.flow_visualization import visualize_cut_plane


"""
Expand Down
10 changes: 5 additions & 5 deletions examples/17_multiple_turbine_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import matplotlib.pyplot as plt

import floris.tools.visualization as wakeviz
import floris.tools.flow_visualization as flowviz
from floris.tools import FlorisInterface


Expand All @@ -24,8 +24,8 @@
# Create the plots
fig, ax_list = plt.subplots(3, 1, figsize=(10, 8))
ax_list = ax_list.flatten()
wakeviz.visualize_cut_plane(horizontal_plane, ax=ax_list[0], title="Horizontal")
wakeviz.visualize_cut_plane(y_plane, ax=ax_list[1], title="Streamwise profile")
wakeviz.visualize_cut_plane(cross_plane, ax=ax_list[2], title="Spanwise profile")
flowviz.visualize_cut_plane(horizontal_plane, ax=ax_list[0], title="Horizontal")
flowviz.visualize_cut_plane(y_plane, ax=ax_list[1], title="Streamwise profile")
flowviz.visualize_cut_plane(cross_plane, ax=ax_list[2], title="Spanwise profile")

wakeviz.show_plots()
plt.show()
93 changes: 93 additions & 0 deletions examples/23_layout_visualizations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

import matplotlib.pyplot as plt
import numpy as np

import floris.tools.layout_visualization as layoutviz
from floris.tools import FlorisInterface
from floris.tools.flow_visualization import visualize_cut_plane


"""
This example shows a number of different ways to visualize a farm layout using FLORIS
"""

# Create the plotting objects using matplotlib
fig, axarr = plt.subplots(3, 3, figsize=(16, 10), sharex=False)
axarr = axarr.flatten()

MIN_WS = 1.0
MAX_WS = 8.0

# Initialize FLORIS with the given input file via FlorisInterface
fi = FlorisInterface("inputs/gch.yaml")

# Change to 5-turbine layout with a wind direction from northwest
fi.set(
layout_x=[0, 0, 1000, 1000, 1000], layout_y=[0, 500, 0, 500, 1000], wind_directions=[300]
)

# Plot 1: Visualize the flow
ax = axarr[0]
# Plot a horizatonal slice of the initial configuration
horizontal_plane = fi.calculate_horizontal_plane(height=90.0)
visualize_cut_plane(
horizontal_plane,
ax=ax,
min_speed=MIN_WS,
max_speed=MAX_WS,
)
# Plot the turbine points, setting the color to white
layoutviz.plot_turbine_points(fi, ax=ax, plotting_dict={"color": "w"})
ax.set_title('Flow visualization and turbine points')

# Plot 2: Show a particular flow case
ax = axarr[1]
turbine_names = [f"T{i}" for i in [10, 11, 12, 13, 22]]
layoutviz.plot_turbine_points(fi, ax=ax)
layoutviz.plot_turbine_labels(fi,
ax=ax,
turbine_names=turbine_names,
show_bbox=True,
bbox_dict={'facecolor':'r'})
ax.set_title("Show turbine names with a red bounding box")


# Plot 2: Show turbine rotors on flow
ax = axarr[2]
horizontal_plane = fi.calculate_horizontal_plane(height=90.0,
yaw_angles=np.array([[0., 30., 0., 0., 0.]]))
visualize_cut_plane(
horizontal_plane,
ax=ax,
min_speed=MIN_WS,
max_speed=MAX_WS
)
layoutviz.plot_turbine_rotors(fi,ax=ax,yaw_angles=np.array([[0., 30., 0., 0., 0.]]))
ax.set_title("Flow visualization with yawed turbine")

# Plot 3: Show the layout, including wake directions
ax = axarr[3]
layoutviz.plot_turbine_points(fi, ax=ax)
layoutviz.plot_turbine_labels(fi, ax=ax, turbine_names=turbine_names)
layoutviz.plot_waking_directions(fi, ax=ax)
ax.set_title("Show turbine names and wake direction")

# Plot 4: Plot a subset of the layout, and limit directions less than 7D
ax = axarr[4]
layoutviz.plot_turbine_points(fi, ax=ax, turbine_indices=[0,1,2,3])
layoutviz.plot_turbine_labels(fi, ax=ax, turbine_names=turbine_names, turbine_indices=[0,1,2,3])
layoutviz.plot_waking_directions(fi, ax=ax, turbine_indices=[0,1,2,3], limit_dist_D=7)
ax.set_title("Plot a subset and limit wake line distance")

# Plot with a shaded region
ax = axarr[5]
layoutviz.plot_turbine_points(fi, ax=ax)
layoutviz.shade_region(np.array([[0,0],[300,0],[300,1000],[0,700]]),ax=ax)
ax.set_title("Plot with a shaded region")

# Change hub heights and plot as a proxy for terrain
ax = axarr[6]
fi.floris.farm.hub_heights = np.array([110, 90, 100, 100, 95])
layoutviz.plot_farm_terrain(fi, ax=ax)

plt.show()
62 changes: 0 additions & 62 deletions examples/23_visualize_layout.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/24_floating_turbine_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.layout_functions import visualize_layout


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/25_tilt_driven_vertical_wake_deflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.visualization import visualize_cut_plane
from floris.tools.flow_visualization import visualize_cut_plane


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/26_empirical_gauss_velocity_deficit_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.visualization import plot_rotor_values, visualize_cut_plane
from floris.tools.flow_visualization import plot_rotor_values, visualize_cut_plane


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/27_empirical_gauss_deflection_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.visualization import plot_rotor_values, visualize_cut_plane
from floris.tools.flow_visualization import plot_rotor_values, visualize_cut_plane


"""
Expand Down
Loading

0 comments on commit 8ac93bf

Please sign in to comment.