0% found this document useful (0 votes)
15 views13 pages

MATLAB Wind Speed Power Spectra Tool

This document describes a MATLAB tool for analyzing wind speed data and generating turbulence power spectra. The tool takes in a wind speed time history, sampling frequency and other parameters to plot normalized or dimensional power spectra. It can also average and smooth the spectra over multiple divisions of the time history. The tool allows comparing the generated spectra to a von Karman theoretical model.

Uploaded by

Taniya Saha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views13 pages

MATLAB Wind Speed Power Spectra Tool

This document describes a MATLAB tool for analyzing wind speed data and generating turbulence power spectra. The tool takes in a wind speed time history, sampling frequency and other parameters to plot normalized or dimensional power spectra. It can also average and smooth the spectra over multiple divisions of the time history. The tool allows comparing the generated spectra to a von Karman theoretical model.

Uploaded by

Taniya Saha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

See discussions, stats, and author profiles for this publication at: [Link]

net/publication/327848577

Wind Analysis Tools: Power Spectra

Technical Report · September 2018


DOI: 10.17603/DS2398M

CITATION READS
1 2,233

1 author:

Mohammadtaghi Moravej
Florida International University
48 PUBLICATIONS 341 CITATIONS

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

INVESTIGATING SCALE EFFECTS ON ANALYTICAL METHODS OF PREDICTING PEAK WIND LOADS ON BUILDINGS View project

All content following this page was uploaded by Mohammadtaghi Moravej on 08 October 2018.

The user has requested enhancement of the downloaded file.


MATLAB Power Spectra Tool for Wind Speed
Analysis

DOI: [Link]

10555 West Flagler St, Miami, FL | [Link] | Page 1 of 12


Table of Contents
Revision History ............................................................................................................................................ 3
1 Definitions & Syntax .............................................................................................................................. 4
2 Instructions & Examples ....................................................................................................................... 4
3 Additional Notes ................................................................................................................................... 8
4 Appendix ............................................................................................................................................. 10

10555 West Flagler St, Miami, FL | [Link] | Page 2 of 12


Revision History

Version Date Author Comments


V1.0 09/18/2018 Mohammadtaghi Moravej Original document

Moravej, Mohammadtaghi; Gan Chowdhury, Arindam, (2018-09-20), "Wind Analysis Tools: Power
Spectra" , DesignSafe-CI [publisher], Dataset, doi:10.17603/DS2398M

10555 West Flagler St, Miami, FL | [Link] | Page 3 of 12


1 Definitions & Syntax
The uspectra code is developed as a tool for the quick generation of turbulence power spectra from
wind speed data collected at wind tunnels. The code is defined as a MATLAB function, and the syntax is
as follows:

[ nOut,sOut,s_avg ] = uspectra(U,h,Sf,mode,Ndiv,FullscaleParam)

Where:

U is the time history of the wind speed.

h is the wind speed measurement height or building dimension or any other parameter desired to be
used to normalize the frequency.

Sf is the sampling frequency.

mode: plot mode that can be either ‘dim’ to plot dimensional plots (frequency on the horizontal axis and
Sn on the vertical axis) or ‘nondim’ to create non-dimensional plots based on mean wind speed (U).

In the non-dimensional case, the horizontal axis becomes nh/U and the vertical axis becomes nSn/U.

Ndiv: Number of divisions is defined when a smoothed plot is desired. The program divides the whole
time history of the wind speed into Ndiv blocks and creates the turbulence power spectrum for each
block, then averages across all and generates a single smoothed plot.

FullscaleParam: If a full-scale comparison is intended, then the required parameters which are the full-
scale height, turbulence intensity and turbulence length scale, should be defined in the form of a row
matrix : [H Iu Lu]. The comparison is made using a Von Karman model. More detailed information is
provided in the following sections.

nOut: Matrix of calculated frequencies

sOut: Matrix of power spectrum ordinates

s_avg: Matrix of averaged (smoothed) power spectrum ordinates

2 Instructions & Examples


To use a MATLAB code, the file should be in a location within the search path of MATLAB. The fastest
way is to either copy it to the current working folder of the MATLAB (the folder which is active and
contents are displayed - Figure 1) or change the folder and set it to the desired location where the
function file is stored. The function file name is uspectra.m and the sample wind speed file coming with
it is [Link].

To run the code and apply the function to the provided wind speed data sample, double-click on the
filename (i.e., [Link] in the Current Folder). By doing this, the variable which is
stored in this file and is named U1to20 will be loaded to the workspace as shown in Figure 2.

10555 West Flagler St, Miami, FL | [Link] | Page 4 of 12


Figure 1 – MATLAB window

Figure 2 – Sample wind speed data loaded into workspace

10555 West Flagler St, Miami, FL | [Link] | Page 5 of 12


To run the function, type the following line in Command Window, where the cursor is blinking after the
>> sign:

uspectra(U1to20,0.2,2500,'nondim')

This command will plot the non-dimensional power spectra for a wind speed time history recorded at a
2500Hz rate and 0.2m height. The output is shown in Figure 3.

Figure 3 –Normalized power spectrum

To plot a smoothed curve averaged over ten subintervals (Figure 4):

uspectra(U1to20,0.2,2500,'nondim',10)

To compare the spectrum with a Von-Karman spectrum at 4m height with Iu=0.216 and Lu=25m (Figure
5, Figure 6):

[n,s1,s2]=uspectra(U1to20,0.2,2500,'nondim',10,[4 0.216 25*0.7])

The above command also saves the outputs into three MATLAB variables named n,s1 and s2. The
variable names can be selected arbitrarily and there is no need to use the same names defined in the
function code.

10555 West Flagler St, Miami, FL | [Link] | Page 6 of 12


Figure 4 – Smoothed power spectrum

Figure 5 – Comparison of the spectrum with the Von Karman model

10555 West Flagler St, Miami, FL | [Link] | Page 7 of 12


Figure 6 - Comparison of the smoothed spectrum with the Von Karman model

3 Additional Notes
The following equation is used to plot the Von Karman spectrum:
𝑛𝑆𝑢𝑢 (𝑛) 4𝑥
2 =
𝜎𝑢 (1 + 70.8𝑥 2 )5/6
where
𝑛𝐿𝑢
𝑥=
𝑈
𝑛: Frequency

𝑆𝑢𝑢 (𝑛): Power spectrum density

𝜎𝑢 : Standard deviation of wind speed

𝐿𝑢 : Turbulence length scale

𝑈: Mean wind speed

Considering the definition of the turbulence intensity:

𝜎𝑢
𝐼𝑢 =
𝑈

10555 West Flagler St, Miami, FL | [Link] | Page 8 of 12


The output of Equation 1 is multiplied by Iu2 to have the spectrum normalized by mean wind speed. Also,
𝑛𝐿𝑢 𝐻
the normalized frequency ( ) is multiplied by ( ) to make it consistent with the reduced frequency
𝑈 𝐿𝑢
𝑛𝐻
definition ( 𝑈 ) used throughout the program for the wind tunnel spectra.

10555 West Flagler St, Miami, FL | [Link] | Page 9 of 12


4 Appendix

The MATLAB code of the uspectra.m function:


function [ nOut,sOut,s_avg ] = uspectra(U,h,Sf,mode,Ndiv,FullscaleParam)
% uspectra v1.0
% This function needs the Signal Processing Toolbox, specifically pwelch
% built-in function.
% uspectra(U,h,Sf,mode,Ndiv,FullscaleParam)
% U: wind speed vector
% b: model dimension or speed measurement height
% Sf: sampling frequency
% mode: if set to 'nondim', plot will be nondimensionalized (normalized
% spectra)
% Ndiv: divides the U into Ndiv subintervals (blocks), calculates the
% spectrum for each block and averages across all the spectra to get
a
% smoothed curve. Input [] to skip and move to the next argument.
% FullscaleParam: should be a matrix of [H Iu Lu]
% where: H full-scale height
% Iu full-scale turbulence intensity
% Lu full-scale integral length scale
% note: ESDU Lu should be multiplied by ~0.7 to be used in
% Von-Karman model

% Last update 09/17/2018 Mohammadtaghi Moravej (mmora229@[Link]) (c)


% FIU Extreme Events Institute - Wall of Wind NHERI EF

if nargin<6
FullscaleParam=[];
end
if nargin<5
Ndiv=[];
end
if nargin<4
mode='nondim'; % sets the default mode to "nondim", i.e. non-dimensional
plots
disp('Default mode set to non-dimensional plots.')
end

umean=mean(U);
[s,n]=pwelch(detrend(U),[],[],[],Sf);%s: spectrum ordinates, n:frequency

if strcmp(mode,'nondim') % if non-dimensional plot is selected


sOut=n.*s/umean^2;
nOut=n*h/(umean);
loglog(nOut,sOut)
xlabel('nb/U')
ylabel('nS_n/U^2')
grid on
hold on

10555 West Flagler St, Miami, FL | [Link] | Page 10 of


12
elseif strcmp(mode,'dim')% if dimensional plot is selected
nOut=n;
sOut=s;
loglog(nOut,sOut)
xlabel('n(Hz)')
ylabel('S_n')
grid on
end

if ~isempty(FullscaleParam) && strcmp(mode,'nondim') % if full-scale


comparison is selected
H=FullscaleParam(1);
Iu=FullscaleParam(2);
Lu=FullscaleParam(3);
yk=vonkarman(nOut)*Iu^2;
xk=nOut*(H/Lu);
q=loglog(xk,yk,'k--');
set(q,'Color','k','linewidth',1.5);
grid on
legend('Wind tunnel spectrum','Von Karman')
end

if ~isempty(Ndiv) % Check if Ndiv is defined (smoothing requested)


[n_avg,s_avg]=spectrablockingN(U,h,Sf,Ndiv);
figure
loglog(n_avg,s_avg,'LineWidth',3,'Color','b')
xlabel('nb/U')
ylabel('nS_n/U^2')
grid on
hold on

if ~isempty(FullscaleParam) % adding the von karman plot


%x=0.01:.01:35;
nOut=n_avg;
yk=vonkarman(nOut)*Iu^2; % to change nS/sigma^2 --> nS/U^2
xk=nOut*(H/Lu); % to change nL/U --> nH/U
q=loglog(xk,yk,'k--');
set(q,'Color','k','linewidth',1.5)
grid on
legend('Wind tunnel spectrum','Von Karman')

end
else
s_avg=[];
end
if nargout==0
nOut=[];
end
end
%% subfunctions
function [A,B]=spectrablockingN(data,h,sf,NBlocks)

10555 West Flagler St, Miami, FL | [Link] | Page 11 of


12
% data: vector of wind speed (or other desired data)
% h : data collection hieght
% sf: sampling frequency
% NBlocks : the whole vector will be divided into NBlocks
% subranges, then averaged over all.
m=mean(data);
data=data-mean(data);
recordLength=size(data,1);
blockSize=floor(recordLength/NBlocks);
for i=1:NBlocks
Data=data((i-1)*blockSize+1:i*blockSize,1);
[p,f]=pwelch(Data,[],[],[],sf);
a(:,i)=f.*h/m;
b(:,i)=f.*p./(m.^2);
end
A=mean(a,2);
B=mean(b,2);
end

function n_Suu_over_sigmauSquared=vonkarman(x)
% x=nL/u
n_Suu_over_sigmauSquared=4*x./(1+70.8*x.^2).^(5/6);
end

10555 West Flagler St, Miami, FL | [Link] | Page 12 of


12

View publication stats

You might also like