Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing simulation yaw angles in planar calculations instead of switching to zero yaw angles #449

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

pjireland
Copy link
Contributor

Feature or improvement description
calculate_horizontal_plane, calculate_cross_plane, and calculate_y_plane previously used zero yaw angles if called with yaw_angles=None. This PR changes the behavior to use the existing yaw angles from self.floris.farm.yaw_angles instead.

Related issue, if one exists
#448

Impacted areas of the software
floris.tools.floris_interface.py

Test results, if applicable

Example visualization before change:
image

Example visualization after change:
image

Unit test results:

$ pytest
================================================================================================ test session starts =================================================================================================
platform win32 -- Python 3.9.12, pytest-7.1.2, pluggy-1.0.0
rootdir: C:\Users\pireland\floris, configfile: pyproject.toml, testpaths: tests
plugins: anyio-3.6.1, dash-2.3.1, cov-3.0.0, env-0.6.2, forked-1.4.0, timeout-2.1.0, xdist-2.5.0, xprocess-0.18.1
collected 99 items

tests\base_test.py ..                                                                                                                                                                                           [  2%] 
tests\farm_unit_test.py ..                                                                                                                                                                                      [  4%] 
tests\floris_interface_test.py ................................                                                                                                                                                 [ 36%]
tests\floris_unit_test.py ....                                                                                                                                                                                  [ 40%]
tests\flow_field_unit_test.py ....                                                                                                                                                                              [ 44%] 
tests\grid_unit_test.py ...                                                                                                                                                                                     [ 47%]
tests\turbine_unit_test.py ..........                                                                                                                                                                           [ 57%]
tests\type_dec_unit_test.py ....                                                                                                                                                                                [ 61%]
tests\utilities_unit_test.py .......                                                                                                                                                                            [ 68%]
tests\vec3_unit_test.py .......                                                                                                                                                                                 [ 75%]
tests\reg_tests\cumulative_curl_regression_test.py ......                                                                                                                                                       [ 81%]
tests\reg_tests\gauss_regression_test.py .......                                                                                                                                                                [ 88%]
tests\reg_tests\jensen_jimenez_regression_test.py ....                                                                                                                                                          [ 92%]
tests\reg_tests\none_regression_test.py ....                                                                                                                                                                    [ 96%]
tests\reg_tests\turbopark_regression_test.py ...                                                                                                                                                                [100%]

================================================================================================== warnings summary ================================================================================================== 
..\Anaconda3\envs\wedev-new-floris\lib\site-packages\numexpr\expressions.py:21
..\Anaconda3\envs\wedev-new-floris\lib\site-packages\numexpr\expressions.py:21
  C:\Users\pireland\Anaconda3\envs\wedev-new-floris\lib\site-packages\numexpr\expressions.py:21: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_forbids_neg_powint = LooseVersion(numpy.__version__) >= LooseVersion('1.12.0b1')

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================================================== 99 passed, 2 warnings in 3.87s ===========================================================================================

@pjireland
Copy link
Contributor Author

This change is causing an error in example 00:

Traceback (most recent call last):
     x       y
  File "/home/runner/work/floris/floris/examples/00_getting_started.py", line 290, in <module>
    horizontal_plane = fi.calculate_horizontal_plane( wd=[wind_directions[0]], height=90.0 )
  File "/home/runner/work/floris/floris/floris/tools/floris_interface.py", line 366, in calculate_horizontal_plane
    self.floris.solve_for_viz()
  File "/home/runner/work/floris/floris/floris/simulation/floris.py", line 194, in solve_for_viz
    full_flow_sequential_solver(self.farm, self.flow_field, self.grid, self.wake)
  File "/home/runner/work/floris/floris/floris/simulation/solver.py", line 242, in full_flow_sequential_solver
    sequential_solver(turbine_grid_farm, turbine_grid_flow_field, turbine_grid, model_manager)
  File "/home/runner/work/floris/floris/floris/simulation/solver.py", line 133, in sequential_solver
    v_wake, w_wake = calculate_transverse_velocity(
  File "/home/runner/work/floris/floris/floris/simulation/wake_deflection/gauss.py", line 465, in calculate_transverse_velocity
    V[delta_x < 0.0] = 0.0  # Subtract by 1 to avoid numerical issues on rotation
IndexError: boolean index did not match indexed array along dimension 0; dimension is 2 but corresponding boolean dimension is 1
   0.0,    0.0
 630.0,    0.0
1260.0,    0.0
     x       y
   0.0,    0.0
   0.0,  400.0
 800.0,    0.0
 800.0,  400.0
Dimensions of grid x-components
(2, 2, 4, 3, 3)

I'm not sure the best way to resolve this (whether it is to fix the test or the code), but will mark as a draft to indicate this is not ready to be merged.

@pjireland pjireland marked this pull request as draft June 22, 2022 21:05
@rafmudaf rafmudaf added enhancement An improvement of an existing feature floris.tools labels Feb 1, 2023
@rafmudaf
Copy link
Collaborator

rafmudaf commented Feb 1, 2023

Thoughts from discussion:

  • Since yaw angles are not retained in subsequent calculations (calculate_wake), it is inconsistent to retain yaw angles between calculations in this case.
  • Is it feasible to represent yaw angles in their own data structure and attach to FlorisInterface?
    • Tools to extract a setting from the full set of wind speed and wind directions
  • Add a flag to use yaw angles for the visualization routines?
  • Check if atmospheric condition are size 1, use the yaw angles already set
  • Include in considerations for floris.tools design

@Bartdoekemeijer
Copy link
Collaborator

Bartdoekemeijer commented Feb 3, 2023

Interesting thoughts @rafmudaf. How about assigning the turbine yaw angles in the .yaml file and updating them with reinitialize(...)? I can see some benefits here:

  • Yaw angles are consistent throughout FlorisInterface and over all operations
  • Yaw angles have a clear place where they are assigned. If unassigned in the .yaml, initialize as zeros.
  • Enforces consistency and transparency. E.g., if a user is reinitializing the ambient conditions with already a set of nonzero yaw angles assigned in FlorisInterface, then raise an error and force user to assign what yaw angles should become.
  • Allows users to directly share and save .yaml files for the yaw-optimized scenario with the FLORIS information and yaw angle schedule in a single file, rather than separately sharing .csv files with optimal yaw angles.

Cons are that this can be API breaking and increases the size of .yaml files.

@rafmudaf
Copy link
Collaborator

rafmudaf commented Jul 3, 2023

@pjireland I rebased your commit onto the develop branch. If you need to update this on your local repo, you can fetch, stash any changes, and then hard-reset to your fork's fix-448 branch. Let me know if any of that is not clear and I can help you get caught up. Note that a hard-reset will drop any unsaved changes or commits on your current branch that are different from the remote. In other words, you could lose work so double check your workflow.
My apologies for letting this PR sit for so long. We are finally dealing with the question of how to handle yaw angles, so we'll consider your suggestion and others.

@pjireland
Copy link
Contributor Author

@pjireland I rebased your commit onto the develop branch. If you need to update this on your local repo, you can fetch, stash any changes, and then hard-reset to your fork's fix-448 branch. Let me know if any of that is not clear and I can help you get caught up. Note that a hard-reset will drop any unsaved changes or commits on your current branch that are different from the remote. In other words, you could lose work so double check your workflow. My apologies for letting this PR sit for so long. We are finally dealing with the question of how to handle yaw angles, so we'll consider your suggestion and others.

Thanks for the update, @rafmudaf!

@rafmudaf rafmudaf added this to the v4.0 milestone Nov 16, 2023
@rafmudaf rafmudaf self-assigned this Nov 29, 2023
@rafmudaf rafmudaf modified the milestones: v4.0, v4.1 Jan 30, 2024
@misi9170
Copy link
Collaborator

misi9170 commented Jul 18, 2024

Hi @pjireland ,

I'm just looking back through older pull requests and I believe that the desired functionality is now included in Floris v4. For example, running

import matplotlib.pyplot as plt

from floris import FlorisModel
from floris import flow_visualization as flowviz

fmodel = FlorisModel("inputs/gch.yaml")

fmodel.set(
    wind_directions=[270.0],
    wind_speeds=[8.0],
    turbulence_intensities=[0.06],
    layout_x=[0, 1000.0],
    layout_y=[0.0, 0.0],
    yaw_angles=[[20.0, 0.0]],
)
fmodel.run() # Not needed, but shows that yaw_angles are retained even after run()
plane = fmodel.calculate_horizontal_plane(height=90)
flowviz.visualize_cut_plane(plane)

plt.show()

produces
image

In fact, with the updates in v4, the yaw_angles must be set prior to the calculate_horizontal_plane() call; calculate_horizontal_plane() no longer accepts yaw_angles as an argument.

If this looks good to you, I think we can close this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature floris.tools
Projects
Status: Future Steps
Development

Successfully merging this pull request may close these issues.

4 participants