Skip to content

Commit

Permalink
Plot lines in horizontal plane
Browse files Browse the repository at this point in the history
  • Loading branch information
rafmudaf committed Nov 21, 2023
1 parent 97bc2d2 commit 68fd463
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions examples/32_plot_velocity_deficit_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from floris.tools import FlorisInterface
from floris.tools.visualization import VelocityProfilesFigure

import floris.tools.visualization as wakeviz

"""
The first part of this example illustrates how to plot velocity deficit profiles at
Expand All @@ -37,16 +37,18 @@ def get_profiles(direction, resolution=100):
downstream_dists=downstream_dists,
resolution=resolution,
homogeneous_wind_speed=homogeneous_wind_speed,
wind_direction=wind_direction
)

if __name__ == '__main__':
D = 126.0 # Turbine diameter
hub_height = 90.0
fi = FlorisInterface("inputs/gch.yaml")
fi.reinitialize(layout_x=[0.0], layout_y=[0.0])
fi.reinitialize(layout_x=[0.0, 500, 1000], layout_y=[0.0, 0.0, 0.0])

downstream_dists = D * np.array([3, 5, 7])
homogeneous_wind_speed = 8.0
wind_direction = 310

# Below, `get_profiles('y')` returns three velocity deficit profiles. These are sampled along
# three corresponding lines that are all parallel to the y-axis (cross-stream direction).
Expand All @@ -55,6 +57,13 @@ def get_profiles(direction, resolution=100):
# same streamwise locations.
profiles = get_profiles('y') + get_profiles('z')

plane = fi.calculate_horizontal_plane(height=90, wd=[wind_direction])
ax = wakeviz.visualize_cut_plane(plane)
colors = ['r', 'g', 'b', 'c', 'm', 'y']
for i, prof in enumerate(profiles):
ax.plot(prof['x'], prof['y'], colors[i], label=str(i))
ax.legend()

# Initialize a VelocityProfilesFigure. The workflow is similar to a matplotlib Figure:
# Initialize it, plot data, and then customize it further if needed.
# The provided value of `layout` puts y-profiles on the top row of the figure and
Expand Down
2 changes: 2 additions & 0 deletions floris/simulation/floris.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ def solve_for_velocity_deficit_profiles(
for i in range(n_lines):
df = pd.DataFrame(
{
"x": x_rotated[i],
"y": y_rotated[i],
"x/D": x_relative_start[i]/ref_rotor_diameter,
"y/D": y_relative_start[i]/ref_rotor_diameter,
"z/D": z_relative_start[i]/ref_rotor_diameter,
Expand Down

0 comments on commit 68fd463

Please sign in to comment.