From 0ec822087783205b6887d596c57329784316568e Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Mon, 22 Apr 2024 12:31:11 -0500 Subject: [PATCH 1/4] [BUGFIX] Update CubatureGrid for 4-dimensional data structures (#881) * Fix the grid resolution validator * Update cubature grid for 4d data structures --- floris/core/grid.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/floris/core/grid.py b/floris/core/grid.py index 9076e01e2..b20ca25ce 100644 --- a/floris/core/grid.py +++ b/floris/core/grid.py @@ -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 @@ -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): """ @@ -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}." ) From 95f33d1c00e5e1a92f5f77b5e600c7554b8e2370 Mon Sep 17 00:00:00 2001 From: misi9170 <39596329+misi9170@users.noreply.github.com> Date: Wed, 24 Apr 2024 13:28:14 -0400 Subject: [PATCH 2/4] Remove extra dimension in indexing hub_heights. (#890) --- floris/core/farm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/floris/core/farm.py b/floris/core/farm.py index 6ab28d2a0..58b29637b 100644 --- a/floris/core/farm.py +++ b/floris/core/farm.py @@ -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] ) ]) From f92167416155be3e4161ca2b4d58d31d1fb4936f Mon Sep 17 00:00:00 2001 From: misi9170 Date: Wed, 24 Apr 2024 13:16:47 -0600 Subject: [PATCH 3/4] Update version to v4.0.1 --- floris/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/floris/version.py b/floris/version.py index b8626c4cf..1454f6ed4 100644 --- a/floris/version.py +++ b/floris/version.py @@ -1 +1 @@ -4 +4.0.1 From 96a52fcb965d2ffc0d3256972fc749d87c9eecf3 Mon Sep 17 00:00:00 2001 From: misi9170 Date: Wed, 24 Apr 2024 14:07:29 -0600 Subject: [PATCH 4/4] Update version to v4.0.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea6d8313e..7d26cf1bd 100644 --- a/README.md +++ b/README.md @@ -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