Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable heterogeneous inflows in yaw optimization routines #678

Merged
merged 6 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion floris/simulation/turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,9 @@ def __attrs_post_init__(self) -> None:
)
self.power_interp = interp1d(
wind_speeds,
inner_power
inner_power,
bounds_error=False,
fill_value=0
)

"""
Expand Down
4 changes: 4 additions & 0 deletions floris/tools/floris_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ def get_turbine_powers(self) -> NDArrayFloat:
"Can't run function `FlorisInterface.get_turbine_powers` without "
"first running `FlorisInterface.calculate_wake`."
)
# Check for negative velocities, which could indicate bad model
# parameters or turbines very closely spaced.
if (self.turbine_effective_velocities < 0.).any():
print("WARNING: Some rotor effective velocities are negative.")

turbine_powers = power(
ref_density_cp_ct=self.floris.farm.ref_density_cp_cts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ def _normalize_control_problem(self):
/ self._normalization_length
)

def _calculate_farm_power(self, yaw_angles=None, wd_array=None, turbine_weights=None):
def _calculate_farm_power(self, yaw_angles=None, wd_array=None, turbine_weights=None,
heterogeneous_speed_multipliers=None
):
"""
Calculate the wind farm power production assuming the predefined
probability distribution (self.unc_options/unc_pmf), with the
Expand All @@ -358,6 +360,9 @@ def _calculate_farm_power(self, yaw_angles=None, wd_array=None, turbine_weights=
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.floris.flow_field.\
heterogenous_inflow_config['speed_multipliers'] = heterogeneous_speed_multipliers

# Ensure format [incompatible with _subset notation]
yaw_angles = self._unpack_variable(yaw_angles, subset=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def optimize(self):
yaw_template = np.tile(yaw_template, (1, 1, 1))
turbine_weights = np.tile(turbine_weights, (1, 1, 1))

# Handle heterogeneous inflow, if there is one
if (hasattr(self.fi.floris.flow_field, 'heterogenous_inflow_config') and
self.fi.floris.flow_field.heterogenous_inflow_config is not None):
het_sm_orig = np.array(
self.fi.floris.flow_field.heterogenous_inflow_config['speed_multipliers']
)
het_sm = het_sm_orig[nwdi,:].reshape(1,-1)
else:
het_sm = None

# Define cost function
def cost(x):
x_full = np.array(yaw_template, copy=True)
Expand All @@ -116,7 +126,8 @@ def cost(x):
- 1.0 * self._calculate_farm_power(
yaw_angles=x_full,
wd_array=[wd],
turbine_weights=turbine_weights
turbine_weights=turbine_weights,
heterogeneous_speed_multipliers=het_sm
)[0, 0] / J0
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,19 @@ def _calc_powers_with_memory(self, yaw_angles_subset, use_memory=True):
if not np.all(idx):
# Now calculate farm powers for conditions we haven't yet evaluated previously
start_time = timerpc()
if (hasattr(self.fi.floris.flow_field, 'heterogenous_inflow_config') and
self.fi.floris.flow_field.heterogenous_inflow_config is not None):
het_sm_orig = np.array(
self.fi.floris.flow_field.heterogenous_inflow_config['speed_multipliers']
)
het_sm = np.tile(het_sm_orig, (Ny, 1))[~idx, :]
else:
het_sm = None
farm_powers[~idx, :] = self._calculate_farm_power(
wd_array=wd_array_subset[~idx],
turbine_weights=turbine_weights_subset[~idx, :, :],
yaw_angles=yaw_angles_subset[~idx, :, :],
heterogeneous_speed_multipliers=het_sm
)
self.time_spent_in_floris += (timerpc() - start_time)

Expand Down