Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
layout_y = []
for i in range(N_row):
for k in range(N_row):
layout_x.append(i*spc*D)
layout_y.append(k*spc*D)
N_turb = len(layout_x)
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y),wind_direction=[270.0],wind_speed=[8.0])
fi.calculate_wake()
# ================================================================================
print('Plotting the FLORIS flowfield...')
# ================================================================================
# Initialize the horizontal cut
hor_plane = wfct.cut_plane.HorPlane(
fi.get_flow_data(),
fi.floris.farm.turbines[0].hub_height
)
# Plot and show
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(hor_plane, ax=ax)
ax.set_title('Baseline flow for U = 8 m/s, Wind Direction = 270$^\circ$')
# ================================================================================
print('Importing wind rose data...')
# ================================================================================
# Create wind rose object and import wind rose dataframe using WIND Toolkit HSDS API.
# Alternatively, load existing file with wind rose information.
calculate_new_wind_rose = False
finish = time.time()
print('Time to calculate flow field', finish - start)
# Get a horizontal cut from default flow field
start = time.time()
hor_plane_1 = wfct.cut_plane.HorPlane(
fi.get_flow_data(),
fi.floris.farm.turbines[0].hub_height
)
fi.calculate_wake()
finish = time.time()
print('Time to extract default flow field', finish - start)
# Get a horizontal cut from horizontal methods
start = time.time()
hor_plane_2 = wfct.cut_plane.HorPlane(
fi.get_hub_height_flow_data(),
fi.floris.farm.turbines[0].hub_height
)
fi.calculate_wake()
finish = time.time()
print('Time to extract horizontal flow field', finish - start)
# Plot and show they are the same
fig, axarr = plt.subplots(1, 2)
wfct.visualization.visualize_cut_plane(
hor_plane_1, ax=axarr[0], minSpeed=minSpeed, maxSpeed=maxSpeed)
wfct.visualization.visualize_cut_plane(
hor_plane_2, ax=axarr[1], minSpeed=minSpeed, maxSpeed=maxSpeed)
plt.show()
spc = 5
layout_x = [0, 0]
layout_y = [0, 5*D]
N_turb = len(layout_x)
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y),wind_direction=[270.0],wind_speed=[8.0])
fi.calculate_wake()
unc_options={'std_wd': 4.95, 'std_yaw': 0.0,'pmf_res': 1.0, 'pdf_cutoff': 0.95}
# ================================================================================
print('Plotting the FLORIS flowfield...')
# ================================================================================
# Initialize the horizontal cut
hor_plane = wfct.cut_plane.HorPlane(
fi.get_flow_data(),
fi.floris.farm.turbines[0].hub_height
)
# Plot and show
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(hor_plane, ax=ax)
ax.set_title('Baseline flow for U = 8 m/s, Wind Direction = 270$^\circ$')
# ================================================================================
print('Importing wind rose data...')
# ================================================================================
# Create wind rose object and import wind rose dataframe using WIND Toolkit HSDS API.
# Alternatively, load existing file with wind rose information.
calculate_new_wind_rose = False
layout_y.append(k*spc*D)
N_turb = len(layout_x)
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y),wind_direction=[270.0],wind_speed=[8.0])
fi.calculate_wake()
# option to include uncertainty
include_unc = False
unc_options={'std_wd': 4.95, 'std_yaw': 0.0,'pmf_res': 1.0, 'pdf_cutoff': 0.95}
# ================================================================================
print('Plotting the FLORIS flowfield...')
# ================================================================================
# Initialize the horizontal cut
hor_plane = wfct.cut_plane.HorPlane(
fi.get_flow_data(),
fi.floris.farm.turbines[0].hub_height
)
# Plot and show
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(hor_plane, ax=ax)
ax.set_title('Baseline flow for U = 8 m/s, Wind Direction = 270$^\circ$')
# ================================================================================
print('Importing wind rose data...')
# ================================================================================
# Create wind rose object and import wind rose dataframe using WIND Toolkit HSDS API.
# Alternatively, load existing .csv file with wind rose information.
calculate_new_wind_rose = True
# Define speed limits
minSpeed = 4.
maxSpeed = 8.
# Initialize FLORIS model
fi = wfct.floris_utilities.FlorisInterface("example_input.json")
# Calculate the time to run wake
start = time.time()
fi.calculate_wake()
finish = time.time()
print('Time to calculate flow field', finish - start)
# Get a horizontal cut from default flow field
start = time.time()
hor_plane_1 = wfct.cut_plane.HorPlane(
fi.get_flow_data(),
fi.floris.farm.turbines[0].hub_height
)
fi.calculate_wake()
finish = time.time()
print('Time to extract default flow field', finish - start)
# Get a horizontal cut from horizontal methods
start = time.time()
hor_plane_2 = wfct.cut_plane.HorPlane(
fi.get_hub_height_flow_data(),
fi.floris.farm.turbines[0].hub_height
)
fi.calculate_wake()
finish = time.time()
print('Time to extract horizontal flow field', finish - start)
# set turbine locations to 3 turbines in a row
D = fi.floris.farm.turbines[0].rotor_diameter
layout_x = [0, 7 * D, 14 * D]
layout_y = [0, 0, 0]
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y))
fi.calculate_wake()
# initial power output
power_initial = np.sum(fi.get_turbine_power())
# ================================================================================
print('Plotting the FLORIS flowfield...')
# ================================================================================
# Initialize the horizontal cut
hor_plane = wfct.cut_plane.HorPlane(fi.get_hub_height_flow_data(),
fi.floris.farm.turbines[0].hub_height)
# Plot and show
fig, ax = plt.subplots()
wfct.visualization.visualize_cut_plane(hor_plane, ax=ax)
# ================================================================================
print('Finding optimal yaw angles in FLORIS...')
# ================================================================================
# set bounds for allowable wake steering
min_yaw = 0.0
max_yaw = 25.0
yaw_angles = optimize_yaw(fi, min_yaw, max_yaw)
print('yaw angles = ')
for i in range(len(yaw_angles)):
print('==========================================')
print('Total Power Gain without Uncertainty = %.1f%%' %
(100.*(power_opt - power_initial)/power_initial))
print('Total Power Gain with Uncertainty using Original Yaw Angles = %.1f%%' %
(100.*(power_opt_unc - power_initial_unc)/power_initial_unc))
print('Total Power Gain with Uncertainty using Robust Yaw Angles = %.1f%%' %
(100.*(power_opt_unc_robust - power_initial_unc)/power_initial_unc))
print('==========================================')
# =============================================================================
print('Plotting the FLORIS flowfield with yaw...')
# =============================================================================
# Initialize the horizontal cut without uncertainty
fi.calculate_wake(yaw_angles=yaw_angles)
hor_plane = wfct.cut_plane.HorPlane(
fi.get_hub_height_flow_data(x_resolution=400,
y_resolution=100),
fi.floris.farm.turbines[0].hub_height
)
# Plot and show
fig, ax = plt.subplots(figsize=(7.0, 5.0))
wfct.visualization.visualize_cut_plane(hor_plane, ax=ax)
ax.set_title('Optimal Wake Steering without Uncertainty for U = 8 m/s, Wind Direction = 273$^\circ$')
# Initialize the horizontal cut for robust wake steering with uncertainty
fi.calculate_wake(yaw_angles=yaw_angles_unc)
hor_plane = wfct.cut_plane.HorPlane(
fi.get_hub_height_flow_data(x_resolution=400,
y_resolution=100),
fi.floris.farm.turbines[0].hub_height