Fast Fourier Transform & JONSWAP Spectral Analysis
Short Description
Analyze waves using fast fourier transform and model it using the Jonswap spectrum. The code was completed in Matlab...
Description
Fast Fourier Transform & JONSWAP Spectral Analysis OCEN 300 April 25, 2013 Team 1
Tyler Morgan
_______________________
Carly Rheman
_______________________
Keaton Savoie
_______________________
Matai Wilson
_______________________
1
Introduction The purpose of this project was to better understand the Fast Fourier Transport and JONSWAP methods of describing wave behavior. This was accomplished by using the Matlab program. To begin coding, two initial conditions were given below: (1.1)
1 cos( t ) sin( t ) cos(2 t ) sin( 3 t )
(1.2)
2 1 2cos 2 ( t ) sin( 4 t ) cos3 ( t )
4
6
3
6
These two conditions were used to determine the Fourier coefficients (AN and BN), as well as the phase EN, from the following equations: T
2 (t ) cos(n t )dt T 0
(1.3)
an
(1.4)
2 bn (t )sin(n t )dt T0
T
(1.5)
n a tan(
bn ) an
The initial, given η equations were plotted below in figures ETA1 and ETA2 below. From there, two time series were created (one for each η-value). This produced an analytical solution to an FFT problem. (Table 1, below and Matlab Appendix: FFT Analytical). Following this, the built-in FFT program in Matlab was used to find AN and BN in order to check the analytical solution FFT. While some imaginary values were produced from the Matlab calculations, the values were manipulated to produce a third set of AN and BN values. These were then compared to the analytical solutions (found above) to check the accuracy of both sets of calculations. After some manipulation and debugging of the Matlab program, similar results for η were found. In figures ETA1a and ETA2a below, one can see the plotted Matlab results of the FFT function, as well as the analytical results of Eta1b and Eta2b below. This is noted in Matlab Appendix: Question One, Parts 1-2.
2
Figure ETA1
Figure ETA2
3
Figure ETA1a: Analytical ETA1
Figure Eta2a: Analytical ETA2
4
Figure Eta1b
Figure Eta2b η1 0 1 2 3 4
an 0 1.2071 1 .866
η2 bn 0 -.1589 0 -0.5
an 1 0.75 -1 .25 .5
bn 0 0 0 0 -0.866
Table 1: A & B Values
5
The second part of this assignment was to use a JONSWAP spectrum to simulate an irregular wave train. To begin, initial conditions were given as follows: Tp = 10sec Hs=6.5m Γ=3.3
T=256s F=1/T σ=2πF
dT=.25s
Using these conditions, an initial graph of wave spectra was generated, as shown below and noted in Matlab Appendix, Question 2, Part1&2.
FIGURE 1: JONSWAP Spectrum From this point, the JONSWAP Spectrum was discretized. It should be noted that a frequency step size of 1/256 Hz was used. This discretized JONSWAP Spectrum was used to create a discretized amplitude spectrum, as noted below in Figure 2 as well as Matlab Appendix, Question 2, Part 3.
6
Figure 2: Discrete Amplitude Spectrum Figure 3 below demonstrates a wave train that was created using a randomly selected initial phase for a time period of 256 seconds. A random phase is key to better modeling wave behavior under real-world conditions rather than idealized sinusoidal curves. Comparing this JONSWAP-style model of surface elevation to that generated in the FFT program (Figure 4, below) reveals two very similar graphs, indicating a correctly executed JONSWAP program. Both of these are noted in Matlab Appendix, Question 2, Part 2 & Part 4.
Figure 3: Wave Surface Elevation vs. Time
7
Figure 4: Wave Amplitude Spectrum as described by FFT program
For each component, the initial phase is given below in Figure 5 and can be found be relating amplitude of the wave components to its frequency, also seen in Matlab Appendix, Question 2, Part 5.
Figure 5: Discretized Amplitude vs. Frequency From Matlab Appendix, Question 2, Part 6, the horizontal velocity under the highest wave crest was plotted after finding the highest wave crest in the time series below in Figures 6/7. This was done for a
8
change in height of .1m from the crest to -8m (Figure 6) and a change in height of 10m from -8m to the bottom at a depth of 400m (Figure 7).
Figure 6: Velocity vs. Crest Depth
Figure 7: Horizontal Velocity vs. Depth In part 2.7 of the assignment, the wave induced pressure under the highest wave crest was found and plotted against the depth of the wave crest to 8 meters below the surface (Matlab Appendix, Question 2, Part 7). This plot can be seen in Figure 8 below. Regarding Figure 9 below, the wave induced 9
pressure under the highest wave crest was calculated and plotted against the depth from 8 meters to the bottom at 400m.
Figure 8: Pressure under Highest Wave Crest
Figure 9: Pressure under Highest Wave Crest Finally, the wave induced vertical acceleration under the highest wave crest was computed using Matlab. As above, the plot of acceleration and depth for the crest to -8m was plotted in Figure 10. The plot of the vertical acceleration vs. the depth of wave crest to 8 meters to the bottom can be found in Figure 11 below. For more detail, reference Matlab Appendix, Question 2, Part 8.
10
Figure 10: Vertical Acceleration vs. Wave Crest
Figure 11: Vertical Acceleration vs. Depth Conclusion This lab allowed the team to analyze waves via an FFT analysis as well as the JONSWAP Spectrum. It proved useful for describing wave behavior and many characteristics for random wave behavior. Overall, the analytical solutions that we derived closely resembled our solutions using the FFT Matlab function. This proves that the FFT function in Matlab is a viable resource for analyzing waves. Furthermore, the JONSWAP spectrum allowed us to simulate unidirectional irregular wave train with 11
given variables. The discrete amplitude spectrum tabled values can be found in the appendix of this document.
12
Appendix - Coding OCEN300.M clc clear all T=256; f=(1/T); S=2*pi*f; t=.25 dt=[.25:t:256];
n1=cos(pi/4-S*dt)+sin(pi/6-S*dt)+cos(2*S*dt)+sin(pi/3-3*S*dt); n2=(1-2*(cos(S*dt)).^2+sin(pi/6-4*S*dt)+(cos(S*dt)).^3);
a0=0 a1=(sqrt(2)/2+.5) a2=1 a3=sqrt(3)/2 b0=0 b2=0 b1=sqrt(2)/2-sqrt(3)/2 b3=-.5 a4=0; a5=3/4; a6=-1; a7=-1/4; a8=1/2; b4=0; b5=0; b6=0; b7=0; b8=-sqrt(3)/2; %% Question One Part Three A %FFT ANALYTICAL ETA ONE ETA=a0+a1*cos(S*dt)+b1*sin(S*dt)+a2*cos(2*S*dt)+b2*sin(S*2*dt)+a3*cos(3*S*dt) +b3*sin(3*S*dt) % FFT ANALYTICAL ETA TWO ETA2=a4+a5*cos(S*dt)+b4*sin(S*dt)+a5*cos(2*S*dt)+b5*sin(S*2*dt)+a6*cos(3*S*dt )+b6*sin(3*S*dt)+a7*cos(4*S*dt)+b7*sin(4*S*dt)+a8*cos(5*S*dt)+b8*sin(5*S*dt) %% Question One Part Three B %FFT NUMERICAL ETA ONE
13
T=256; f=(1/T); S=2*pi*f; y1=fft(n1,256*4); ay1=(2*real(y1(1:512))/4/256); ay12=a1/1024; bigby1=(2*imag(y1(513:1024))/4/256); n=1:512 FFTNUM1 = ay12+ ay1*cos(2*pi*n'*dt/256)+ bigby1*sin(2*pi*n'*dt/256); % FFT NUMERICAL ETA TWO T=256; f=(1/T); S=2*pi*f; y2=fft(n2,256*4); ay2=(2*real(y2(1:512))/4/256); ay22=a5/1024; bigby2=(2*imag(y2(513:1024))/4/256); n=1:512 FFTNUM2 = ay22+ ay2*cos(2*pi*n'*dt/256)+ bigby2*sin(2*pi*n'*dt/256);
%% Plot Commands of Eta One, Eta Two, FFT Analytical, FFT Numerical % Plot Eta One and Two figure(1) plot(dt,n1,'b') xlim([0 260]) title('Eta One vs Time') xlabel('Time(s)') ylabel('Eta One (m)') figure(2) plot(dt,n2,'c') title('Eta Two vs Time') xlabel('Time(s)') ylabel('Eta Two (m)') xlim([0 260]) % Plot FFT Analytical figure(3) plot(dt,ETA) title('Analytical Eta One (FFT) vs Time') xlabel('Time(s)') ylabel('Eta One (m)') xlim([0 260]) figure(4) plot(dt,ETA2) title('Analytical Eta Two (FFT) vs Time') xlabel('Time(s)') ylabel('Eta Two (m)') xlim([0 260])
14
% Plot FFT Numerical figure(5) plot(dt,FFTNUM1) title('Numerical FFT ONE') ylabel('Wave and Surface Elevation (m)') xlabel('T(sec)') xlim([0 256]) figure(6) plot(dt, FFTNUM2) title('Numerical FFT TWO') ylabel('Wave and Surface Elevation (m)') xlabel('T(sec)') xlim([0 256])
OCEN300q1p2.m clc clear all T=256; f=(1/T); S=2*pi*f; t=.25 dt=[0:t:256];
n1=cos(pi/4-S*dt)+sin(pi/6-S*dt)+cos(2*S*dt)+sin(pi/3-3*S*dt); n2=(1-2*(cos(S*dt)).^2+sin(pi/6-4*S*dt)+(cos(S*dt)).^3);
a0=0 a1=(sqrt(2)/2+.5) a2=1 a3=sqrt(3)/2 b0=0 b2=0 b1=sqrt(2)/2-sqrt(3)/2 b3=-.5 %Carly said we should just copy it. E1=atan(b1/a1) % E11=E1+2*pi E2=atan(b2/a2) E3=atan(b3/a3) E33=E3+pi %%
15
%question 2 %Carly said we should start part 2...yeah T=256; f=(1/T); S=2*pi*f; %% % question 3 y1=fft(n2,256*4); a=2*real(y1)/4/256; a(1)=2*a1; bigb=2*imag(y1)/4/256;
JONSWAP.M Tp=10; Hs=6.5; G=3.3; T=.25:.25:256; df=1/.25; dt=.25; cf=.3; wmax=cf; lcf=.02; h=400; fp=1/Tp; fe=[1/256:1/256:0.3]; S=2*pi.*fe; for i=1:length(fe) if fe
View more...
Comments