Skip to content

Commit

Permalink
Bugfix: Moving effective yaw definition and properties to Gauss defle…
Browse files Browse the repository at this point in the history
…ction model (#190)

* Moves effective yaw definition & properties to gauss deflection model
  • Loading branch information
bayc committed Mar 11, 2021
1 parent 98ce54a commit 22d220c
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 193 deletions.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ Citation
If FLORIS played a role in your research, please cite it. This software can be
cited as:

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

For LaTeX users:

.. code-block:: latex

@misc{FLORIS_2020,
author = {NREL},
title = {{FLORIS. Version 2.2.4},
year = {2020},
title = {{FLORIS. Version 2.2.5},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
url = {https://github.com/NREL/floris}
Expand Down Expand Up @@ -125,7 +125,7 @@ display information:
License
=======

Copyright 2020 NREL
Copyright 2021 NREL

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@

# General information about the project.
project = "FLORIS"
copyright = "2020, NREL"
copyright = "2021, NREL"
author = "NREL"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
version = "2.2.4"
release = "2.2.4"
version = "2.2.5"
release = "2.2.5"

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

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

For LaTeX users:

.. code-block:: latex

@misc{FLORIS_2020,
@misc{FLORIS_2021,
author = {NREL},
title = {{FLORIS. Version 2.2.4}},
year = {2020},
title = {{FLORIS. Version 2.2.5}},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
url = {https://github.com/NREL/floris}
Expand All @@ -88,7 +88,7 @@ For LaTeX users:
License
=======

Copyright 2020 NREL
Copyright 2021 NREL

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
180 changes: 0 additions & 180 deletions floris/simulation/wake_deflection/base_velocity_deflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,183 +82,3 @@ def _get_model_dict(self, default_dict):
raise KeyError(err_msg)
return_dict = user_dict
return return_dict

def calculate_effective_yaw_angle(
self, x_locations, y_locations, z_locations, turbine, coord, flow_field
):
"""
This method determines the effective yaw angle to be used when
secondary steering is enabled. For more details on how the effective
yaw angle is calculated, see :cite:`bvd-King2019Controls`.
Args:
x_locations (np.array): Streamwise locations in wake.
y_locations (np.array): Spanwise locations in wake.
z_locations (np.array): Vertical locations in wake.
turbine (:py:class:`floris.simulation.turbine.Turbine`):
Turbine object.
coord (:py:obj:`floris.simulation.turbine_map.TurbineMap.coords`):
Spatial coordinates of wind turbine.
flow_field (:py:class:`floris.simulation.flow_field.FlowField`):
Flow field object.
Raises:
ValueError: It appears that 'use_secondary_steering' is set
to True and 'calculate_VW_velocities' is set to False.
This configuration is not valid. Please set
'use_secondary_steering' to True if you wish to use
yaw-added recovery.
Returns:
float: The turbine yaw angle, including any effective yaw if
secondary steering is enabled.
"""
if self.use_secondary_steering:
if not flow_field.wake.velocity_model.calculate_VW_velocities:
err_msg = (
"It appears that 'use_secondary_steering' is set "
+ "to True and 'calculate_VW_velocities' is set to False. "
+ "This configuration is not valid. Please set "
+ "'use_secondary_steering' to True if you wish to use "
+ "yaw-added recovery."
)
self.logger.error(err_msg, stack_info=True)
raise ValueError(err_msg)
# turbine parameters
Ct = turbine.Ct
D = turbine.rotor_diameter
HH = turbine.hub_height
aI = turbine.aI
TSR = turbine.tsr
V = flow_field.v
Uinf = np.mean(flow_field.wind_map.grid_wind_speed)

eps = self.eps_gain * D # Use set value
idx = np.where(
(np.abs(x_locations - coord.x1) < D / 4)
& (np.abs(y_locations - coord.x2) < D / 2)
)

yLocs = y_locations[idx] + 0.01 - coord.x2

# location of top vortex
zT = z_locations[idx] + 0.01 - (HH + D / 2)
rT = yLocs ** 2 + zT ** 2

# location of bottom vortex
zB = z_locations[idx] + 0.01 - (HH - D / 2)
rB = yLocs ** 2 + zB ** 2

# wake rotation vortex
zC = z_locations[idx] + 0.01 - (HH)
rC = yLocs ** 2 + zC ** 2

# find wake deflection from CRV
test_gamma = np.linspace(-45, 45, 91)
avg_V = np.mean(V[idx])
target_yaw_ix = None

# what yaw angle would have produced that same average spanwise velocity
yaw = test_gamma # [i]

vel_top = (
(HH + D / 2) / flow_field.specified_wind_height
) ** flow_field.wind_shear
vel_bottom = (
(HH - D / 2) / flow_field.specified_wind_height
) ** flow_field.wind_shear
Gamma_top = (np.pi / 8) * D * vel_top * Uinf * Ct * sind(yaw) * cosd(yaw)
Gamma_bottom = (
-(np.pi / 8) * D * vel_bottom * Uinf * Ct * sind(yaw) * cosd(yaw)
)
Gamma_wake_rotation = (
0.25 * 2 * np.pi * D * (aI - aI ** 2) * turbine.average_velocity / TSR
)

Veff = (
np.divide(np.einsum("i,j", Gamma_top, zT), (2 * np.pi * rT))
* (1 - np.exp(-rT / (eps ** 2)))
+ np.einsum("i,j", Gamma_bottom, zB)
/ (2 * np.pi * rB)
* (1 - np.exp(-rB / (eps ** 2)))
+ (zC * Gamma_wake_rotation)
/ (2 * np.pi * rC)
* (1 - np.exp(-rC / (eps ** 2)))
)

tmp = avg_V - np.mean(Veff, axis=1)
target_yaw_ix = np.argmin(np.abs(tmp))

if target_yaw_ix is not None:
yaw_effective = test_gamma[target_yaw_ix]
else:
err_msg = "No effective yaw angle is found. Set to 0."
self.logger.warning(err_msg, stack_info=True)
yaw_effective = 0.0

return yaw_effective + turbine.yaw_angle

else:
return turbine.yaw_angle

@property
def use_secondary_steering(self):
"""
Flag to use secondary steering on the wake deflection using methods
developed in :cite:`bvd-King2019Controls`.
**Note:** This is a virtual property used to "get" or "set" a value.
Args:
value (bool): Value to set.
Returns:
float: Value currently set.
Raises:
ValueError: Invalid value.
"""
return self._use_secondary_steering

@use_secondary_steering.setter
def use_secondary_steering(self, value):
if type(value) is not bool:
err_msg = (
"Value of use_secondary_steering must be type "
+ "bool; {} given.".format(type(value))
)
self.logger.error(err_msg, stack_info=True)
raise ValueError(err_msg)
self._use_secondary_steering = value

@property
def eps_gain(self):
"""
Tuning value for yaw added recovery on the wake velocity using methods
developed in :cite:`bvd-King2019Controls`.
TODO: Don't believe this needs to be defined here. Already defined in
gaussian_model_model.py. Verify that it can be removed.
**Note:** This is a virtual property used to "get" or "set" a value.
Args:
value (bool): Value to set.
Returns:
float: Value currently set.
Raises:
ValueError: Invalid value.
"""
return self._eps_gain

@eps_gain.setter
def eps_gain(self, value):
if type(value) is not float:
err_msg = "Value of eps_gain must be type " + "float; {} given.".format(
type(value)
)
self.logger.error(err_msg, stack_info=True)
raise ValueError(err_msg)
self._eps_gain = value
Loading

0 comments on commit 22d220c

Please sign in to comment.