Skip to content

Commit

Permalink
Feature: Add y-normal cut planes
Browse files Browse the repository at this point in the history
* Handle ynormal cut plane

* Add example to show cutplane visuals

* Updating version number to 2.2.4

Co-authored-by: bayc <christopher.j.bay@gmail.com>
  • Loading branch information
paulf81 and bayc committed Jan 13, 2021
1 parent 9f3743c commit 98ce54a
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ Citation
If FLORIS played a role in your research, please cite it. This software can be
cited as:

FLORIS. Version 2.2.3 (2020). Available at https://github.com/NREL/floris.
FLORIS. Version 2.2.4 (2020). Available at https://github.com/NREL/floris.

For LaTeX users:

.. code-block:: latex

@misc{FLORIS_2020,
author = {NREL},
title = {{FLORIS. Version 2.2.3},
title = {{FLORIS. Version 2.2.4},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
version = "2.2.3"
release = "2.2.3"
version = "2.2.4"
release = "2.2.4"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ Citation
If FLORIS played a role in your research, please cite it. This software can be
cited as:

FLORIS. Version 2.2.3 (2020). Available at https://github.com/NREL/floris.
FLORIS. Version 2.2.4 (2020). Available at https://github.com/NREL/floris.

For LaTeX users:

.. code-block:: latex

@misc{FLORIS_2020,
author = {NREL},
title = {{FLORIS. Version 2.2.3}},
title = {{FLORIS. Version 2.2.4}},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
Expand Down
116 changes: 116 additions & 0 deletions examples/visualization/interactive_visual.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Copyright 2020 NREL

# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# See https://floris.readthedocs.io for documentation


# NOTE: This example requires an additional module, `streamlit`.
#
# TO USE THIS FROM COMMAND TYPE:
# streamlit run interactive_visual.py

import matplotlib.pyplot as plt

import streamlit as st
import floris.tools as wfct


# Fixed parameters
minSpeed = 4
maxSpeed = 8.0

# Options
wd = st.sidebar.slider("Wind Direction", 250, 290, 270, step=2)
yaw_1 = st.sidebar.slider("Yaw angle T1", -30, 30, 0, step=1)
x_loc = st.sidebar.slider("x normal plane intercept", 0, 3000, 500, step=10)
y_loc = st.sidebar.slider("y normal plane intercept", -100, 100, 0, step=5)


# Initialize the FLORIS interface fi
fi = wfct.floris_interface.FlorisInterface("../example_input.json")
fi.reinitialize_flow_field(
wind_direction=wd, layout_array=((0, 126 * 7, 126 * 14), (0, 0, 0))
)
fi.calculate_wake(yaw_angles=[yaw_1, 0, 0])

st.write("# Results with GCH")

# Horizontal plane
hor_plane = fi.get_hor_plane()
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(
hor_plane, ax=ax, minSpeed=minSpeed, maxSpeed=maxSpeed
)
ax.axhline(y_loc, color="w", ls="--", lw=1)
ax.axvline(x_loc, color="w", ls="--", lw=1)
st.write("## Horizontal Cut Plane")
st.write(fig)

# Cross (x-normal) plane
cross_plane = fi.get_cross_plane(x_loc=x_loc)
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(
cross_plane, ax=ax, minSpeed=minSpeed, maxSpeed=maxSpeed
)
st.write("## Cross (X-Normal) Cut Plane")
wfct.visualization.reverse_cut_plane_x_axis_in_plot(ax)
st.write(fig)

# Cross (y-normal) plane
cross_plane = fi.get_y_plane(y_loc=y_loc)
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(
cross_plane, ax=ax, minSpeed=minSpeed, maxSpeed=maxSpeed
)
st.write("## Cross (Y-Normal) Cut Plane")
st.write(fig)


# NO GCH RESULTS
st.write("# Results without GCH")
fi = wfct.floris_interface.FlorisInterface("../example_input.json")
fi.set_gch(False)
fi.reinitialize_flow_field(
wind_direction=wd, layout_array=((0, 126 * 7, 126 * 14), (0, 0, 0))
)
fi.calculate_wake(yaw_angles=[yaw_1, 0, 0])


# Horizontal plane
hor_plane = fi.get_hor_plane()
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(
hor_plane, ax=ax, minSpeed=minSpeed, maxSpeed=maxSpeed
)
ax.axhline(y_loc, color="w", ls="--", lw=1)
ax.axvline(x_loc, color="w", ls="--", lw=1)
st.write("## Horizontal Cut Plane")
st.write(fig)

# Cross (x-normal) plane
cross_plane = fi.get_cross_plane(x_loc=x_loc)
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(
cross_plane, ax=ax, minSpeed=minSpeed, maxSpeed=maxSpeed
)
st.write("## Cross (X-Normal) Cut Plane")
wfct.visualization.reverse_cut_plane_x_axis_in_plot(ax)
st.write(fig)

# Cross (y-normal) plane
cross_plane = fi.get_y_plane(y_loc=y_loc)
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(
cross_plane, ax=ax, minSpeed=minSpeed, maxSpeed=maxSpeed
)
st.write("## Cross (Y-Normal) Cut Plane")
st.write(fig)
13 changes: 13 additions & 0 deletions floris/tools/floris_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,17 @@ def get_plane_of_points(
0
].hub_height
x2_bounds = (10, hub_height * 2)
if normal_vector == "y": # Rules of thumb for cut plane plane
if x1_bounds is None:
coords = self.floris.farm.flow_field.turbine_map.coords
max_diameter = self.floris.farm.flow_field.max_diameter
x = [coord.x1 for coord in coords]
x1_bounds = (min(x) - 2 * max_diameter, max(x) + 10 * max_diameter)
if x2_bounds is None:
hub_height = self.floris.farm.flow_field.turbine_map.turbines[
0
].hub_height
x2_bounds = (10, hub_height * 2)

# Set up the points to test
x1_array = np.linspace(x1_bounds[0], x1_bounds[1], num=x1_resolution)
Expand All @@ -338,6 +349,8 @@ def get_plane_of_points(
points = np.row_stack((x1_array, x2_array, x3_array))
if normal_vector == "x":
points = np.row_stack((x3_array, x1_array, x2_array))
if normal_vector == "y":
points = np.row_stack((x1_array, x3_array, x2_array))

# Recalculate wake with these points
flow_field.calculate_wake(points=points)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
EMAIL = "rafael.mudafort@nrel.gov"
AUTHOR = "NREL National Wind Technology Center"
REQUIRES_PYTHON = ">=3.6.0"
VERSION = "2.2.3"
VERSION = "2.2.4"

# What packages are required for this module to be executed?
REQUIRED = [
Expand Down

0 comments on commit 98ce54a

Please sign in to comment.