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

[BUGFIX] Incorrect indexing to hub heights in Farm.coordinates() #890

Merged
merged 1 commit into from Apr 24, 2024

Conversation

misi9170
Copy link
Collaborator

@misi9170 misi9170 commented Apr 24, 2024

#846 introduced a bugfix to the Farm.coordinates() method, which was released and runs as expected in FLORIS v3.6. However, when develop was merged back into the v4 branch in preparation for the release of FLORIS v4.0, this line was missed in reducing from 5D to 4D data structures.

This PR fixes this issue by simply removing the now-redundant dimension in accessing hub_heights.

The following code demonstrates the error that is raised:

from floris import FlorisModel

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

# Changing the wind farm layout uses FLORIS' set method to a two-turbine layout
fmodel.set(layout_x=[0, 500.0], layout_y=[0.0, 0.0])

# Runs correctly
print(fmodel.get_turbine_layout())
print(fmodel.get_turbine_layout(True))

fmodel.run()

# Fails before the bugfix
print(fmodel.get_turbine_layout())
print(fmodel.get_turbine_layout(True))

With the bugfix, this produces

(array([  0., 500.]), array([0., 0.]))
(array([  0., 500.]), array([0., 0.]), array([90., 90.]))
(array([  0., 500.]), array([0., 0.]))
(array([  0., 500.]), array([0., 0.]), array([90., 90.]))

as expected. Prior to the bug fix (on the develop branch), the output is:

(array([  0., 500.]), array([0., 0.]))
(array([  0., 500.]), array([0., 0.]), array([90., 90.]))
Traceback (most recent call last):
  File "/Users/msinner/floris3/examples/dis887.py", line 18, in <module>
    print(fmodel.get_turbine_layout())
  File "/Users/msinner/floris3/floris/floris_model.py", line 1511, in get_turbine_layout
    xcoords, ycoords, zcoords = self.core.farm.coordinates.T
  File "/Users/msinner/floris3/floris/core/farm.py", line 465, in coordinates
    np.array([x, y, z]) for x, y, z in zip(
TypeError: 'numpy.float64' object is not iterable

Thank you to @AJP-47 for identifying this bug in #887, and to @rafmudaf for helping track it down.

@misi9170 misi9170 requested a review from rafmudaf April 24, 2024 16:49
@misi9170 misi9170 added the bug Something isn't working label Apr 24, 2024
@misi9170 misi9170 merged commit 95f33d1 into NREL:develop Apr 24, 2024
8 checks passed
@misi9170 misi9170 deleted the bugfix/hh-shape branch April 24, 2024 17:28
@misi9170 misi9170 mentioned this pull request Apr 24, 2024
misi9170 added a commit that referenced this pull request Apr 24, 2024
* [BUGFIX] Update CubatureGrid for 4-dimensional data structures (#881)

* Fix the grid resolution validator

* Update cubature grid for 4d data structures

* Remove extra dimension in indexing hub_heights. (#890)

* Update version to v4.0.1

* Update version to v4.0.1

---------

Co-authored-by: Rafael M Mudafort <rafmudaf@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants