MATLAB script for generating uniform wind files (.wnd)

Dear community,

I want to share with you a MATLAB code i made in order to generate .wnd file.
This file is used to simulate uniform wind speed. Note that i am using MATLAB R2021a.
The code:

function [ ] = write_uniform_wind_file_for_InflowWind_riad()
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
% The goal of this function is to write uniform wind files
% Those files have .wnd as extension and they are used by InflowWind

tic

%% ======================== Defining the variables ===========================

time_step=0.0125;
% Pay attention to the time step
% I prefer to be the same as the one used in OpenFAST
% I am working on the 5 MW barge-type FOWT

mean_wind_speed_at_hub_height=11.4;

wind_direction=0;

vertical_shear=0;

horizontal_shear=0;

power_law_shear=0.2;

lin_vertical_shear=0;

gust=0;

time=0:time_step:10800; % Time in seconds

A=cell(length(time)+1,1);

vector_of_wind_speed_at_hub_height=mean_wind_speed_at_hub_height*ones(1,length(time)); % Wind speed in (m/s) at hub height

vector_of_wind_direction=wind_direction*ones(1,length(time));

vector_of_vertical_shear=vertical_shear*ones(1,length(time));

vector_of_horizontal_shear=horizontal_shear*ones(1,length(time));

vector_of_power_law_shear=power_law_shear*ones(1,length(time));

vector_of_lin_vertical_speed=lin_vertical_shear*ones(1,length(time));

vector_of_gust_speed=gust*ones(1,length(time));

%% ========================= Content of the .wnd file ======================

for i=1:length(time)
A{i}=strcat(num2str(time(i))," “,num2str(vector_of_wind_speed_at_hub_height(i)),” “,num2str(vector_of_wind_direction(i)),” “,num2str(vector_of_vertical_shear(i)),” “,num2str(vector_of_horizontal_shear(i)),” “,num2str(vector_of_power_law_shear(i)),” “,num2str(vector_of_lin_vertical_speed(i)),” ",num2str(vector_of_gust_speed(i)));
end

%% ========================= Writing .wnd file ======================================

fid = fopen(“test_uniform_wind_file.wnd”, ‘w’);

for i = 1:numel(A)-1
if strcmp(A{i+1},-1)==1
fprintf(fid,‘%s’, A{i});
break
else
fprintf(fid,‘%s\n’, A{i});
end

% fprintf(fid,‘%s\n’, A{i});
end
fclose(fid);

toc

end

%% ============================================================= End of the file ========================================================

Best Regards,

Riad

1 Like

Dear @ Riad.Elhamoud,
Thank you so much for kindly sharing the code! I was wondering if I could politely ask for a bit of clarification: when the wind type is set to WindType=2 (uniform), would Vh_ref refer to the mean wind speed or the combined value of the mean wind and turbulent fluctuations? Your expert insight on this would be greatly appreciated.
Best Regards,

Dear @Yingxin.Lv,

In fact, it should be the combined value of the mean wind speed and turbulent fluctuations. However, i used the code to generate a gust. I have seen in this article: Insights from detailed numerical investigation of 15 MW offshore semi-submersible wind turbine using aero-hydro-servo-elastic code - ScienceDirect
that to generate a gust one should have a constant mean wind speed, then the gust is applied where the wind speed increases instantaneously then it comes back to the mean value before gust. But of course you can have a mean wind speed then add fluctuations generated from Kaimal spectrum for example.

The most important thing is to remember that:

  • The uniform wind speed field in OpenFAST does not consider spatial variablility and varies only with time
  • The steady wind speed field does not consider the variability neither in time nor space
  • The turbulent wind speed field considers both the spatial and time variabililty

Best Regards,

Riad

Dear @ Riad.Elhamoud,
Thank you ever so much for your gracious reply! Upon reviewing the InflowWind_Manual, I noticed the calculation formulas for horizontal and vertical wind speeds. From my understanding, The power law model addressed in the formulas describes the distribution law corresponding to the mean wind speed..Might this imply that Vhref denotes the mean wind speed?
Additionally, I would be most grateful if you could kindly clarify the significance of the “VGust” column in the input file.



May I kindly share my perspective first? I suspect that the calculation formulas for turbulent wind speed and mean wind speed might differ when computing aerodynamic loads in OpenFAST, especially considering the distinct physical mechanisms they represent. Would you kindly confirm if this aligns with your understanding?
Best Regards,
Yingxin

Dear @Yingxin.Lv,

Thank you for sharing this figure.
In my understanding, Vh_ref is the out-of-plane (perpendicular to rotor plane) mean wind speed. It contains several contributions :

(i) from the height z described by the famous power law
(ii) from the horizontal linear wind-shear
(iii) from the vertical linear wind-shear

The gust is specified as the additional wind speed. Please kindly find an attached image i used to generate gust.

In this figure, the mean wind speed initially is 11.4 m/s then at t=200 s, a gust was applied. After the gust, the mean wind speed returns to its initial value. Also, in this figure, both the horizontal and the vertical linear wind-shear are set to zero. I take a vertical shear equals to 0.2 (power law) and V_gust that varies between -2 and +4.

Regarding my opinion concerning the perspective you have asked, I think (maybe i am wrong !) i dont agree with you. In my understanding, for computing aerodynamic loads, relative wind speed is needed which is V_h(x,y,z) because it represents the magnitude of the wind speed in the plane. That is, if u is the wind speed component along x-direction, v is the wind speed component along y-direction and w is the wind speed component along z-direction, V_h(x,y,z) = sqrt(u^2+v^2). But personally, i dont now how this is related to the expression given in the manual. Maybe @Jason.Jonkman could you give your comments, opinions and insights please ? thank you in advance.

Best Regards,

Riad

I agree with @Riad.Elhamoud’s responses to @Yingxin.Lv’s questions. I would just add that uniform wind data files are typically used to model deterministic wind gust events, but not for turbulence. To simulate turbulence, typically TurbSim is used to generate full-field turbulence data files.

Best regards,

Dear@ Riad.Elhamoud@ Jason.Jonkman
Thank you so much for your helpful reply! It solved my problem perfectly. Your insight was invaluable—many thanks for your time!
Best regards,
yingxin

Dear@ Jason.Jonkman
I hope this message finds you well. How to configure TurbSim to generate a unidirectional wind field (with zero wind velocities in both v and w directions)? I’ve attempted:
Generating RootName-u.bin, RootName-v.bin, RootName-w.bin
Setting InflowWind WindType = 5
Assigning FileName_v and FileName_w to “unused”
However, InflowWind requires valid files for FileName_v and FileName_w. How might I properly achieve a unidirectional wind field?
Might I kindly request your guidance on the correct approach to configure this setup? Any advice would be sincerely appreciated.
Thank you for your time and valuable assistance.
Best regards,

Dear @Yingxin.Lv,

Yes, InflowWind requires valid u.bin, v.bin and w.bin files when using HAWC-formatted wind files. So, to use your approach you’ve have to overwrite the v.bin and w.bin files with files that are zero-valued.

Another approach would be to select TurbModel = USRINP and in the user-defined spectra file, UserFile, set the v- and w-spectra to zero. In this case, you can output wind data from TurbSim using any of its data formats.

Best regards,

Dear@ Jason.Jonkman
Thank you very much for your reply! Your suggestions were extremely effective.
Best regards,