## Irregular Waves and Pitch Momentum in MATLAB

Topics of general, but wind-related interest.

Moderator: Bonnie.Jonkman

Leonardo.Anjos
Posts: 2
Joined: Fri Sep 11, 2020 4:01 pm
Organization: General Electric
Location: Brazil

### Irregular Waves and Pitch Momentum in MATLAB

Hello,

I' ve been trying to replicate the strategy used to generate irregular waves and the diffraction pitch momentum as described in: https://www.nrel.gov/docs/fy08osti/41958.pdf using MATLAB, for academic purposes. However, I'm not sure what I am doing wrong, as it seems that, when I increase the sampling size for the angular frequency (the 'step' variable in my script), it affects both amplitude and frequency of the waves generated, when it (probably, I guess) shouldn't happen.
What seems to work is dividing the PSD by the step size and making it so that the simulation time increases as the step size decreases. The second one makes sense to me, since in the inverse fast fourier transform, more points in the frequency domain equals more time before 'repeating' itself. But I could not find an explanation to the amplitude issue. Following is my code, and examples of graphs with and without corrections. Any help is apprecriated.

Code: Select all

`%Read the WAMIT output file for the Barge Platform Wave-Excitation ForceBX = xlsread('C:\Users\Path\To\Barge.3\File\In\xlsx\Format','A1:G22201');B5 = BX(BX(:,2)==0 & BX(:,3)==5,:);B5(:,1) = 2*pi./B5(:,1);%Determining the frequency rangelim = 1.2;step = 0.0001;w = step:step:lim;%Reading only data regarding Beta = 0 and Pitch motion, summing both real%and imaginary partsReX5 = interp1(B5(:,1), B5(:,6), w, 'linear');ImX5 = interp1(B5(:,1), B5(:,7), w, 'linear');X5 = ReX5+1i*ImX5;%Preparing random variates for the WGN generationrng('shuffle');u1 = rand(1,size(w,2));rng('shuffle');u2 = rand(1,size(w,2));%Calling the noise fun. for every w and mirroring itn = noise(u1,u2);rn = fliplr(conj(n));wgn = [rn, 0, n];%Calling the spectra fun. for every w and mirroring its = spectra(w);rs = rot90(s,2);sout = [rs,0,s];%Taking the wave-excitation vector and mirroring itX5n = fliplr(conj(n));X5 = [X5n, 0, X5];%New boundaries definedw = -lim:step:lim;Ts = 2*pi/lim;tlim = Ts*length(sout)-Ts;t = 0:Ts:tlim;%Processing the data, taking it to time domainpre_waves = wgn.*sqrt(pi.*sout./step);waves = ifft(ifftshift(pre_waves), 'symmetric');pre_force5 = wgn.*sqrt(pi.*sout./step).*X5;force5 = ifft(pre_force5,'symmetric');%Plottingfigure(3)plot(t,waves,'b', t, force5, 'r')grid`

Jason.Jonkman
Posts: 5729
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

### Re: Irregular Waves and Pitch Momentum in MATLAB

Dear Leonardo,

I haven't reviewed your MATLAB code in detail, and I don't see any results attached to review. Regardless, in the FFT method, the frequency step is related to the simulation length and the time step is related to maximum frequency, i.e.:

domega = 2*pi/t_max
omega_max = pi/dt

(The frequencies here are in rad/s, not Hz.)

This is more clearly explained in my 2009 Wind Energy journal paper, which is based on the report you mention: https://onlinelibrary.wiley.com/doi/abs/10.1002/we.347.

When changing the simulation length, the frequency step should change, which means the random phases tied to each frequent component will change and you'll get a different realization of the wave time series.

Best regards,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

Leonardo.Anjos
Posts: 2
Joined: Fri Sep 11, 2020 4:01 pm
Organization: General Electric
Location: Brazil

### Re: Irregular Waves and Pitch Momentum in MATLAB

Dear Jason,

Thank you for your reply. I have implemented the relation between time and frequency you cited, and it seems to be working:

Irregular Wave Simulation
no_correction.jpg (68.34 KiB) Viewed 235 times

But the amplitude seems to be the issue, since I've used the same JONSWAP spectra from your paper, the significant height should look like:

Irregular Wave Simulation w/ Correction
resolved.jpg (64.97 KiB) Viewed 235 times

In this simulation, I've divided the spectrum by the 'domega' frequency step, and it seems to work, but I don't know why, as I've done this out of intuition. In the meantime, I'll be reading the paper you suggested.

Jason.Jonkman
Posts: 5729
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

### Re: Irregular Waves and Pitch Momentum in MATLAB

Dear Leanardo,

The DFT of the White Guassian Noise using the Box-Muller method is not stated in the Wind Energy paper I referenced above. But this is:

W[k] = SQRT(N/2)*SQRT(-2*LN(U1[k]))*EXP(j*2*pi*U2[k])

where U1[k] and U2[k] are independent and uniformly distributed random variates (random numbers between zero and one). U2[k] randomizes the phase and U1[k] randomizes the amplitude. If the amplitudes are not to be randomized (WaveNDAmp = FALSE in HydroDyn), then SQRT(-2*LN(U1[k])) is replaced by its mean value, SQRT(2).

Best regards,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov