From c523c77adbece3dc6d3046885c2ab6b7adb60a8a Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 9 Mar 2024 10:28:49 -0700 Subject: [PATCH] fi_subset -> fmodel_subset --- .../layout_optimization_base.py | 2 +- .../yaw_optimization/yaw_optimization_base.py | 26 +++++++++---------- .../yaw_optimizer_geometric.py | 6 ++--- .../yaw_optimization/yaw_optimizer_scipy.py | 8 +++--- .../yaw_optimization/yaw_optimizer_sr.py | 10 +++---- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/floris/optimization/layout_optimization/layout_optimization_base.py b/floris/optimization/layout_optimization/layout_optimization_base.py index e38668fe6..c8e192d1a 100644 --- a/floris/optimization/layout_optimization/layout_optimization_base.py +++ b/floris/optimization/layout_optimization/layout_optimization_base.py @@ -79,7 +79,7 @@ def _get_geoyaw_angles(self): # NOTE: requires that child class saves x and y locations # as self.x and self.y and updates them during optimization. if self.enable_geometric_yaw: - self.yaw_opt.fi_subset.set(layout_x=self.x, layout_y=self.y) + self.yaw_opt.fmodel_subset.set(layout_x=self.x, layout_y=self.y) df_opt = self.yaw_opt.optimize() self.yaw_angles = np.vstack(df_opt['yaw_angles_opt'])[:, :] else: diff --git a/floris/optimization/yaw_optimization/yaw_optimization_base.py b/floris/optimization/yaw_optimization/yaw_optimization_base.py index 99419d1cf..796dc8bde 100644 --- a/floris/optimization/yaw_optimization/yaw_optimization_base.py +++ b/floris/optimization/yaw_optimization/yaw_optimization_base.py @@ -224,7 +224,7 @@ def _reduce_control_problem(self): self.turbs_to_opt = (self.maximum_yaw_angle - self.minimum_yaw_angle >= 0.001) # Initialize subset variables as full set - self.fi_subset = self.fmodel.copy() + self.fmodel_subset = self.fmodel.copy() n_findex_subset = copy.deepcopy(self.fmodel.core.flow_field.n_findex) minimum_yaw_angle_subset = copy.deepcopy(self.minimum_yaw_angle) maximum_yaw_angle_subset = copy.deepcopy(self.maximum_yaw_angle) @@ -325,19 +325,19 @@ def _calculate_farm_power( farm_power (float): Weighted wind farm power. """ # Unpack all variables, whichever are defined. - fi_subset = copy.deepcopy(self.fi_subset) + fmodel_subset = copy.deepcopy(self.fmodel_subset) if wd_array is None: - wd_array = fi_subset.core.flow_field.wind_directions + wd_array = fmodel_subset.core.flow_field.wind_directions if ws_array is None: - ws_array = fi_subset.core.flow_field.wind_speeds + ws_array = fmodel_subset.core.flow_field.wind_speeds if ti_array is None: - ti_array = fi_subset.core.flow_field.turbulence_intensities + ti_array = fmodel_subset.core.flow_field.turbulence_intensities if yaw_angles is None: yaw_angles = self._yaw_angles_baseline_subset if turbine_weights is None: turbine_weights = self._turbine_weights_subset if heterogeneous_speed_multipliers is not None: - fi_subset.core.flow_field.\ + fmodel_subset.core.flow_field.\ heterogenous_inflow_config['speed_multipliers'] = heterogeneous_speed_multipliers # Ensure format [incompatible with _subset notation] @@ -348,14 +348,14 @@ def _calculate_farm_power( # Calculate solutions turbine_power = np.zeros_like(self._minimum_yaw_angle_subset[:, :]) - fi_subset.set( + fmodel_subset.set( wind_directions=wd_array, wind_speeds=ws_array, turbulence_intensities=ti_array, yaw_angles=yaw_angles, ) - fi_subset.run() - turbine_power = fi_subset.get_turbine_powers() + fmodel_subset.run() + turbine_power = fmodel_subset.get_turbine_powers() # Multiply with turbine weighing terms turbine_power_weighted = np.multiply(turbine_weights, turbine_power) @@ -494,9 +494,9 @@ def _verify_solutions_for_convergence( # to its baseline value for all conditions. n_turbs = len(self.fmodel.layout_x) sp = (n_turbs, 1) # Tile shape for matrix expansion - wd_array_nominal = self.fi_subset.core.flow_field.wind_directions - ws_array_nominal = self.fi_subset.core.flow_field.wind_speeds - ti_array_nominal = self.fi_subset.core.flow_field.turbulence_intensities + wd_array_nominal = self.fmodel_subset.core.flow_field.wind_directions + ws_array_nominal = self.fmodel_subset.core.flow_field.wind_speeds + ti_array_nominal = self.fmodel_subset.core.flow_field.turbulence_intensities n_wind_directions = len(wd_array_nominal) yaw_angles_verify = np.tile(yaw_angles_opt_subset, sp) yaw_angles_bl_verify = np.tile(yaw_angles_baseline_subset, sp) @@ -564,7 +564,7 @@ def _verify_solutions_for_convergence( diff_uplift = dP_old - dP_new ids_max_loss = np.where(np.nanmax(diff_uplift) == diff_uplift) jj = (ids_max_loss[0][0], ids_max_loss[1][0]) - ws_array_nominal = self.fi_subset.core.flow_field.wind_speeds + ws_array_nominal = self.fmodel_subset.core.flow_field.wind_speeds print( "Nullified the optimal yaw offset for {:d}".format(n) + " conditions and turbines." diff --git a/floris/optimization/yaw_optimization/yaw_optimizer_geometric.py b/floris/optimization/yaw_optimization/yaw_optimizer_geometric.py index 005de679d..ab0d4c9af 100644 --- a/floris/optimization/yaw_optimization/yaw_optimizer_geometric.py +++ b/floris/optimization/yaw_optimization/yaw_optimizer_geometric.py @@ -42,12 +42,12 @@ def optimize(self): array is equal in length to the number of turbines in the farm. """ # Loop through every WD individually. WS ignored! - wd_array = self.fi_subset.core.flow_field.wind_directions + wd_array = self.fmodel_subset.core.flow_field.wind_directions for nwdi, wd in enumerate(wd_array): self._yaw_angles_opt_subset[nwdi, :] = geometric_yaw( - self.fi_subset.layout_x, - self.fi_subset.layout_y, + self.fmodel_subset.layout_x, + self.fmodel_subset.layout_y, wd, self.fmodel.core.farm.turbine_definitions[0]["rotor_diameter"], top_left_yaw_upper=self.maximum_yaw_angle[0, 0], diff --git a/floris/optimization/yaw_optimization/yaw_optimizer_scipy.py b/floris/optimization/yaw_optimization/yaw_optimizer_scipy.py index caffcea90..4062f6200 100644 --- a/floris/optimization/yaw_optimization/yaw_optimizer_scipy.py +++ b/floris/optimization/yaw_optimization/yaw_optimizer_scipy.py @@ -68,12 +68,12 @@ def optimize(self): array is equal in length to the number of turbines in the farm. """ # Loop through every wind condition individually - wd_array = self.fi_subset.core.flow_field.wind_directions - ws_array = self.fi_subset.core.flow_field.wind_speeds - ti_array = self.fi_subset.core.flow_field.turbulence_intensities + wd_array = self.fmodel_subset.core.flow_field.wind_directions + ws_array = self.fmodel_subset.core.flow_field.wind_speeds + ti_array = self.fmodel_subset.core.flow_field.turbulence_intensities for i, (wd, ws, ti) in enumerate(zip(wd_array, ws_array, ti_array)): - self.fi_subset.set( + self.fmodel_subset.set( wind_directions=[wd], wind_speeds=[ws], turbulence_intensities=[ti] diff --git a/floris/optimization/yaw_optimization/yaw_optimizer_sr.py b/floris/optimization/yaw_optimization/yaw_optimizer_sr.py index 99eb44545..c6d76b04e 100644 --- a/floris/optimization/yaw_optimization/yaw_optimizer_sr.py +++ b/floris/optimization/yaw_optimization/yaw_optimizer_sr.py @@ -76,7 +76,7 @@ def _get_turbine_orders(self): layout_x = self.fmodel.layout_x layout_y = self.fmodel.layout_y turbines_ordered_array = [] - for wd in self.fi_subset.core.flow_field.wind_directions: + for wd in self.fmodel_subset.core.flow_field.wind_directions: layout_x_rot = ( np.cos((wd - 270.0) * np.pi / 180.0) * layout_x - np.sin((wd - 270.0) * np.pi / 180.0) * layout_y @@ -90,9 +90,9 @@ def _calc_powers_with_memory(self, yaw_angles_subset, use_memory=True): # Define current optimal solutions and floris wind directions locally yaw_angles_opt_subset = self._yaw_angles_opt_subset farm_power_opt_subset = self._farm_power_opt_subset - wd_array_subset = self.fi_subset.core.flow_field.wind_directions - ws_array_subset = self.fi_subset.core.flow_field.wind_speeds - ti_array_subset = self.fi_subset.core.flow_field.turbulence_intensities + wd_array_subset = self.fmodel_subset.core.flow_field.wind_directions + ws_array_subset = self.fmodel_subset.core.flow_field.wind_speeds + ti_array_subset = self.fmodel_subset.core.flow_field.turbulence_intensities turbine_weights_subset = self._turbine_weights_subset # Reformat yaw_angles_subset, if necessary @@ -153,7 +153,7 @@ def _calc_powers_with_memory(self, yaw_angles_subset, use_memory=True): farm_powers, ( Ny, - self.fi_subset.core.flow_field.n_findex + self.fmodel_subset.core.flow_field.n_findex ) )