Skip to content

Commit

Permalink
fi_subset -> fmodel_subset
Browse files Browse the repository at this point in the history
  • Loading branch information
paulf81 committed Mar 9, 2024
1 parent ab399a7 commit c523c77
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 13 additions & 13 deletions floris/optimization/yaw_optimization/yaw_optimization_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
8 changes: 4 additions & 4 deletions floris/optimization/yaw_optimization/yaw_optimizer_scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions floris/optimization/yaw_optimization/yaw_optimizer_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
)
)

Expand Down

0 comments on commit c523c77

Please sign in to comment.