hyeye archive
[FLORIS] FlorisInterface 초기화, Run Optimization using the Serial-Refine method 본문
Simulator
[FLORIS] FlorisInterface 초기화, Run Optimization using the Serial-Refine method
hyeye_ 2023. 9. 27. 12:06터빈 레이아웃
- wake model : Gauss Curl Hybrid model
- turbine : NREL 5MW
- diameter : 126.0 m
- cut-in / rate / cut-out wind speed : 3 / 11.4 / 25 (m/s)
- layout_x : [5*D, 10*D, 15*D]
- layout_y : [500., 500., 500.]
바람장 조건
- 3 <= wind speed <=12 (m/s)
- 180 <= wind direction <= 360 (deg)
결과
Code
# import library
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt
from floris.tools import FlorisInterface
from floris.tools.optimization.yaw_optimization.yaw_optimizer_sr import YawOptimizationSR
from floris.tools.visualization import visualize_cut_plane
#%% Initialization
# Initialize FLORIS with the given input file via FlorisInterface.
fi = FlorisInterface("./gch.yaml")
# Convert to a simple three-turbine layout and wind conditions
D = 126.0
wd = np.arange(180.0, 360.0, 5.0)
fi.reinitialize(
layout_x=[5*D, 10*D, 15*D],
layout_y=[500., 500., 500.])
# Using the FlorisInterface functions, get 2D slices.
horizontal_plane = fi.calculate_horizontal_plane(x_resolution=200, y_resolution=100, height=90.0)
visualize_cut_plane(horizontal_plane, title="Horizontal")
plt.show()
# Initialize an empty list to store legend labels
legend_labels = []
# Create a single plot for yaw results
fig, axarr = plt.subplots(3, 1, sharex=True, sharey=False, figsize=(8, 8))
#%% Optimization
# Loop over wind speeds
for ws in range(3, 13):
fi.reinitialize(
wind_directions=wd,
wind_speeds=[ws])
# Initialize optimizer object and run optimization using the Serial-Refine method
yaw_opt = YawOptimizationSR(fi)
df_opt = yaw_opt.optimize()
print("Optimization results : ")
print(df_opt)
# Split out the turbine results
for t in range(3):
df_opt['t%d' % t] = df_opt.yaw_angles_opt.apply(lambda x: x[t])
# Add the legend label for this wind speed
legend_labels.append(f'WS={ws} m/s')
# Plot yaw offset for T1
ax1 = axarr[0]
ax1.plot(df_opt.wind_direction, df_opt['t0'], label='WS={ws} m/s'.format(ws=ws))
ax1.set_title('T0')
ax1.legend(legend_labels)
ax1.grid(True)
# Plot yaw offset for T2
ax2 = axarr[1]
ax2.plot(df_opt.wind_direction, df_opt['t1'], label='WS={ws} m/s'.format(ws=ws))
ax2.set_title('T1')
ax2.set_ylabel('Yaw Offset (deg)')
ax2.grid(True)
# Plot yaw offset for T3
ax3 = axarr[2]
ax3.plot(df_opt.wind_direction, df_opt['t2'], label='WS={ws} m/s'.format(ws=ws))
ax3.set_title('T2')
ax3.set_xlabel('Wind Direction (deg)')
ax3.grid(True)
# save result
df_yaw_t0 = pd.DataFrame([df_opt['t0']]).T
df_yaw_t1 = pd.DataFrame([df_opt['t1']]).T
df_yaw_t2 = pd.DataFrame([df_opt['t2']]).T
df_wd = pd.DataFrame([wd]).T
data = pd.concat([df_wd, df_yaw_t0, df_yaw_t1, df_yaw_t2], axis=1)
data.columns = ['WD', 'yaw_T0', 'yaw_T1', 'yaw_T2']
data.to_csv('./result/{ws}_ms.csv'.format(ws=ws), header=True, index=False)
# save control region
any_nonzero_yaw = (data[['yaw_T0','yaw_T1','yaw_T2']] != 0).any(axis=1)
if any_nonzero_yaw.any():
data_nonzero = data[any_nonzero_yaw]
data_nonzero['ws'] = ws
data_nonzero.columns = ['WD', 'yaw_TO', 'yaw_T1', 'yaw_T2', 'WS']
if not os.path.isfile('./result/control_region.csv'):
data_nonzero.to_csv('./result/control_region.csv', mode='a', header=True, index=False)
else:
data_nonzero.to_csv('./result/control_region.csv', mode='a', header=False, index=False)
# Show the results
plt.show()
'Simulator' 카테고리의 다른 글
[FLORIS] Floris.v3 설치 방법/ 기존 Floris 삭제 / Python 인터페이스 (0) | 2022.07.04 |
---|---|
[FLORIS] Floris 설치 방법 / Python 인터페이스 (0) | 2022.05.18 |