Official Defined functions in Wake Deficit Models have some issues
Hello, I used the pychar IDE to reproduce the code in the tutorial. However, when running visualized wake models such as Jensen, TurboNOJ, Gaussian, etc., I was unable to draw images properly. Discovering custom function plot_ Deficit_ There is a problem with the map.
Wake Deficit Models
Definition and configuration
plot_deficit_map:
The custom function link for the official tutorial is https://topfarm.pages.windenergy.dtu.dk/PyWake/notebooks/WakeDeficitModels.html。
fm.ws is a one-dimensional xarray, fm.WS_ If the eff is 5D xarray, there may be a mismatch with the matplotlib dimension, resulting in drawing failure and inability to complete the image drawing.
I changed the custom function plot _ deficit_ map code according to my personal understanding, as follows:
def plot_deficit_map(model, cmap='Blues', levels=np.linspace(0, 10, 55)):
fm = get_flow_map(model)
deficit_map_plane = fm.ws.values[0] - fm.WS_eff.values[:, :, 0, 0, 0] # Select a plane and extract data
contour = plt.contourf(fm.X / D, fm.Y / D, deficit_map_plane, levels=levels, cmap=cmap)
# Add a line representing wind turbine
plt.plot([0, 0], [-0.5, 0.5], color='black', linewidth=2) # Line representing the diameter D of the wind turbine
# Add a black solid dot at (0, 0) to represent hub
plt.scatter([0], [0], color='black', s=40)
setup_plot(grid=False, ylabel="Crosswind distance [y/D]", xlabel="Downwind distance [x/D]",
xlim=[fm.x.min() / D, fm.x.max() / D], ylim=[fm.y.min() / D, fm.y.max() / D])
plt.colorbar(contour, label='Deficit [m/s]') # Add colorbar with label
However, there are still differences from the official ones, as the wind turbine type V80 is not displayed in the upper right corner of the image
In addition, the following official codes also have issues:
Comparing wake deficit models:
#printing all available wake deficit models in PyWake
from py_wake.utils.model_utils import get_models
from py_wake.deficit_models.deficit_model import WakeDeficitModel
deficitModels = get_models(WakeDeficitModel)
for deficitModel in deficitModels:
print (deficitModel.__name__)
The error prompt is:
Traceback (most recent call last):
File "D:\WindCode\My_pywake\Engineering_WindFarm_Models_object.py", line 201, in <module>
fm = get_flow_map(deficitModel(), XYGrid(x=np.linspace(-200, 800, 300), y=0))
^^^^^^^^^^^^^^
File "D:\WindCode\py_wake\deficit_models\fuga.py", line 210, in __init__
x_lst, y_lst, z_lst = [ds_lst[0][k].values for k in 'xyz']
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\WindCode\py_wake\deficit_models\fuga.py", line 210, in <listcomp>
x_lst, y_lst, z_lst = [ds_lst[0][k].values for k in 'xyz']
~~~~~~^^^
IndexError: list index out of range
I hope the official can correct the code in a timely manner, so that I, as a beginner in the code, can repeat the official tutorial and provide a foundation for future learning of pywalk. After all, the incorrect code cannot be further learned. Thank you very much for the official and everyone's reply!