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