MATLAB code for full stochastic turbulent wind speed field magnitude generated by TURBSIM

Hello everyone,

I write a MATLAB code that permits to draw the full stochastic turbulent wind speed field magnitude generated by TURBSIM. This code makes use of the function readfile_BTS.m written by Bonnie JONKMAN (NREL).

%%%%%%% Start of the code%%%%%%%%%%%%%%%%%%%%%%%%
%%% draw the full stochastic turbulent wind speed field magnitude
[velocity, twrVelocity, y, z, zTwr, nz, ny, dz, dy, dt, zHub, z1,mffws] = readfile_BTS(bts file path);

velocity_magnitude=zeros(length(velocity(:,1,1,1)),ny,nz); % Definition of a 3D array

for i=1:nz
for j=1:ny
velocity_magnitude(:,j,i)=sqrt(velocity(:,1,j,i).^2 + velocity(:,2,j,i).^2 + velocity(:,3,j,i).^2);
end
end

time=linspace(0,(length(velocity_magnitude(:,1,1))-1)*dt,length(velocity_magnitude(:,1,1)));

[mesh_grid_y,mesh_grid_time,mesh_grid_z]=meshgrid(y,time,z);

x_slice=[ ];

y_slice=linspace(0,(length(velocity_magnitude(:,1,1))-1)*dt,1000);

z_slice=[ ];

slice(mesh_grid_y,mesh_grid_time,mesh_grid_z,velocity_magnitude,x_slice,y_slice,z_slice)
xlabel(“Lateral distance from the tower (m)”)
ylabel(“Time (s)”)
zlabel(“Height (m)”)
shading interp;
c=colorbar;
c.Label.String=“Magnitude of wind speed (m/s)”;

%%%%%%END of the code%%%%%%%%%%%%%%%%%%%%%%%%%%
The execution of my bts file leads to the following full stochastic turbulent wind speed field magnitude.

N.B: I am using MATLAB R2021a

Hope that code helps :grinning:

Best Regards,

Riad