You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to add a Bayesian algorithm in addition to scipy, serial refine, and geometrics, which can be tested with Floris this time. I'm encountering an error 'axis 2 is out of bounds for an array of dimension 2' when using the 'fi.calculate_wake(yaw_angles=yaw_agnles_array)' syntax. When using '.list', I get a 'dimension 1' error. Is there a good alternative? I apologize for asking what may seem like silly questions.
def calculate_efficiency(yaw_angles, wind_direction, wind_speed):
# Calculate the efficiency based on yaw angles, wind direction, and wind speed
total_efficiency = 1.0
for yaw_angle in yaw_angles:
angle_diff = min(abs(wind_direction - yaw_angle), 360 - abs(wind_direction - yaw_angle))
eff = max(0, np.cos(np.radians(angle_diff))) # Efficiency based on the cosine of the angle difference
total_efficiency += eff
average_efficiency = total_efficiency / len(yaw_angles) # Average efficiency per turbine
return average_efficiency
def calculate_AEP(efficiency, wind_speed):
# Calculate the Annual Energy Production (AEP)
Air_Density = 1.0 # Air density (kg/m^3)
power_output = Air_Density * efficiency * (wind_speed ** 3)
hours_per_year = 8760 # Operating hours per year
AEP = power_output * hours_per_year # Annual energy production (MWh)
return AEP / 1000 # Convert to GWh
def optimize_yaw_angles():
# Initialize the Floris Interface
fi = wfct.floris_interface.FlorisInterface("examples/inputs/gch.yaml")
# Reinitialize the Floris Interface with a new layout, wind directions, and wind speeds
D = 40.0
F = D * 3
fi.reinitialize(
layout_x=[882.51*F, 883.71*F, 884.82*F, 886.34*F, 888.48*F, 888.07*F, 886.76*F, 885.32*F, 887.92*F, 889.53*F, 890.96*F, 892.56*F, 890.73*F],
layout_y=[1758.3*F, 1755.87*F, 1753.26*F, 1751.23*F, 1752.14*F, 1755.57*F, 1758.35*F, 1760.55*F, 1761.95*F, 1759.4*F, 1757.2*F, 1754.7*F, 1753.35*F],
wind_directions=np.arange(260.0, 280.0, 2.0),
wind_speeds=[7.0]
)
def yaw_angles_efficiency(wind_direction, wind_speed, **yaw_angles):
# Convert 1D array of yaw_angles to a 2D array
yaw_angles_list = [yaw_angles[f'yaw_angle_{i}'] for i in range(len(fi.floris.farm.layout_x))]
yaw_angles_array = np.array([yaw_angles_list])
# Set wind direction, wind speed, and yaw angles in FLORIS
fi.reinitialize(wind_directions=np.array([wind_direction]), wind_speeds=np.array([wind_speed]))
fi.calculate_wake(yaw_angles=yaw_angles_array)
# Calculate AEP
power_output = fi.get_farm_power()
efficiency = calculate_efficiency(yaw_angles_list, wind_direction, wind_speed)
hours_per_year = 8760
AEP = power_output * hours_per_year / 1000 # Convert to GWh
return AEP
# Set up Bayesian Optimization
pbounds = {f'yaw_angle_{i}': (-25, 25) for i in range(len(fi.floris.farm.layout_x))}
pbounds['wind_direction'] = (260, 280)
pbounds['wind_speed'] = (7, 7)
optimizer = BayesianOptimization(
f=yaw_angles_efficiency,
pbounds=pbounds,
random_state=2048,
verbose=2
)
optimizer.maximize(init_points=13, n_iter=500)
# Print the optimized results
optimized_parameters = optimizer.max['params']
print("\nOptimized Yaw Angles and Estimated AEP:")
for i in range(len(fi.floris.farm.layout_x)):
angle = optimized_parameters[f'yaw_angle_{i}']
print(f"Turbine {i+1}: Yaw Angle = {angle:.2f} degrees")
total_AEP = calculate_AEP(fi.get_farm_power(), optimized_parameters['wind_speed'])
print(f"Estimated Total AEP: {total_AEP:.2f} GWh")
if __name__ == "__main__":
optimize_yaw_angles() ''
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to add a Bayesian algorithm in addition to scipy, serial refine, and geometrics, which can be tested with Floris this time. I'm encountering an error 'axis 2 is out of bounds for an array of dimension 2' when using the 'fi.calculate_wake(yaw_angles=yaw_agnles_array)' syntax. When using '.list', I get a 'dimension 1' error. Is there a good alternative? I apologize for asking what may seem like silly questions.
Beta Was this translation helpful? Give feedback.
All reactions