From a1c2134a51144ec7891af07ca28967415ba96231 Mon Sep 17 00:00:00 2001 From: misi9170 <39596329+misi9170@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:00:15 -0400 Subject: [PATCH] Bugfix for rotor_diameters; error in width of grid; make sure n_turbines_max is of type int. (#984) --- .../layout_optimization/layout_optimization_gridded.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/floris/optimization/layout_optimization/layout_optimization_gridded.py b/floris/optimization/layout_optimization/layout_optimization_gridded.py index 76a85c6db..f730c2287 100644 --- a/floris/optimization/layout_optimization/layout_optimization_gridded.py +++ b/floris/optimization/layout_optimization/layout_optimization_gridded.py @@ -65,7 +65,7 @@ def __init__( if min_dist_D is not None and min_dist is None: if min_dist_D < 0: # Default to 5D min_dist_D = 5.0 - min_dist = min_dist_D * fmodel.core.farm.rotor_diameters[0] + min_dist = min_dist_D * fmodel.core.farm.rotor_diameters.flat[0] if len(np.unique(fmodel.core.farm.rotor_diameters)) > 1: self.logger.warning(( "Found multiple turbine diameters. Using diameter of first turbine to set" @@ -83,7 +83,7 @@ def __init__( if translation_step_D is not None and translation_step is None: if translation_step_D < 0: # Default to 1D translation_step_D = 1.0 - translation_step = translation_step_D * fmodel.core.farm.rotor_diameters[0] + translation_step = translation_step_D * fmodel.core.farm.rotor_diameters.flat[0] if len(np.unique(fmodel.core.farm.rotor_diameters)) > 1: self.logger.warning(( "Found multiple turbine diameters. Using diameter of first turbine to set" @@ -107,7 +107,7 @@ def __init__( # Create the default grid # use min_dist, hexagonal packing, and boundaries to create a grid. - d = 1.1 * np.sqrt((self.xmax**2 - self.xmin**2) + (self.ymax**2 - self.ymin**2)) + d = 1.1 * np.sqrt((self.xmax - self.xmin)**2 + (self.ymax - self.ymin)**2) grid_1D = np.arange(0, d+min_dist, min_dist) if hexagonal_packing: x_locs = np.tile(grid_1D.reshape(1,-1), (len(grid_1D), 1)) @@ -196,7 +196,7 @@ def optimize(self): x, y in zip(x_opt_all, y_opt_all)] # Save best layout, along with the number of turbines in bounds, and return - self.n_turbines_max = turbines_in_bounds[idx_max] + self.n_turbines_max = round(turbines_in_bounds[idx_max]) self.x_opt = x_opt_all[mask_in_bounds] self.y_opt = y_opt_all[mask_in_bounds] return self.n_turbines_max, self.x_opt, self.y_opt