MATLAB Examples

Vertical mast

The wind field is now simulated along a vertical line (e.g. a wind mast). I use the input file INPUT_MAST.txt with 20 nodes created along a vertical line, for alitudes ranging from 10 to 90 m.

The power law was chosen for the vertical wind profile. The mean wind velocity at reference heigth was: Uref = 20 m/s, and the reference height was 10 m above the sea. The coefficient for the power law is: a = 0.15.

The position of "y" is not important any more. I have chosen it equal to 0, but it could have been anything else. The new grid is therfore defined using:

  • Nyy = 1 (number of nodes along y axe)
  • Nzz = 20 (number of nodes along z axe)
  • Zmin = 10 (min altitude of grid for z-axe (meters))
  • Zmax = 90 (max altitude of grid for z-axe (meters))
  • Ymin = 0 (min longitude for y-axe (meters))
  • Ymax = 0 (max longitude for y-axe (meters))

The evolution of the turbulent parameters (Lu,Iu, coherence...) are here defined based on the reference height and reference wind velocity only. In reality, this may be different. In that case, a modification of the function windSim may be required.

Contents

Function call

clear all;close all;clc;
rng(1) ;% to ensure reproducibility of the example.
filename = 'INPUT_MAST.txt';
[u,v,w,t,nodes] = windSim(filename);
U = u+nodes.U*ones(size(t)); % get fluctuating + mean value
Elapsed time is 21.976179 seconds.

Time series overview

figure
box on; hold on
[x,z]=meshgrid(t(1:600),nodes.Z(1:5:end));
plot3(x',z',U(1:5:end,1:600)')
xlabel('time (s) ');
zlabel('u (m/s)')
ylabel('z (m)')
set(gcf,'color','w')
view(-45,45)

Vertical mean wind speed profile

zr = 10; % 10 meters
a = 0.15 ; % cf INPUT_MAST.txt
U_target= nodes.U(1).*(nodes.Z./zr).^(a);
figure
hold on; box on;
plot(mean(U,2),nodes.Z,'k')
plot(nodes.U,nodes.Z,'ko','markerfacecolor','r')
legend('target','simulated','location','NorthWest')
ylabel('z (m) ');
xlabel('U (m/s)')
set(gcf,'color','w')

Turbulence intensity

The present code specifies a turbulent intensity that decreases for increasing mean wind velocity, i.e. for increasing altitudes. This is more realistic than the constant turbulent intensity introduced in a previous version.

Iu = std(u,0,2)./nodes.U*100;
Iv = std(v,0,2)./nodes.U*100;
Iw = std(w,0,2)./nodes.U*100;

figure
box on;hold on,grid on
plot(nodes.U,Iu,'ko','markerFaceColor','r')
plot(nodes.U,Iv,'ko','markerFaceColor','y')
plot(nodes.U,Iw,'ko','markerFaceColor','b')
xlabel('U (m/s)')
ylabel('TI (%)')
set(gcf,'color','w')
legend('Iu','Iv','Iw','location','SouthWest')
% set(findall(gca,'-property','fontSize'),'fontsize',16)

Co-coherence & assumption

Assumption: Averaging over same cross-wind separation.
Here, we are assuming the the coherence does not change so much with the
altitude, i.e. variations of U have little influence on the measured
coherence.
% time step & sampling frequency
dt = median(diff(t));
fs = 1/dt;
tmax = t(end);
f0 = 1/tmax;
[Nsamples,N] = size(u);
% block duration (each)
tBlock = 240;
% number of blocks
NBlock = round(tmax/tBlock);
% number of data point per block
Ncoh = round(N/NBlock);
clear Su Sv Sw

if mod(Ncoh,2),
    cocoh = zeros(Nsamples,Nsamples,round(Ncoh/2));
else
    cocoh = zeros(Nsamples,Nsamples,round(Ncoh/2)+1);
end
% computation of the cocoherence using the function cohere
for ii=1:Nsamples,
    for jj=1:Nsamples,
        [cocoh(ii,jj,:),~,freq] = coherence(u(ii,:),u(jj,:),Ncoh,round(Ncoh/2),Ncoh,fs);
    end
end


dz = zeros(Nsamples,Nsamples); % matrix distance along y
for kk= 1:Nsamples,
    for mm = 1:Nsamples,
        dz(kk,mm) = abs(nodes.Z(kk)-nodes.Z(mm));
    end
end

cocoh2 = reshape(cocoh,Nsamples*Nsamples,[]);
[uniqueDist]=unique(round(dz(:)*100)/100); % average at +/- 1 cm
meanCoCoh = zeros(numel(uniqueDist),size(cocoh2,2));
for ii=1:numel(uniqueDist),
    ind = find(round(dz(:)*100)/100==uniqueDist(ii));
    meanCoCoh(ii,:)=nanmean(cocoh2(ind,:));
end

distTarget = [10,20,40,60];

figure
for ii=1:4,
    [~,indDist] = min(abs(uniqueDist-distTarget(ii)));
    subplot(2,2,ii)
    box on;hold on
    plot(freq,meanCoCoh(indDist,:),'ko','markerfacecolor','r');
    plot(freq,exp(-10.*dz(1,indDist).*freq/nodes.U(1)),'k');
    legend(['d = ',num2str(uniqueDist(indDist),2),' m'],'target');
    xlim([0,0.2])
    ylabel('co-coherence')
    if ii>2,
        xlabel('f (Hz)')
    end
    set(gcf,'color','w')
end

Verification of assumption

I plot the co-coherence for different cross-wind separation, with two reference sensors: one at z = 10 m and the other at z = 90 m Results: Little difference is obtained. The averaging over same cross-wind separations appears as reliable here. In reality, fluctuations of the coherence with the altitude could be observed

figure
distTarget = [5,15,25,45];
COLOR = {'r','y','g','b'};
symbol = {'ko','kd','ksq','k^'};
indZ = [1,20]; % i look at 4 separation with  reference nodes 1,5,10 ad 15
for ii=1:numel(distTarget),
    clear indDist myLeg
    for jj=1:numel(indZ)
        [~,indDist] = min(abs(dz(:,indZ(jj))-distTarget(ii)));
        subplot(2,2,ii)
        box on;hold on
        plot(freq,squeeze(cocoh(indDist,indZ(jj),:)),symbol{jj},'markerfacecolor',COLOR{jj});
        myLeg{jj} =['z =',num2str(nodes.Z(indZ(jj)),2),' m and z =',num2str(nodes.Z(indDist),2),' m'];
    end
    xlim([0,0.2])
    if or(ii==1,ii==3),
        ylabel('co-coherence')
    end
    xlabel('f (Hz)')
    legend(myLeg,'location','NorthOutside')
end
set(gcf,'color','w')

Conclusions

A turbulent wind field has been simulated along a vertical line in a simple study case. The model used here is rather simple, because the turbulent parameters are defined based on the reference wind speed, and the reference height.