Skip to content

Commit

Permalink
Merge pull request #891 from NREL/develop
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
misi9170 and rafmudaf committed Apr 24, 2024
2 parents 8bbe62d + 96a52fc commit 6181d78
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -3,7 +3,7 @@
FLORIS is a controls-focused wind farm simulation software incorporating
steady-state engineering wake models into a performance-focused Python
framework. It has been in active development at NREL since 2013 and the latest
release is [FLORIS v4.0](https://github.com/NREL/floris/releases/latest).
release is [FLORIS v4.0.1](https://github.com/NREL/floris/releases/latest).
Online documentation is available at https://nrel.github.io/floris.

The software is in active development and engagement with the development team
Expand Down
2 changes: 1 addition & 1 deletion floris/core/farm.py
Expand Up @@ -465,7 +465,7 @@ def coordinates(self):
np.array([x, y, z]) for x, y, z in zip(
self.layout_x,
self.layout_y,
self.hub_heights if len(self.hub_heights.shape) == 1 else self.hub_heights[0,0]
self.hub_heights if len(self.hub_heights.shape) == 1 else self.hub_heights[0]
)
])

Expand Down
29 changes: 16 additions & 13 deletions floris/core/grid.py
Expand Up @@ -317,21 +317,28 @@ def set_grid(self) -> None:
),
dtype=floris_float_type
)
_x = x[:, :, :, None, None] * template_grid
_y = y[:, :, :, None, None] * template_grid
_z = z[:, :, :, None, None] * template_grid
_x = x[:, :, None, None] * template_grid
_y = y[:, :, None, None] * template_grid
_z = z[:, :, None, None] * template_grid

n_coordinates = len(yv)
yv = np.broadcast_to(yv, (self.n_findex, self.n_turbines, n_coordinates))
yv = np.expand_dims(yv, axis=-1)
zv = np.broadcast_to(zv, (self.n_findex, self.n_turbines, n_coordinates))
zv = np.expand_dims(zv, axis=-1)

for ti in range(self.n_turbines):
_y[:, :, ti, :, :] += yv[None, None, :, None]*self.turbine_diameters[ti] / 2.0
_z[:, :, ti, :, :] += zv[None, None, :, None]*self.turbine_diameters[ti] / 2.0
_y[:, ti, :, :] += yv[:, ti] * self.turbine_diameters[ti] / 2.0
_z[:, ti, :, :] += zv[:, ti] * self.turbine_diameters[ti] / 2.0

# Sort the turbines at each wind direction

# Get the sorted indices for the x coordinates. These are the indices
# to sort the turbines from upstream to downstream for all wind directions.
# Also, store the indices to sort them back for when the calculation finishes.
self.sorted_indices = _x.argsort(axis=2)
self.sorted_coord_indices = x.argsort(axis=2)
self.unsorted_indices = self.sorted_indices.argsort(axis=2)
self.sorted_indices = _x.argsort(axis=1)
self.sorted_coord_indices = x.argsort(axis=1)
self.unsorted_indices = self.sorted_indices.argsort(axis=1)

# Put the turbine coordinates into the final arrays in their sorted order
# These are the coordinates that should be used within the internal calculations
Expand All @@ -340,10 +347,6 @@ def set_grid(self) -> None:
self.y_sorted = np.take_along_axis(_y, self.sorted_indices, axis=1)
self.z_sorted = np.take_along_axis(_z, self.sorted_indices, axis=1)

self.x = np.take_along_axis(self.x_sorted, self.unsorted_indices, axis=1)
self.y = np.take_along_axis(self.y_sorted, self.unsorted_indices, axis=1)
self.z = np.take_along_axis(self.z_sorted, self.unsorted_indices, axis=1)

@classmethod
def get_cubature_coefficients(cls, N: int):
"""
Expand All @@ -359,7 +362,7 @@ def get_cubature_coefficients(cls, N: int):
integration coefficients, "r", "t", "q", "A" and "B".
"""

if N < 1 and N < 10:
if N < 1 or N > 10:
raise ValueError(
f"Order of cubature integration must be between '1' and '10', given {N}."
)
Expand Down
2 changes: 1 addition & 1 deletion floris/version.py
@@ -1 +1 @@
4
4.0.1

0 comments on commit 6181d78

Please sign in to comment.