|
[Sponsors] |
|
February 9, 2013, 04:01 |
|
#1 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,776
Rep Power: 71 |
just consider a 3d Cartesian mesh and (j,k) some fixed positions. This is some lines of my Matlab code for the energy spectrum
% ____________ E_uu (stream-wise)______________ % ff is a dump array for using the FFT of the field u(i,j,k) for i = 1:np+1, ff(i) = u(i,j,k); end % Discrete transform: computation of the Fourier coefficient c=fft(ff,np); for q = 1:np, c(q)=c(q)/np; end % Computation of the modulus squared. Cycle for all the wavenumbers for q=1:np, cu(q,k)=c(q)*conj(c(q)); end Then, you must simply plot your power spectrum. Generally, the computed spectrum are also computed along the whole homogeneous directions (e.g. for all the k) and then averaged to have a statistically meaning. |
|
February 12, 2013, 12:30 |
|
#2 |
New Member
Kealie Goodwin
Join Date: Feb 2013
Posts: 2
Rep Power: 0 |
Thank you for your code, FMDenaro. However, it's difficult for me to understand your process without your data. Does anyone have the math formulas they used for the autocorrelation? Again, the steps I'm using are:
1. Calculate autocorrelation to get signal into wave number space 2. Take fft 3. Calculate energy E(k) = E(k) + abs(V(i,j,m))^2 + abs(U(i,j,m))^2 + abs(W(i,j,m))^2; 4. plot energy vs wave number |
|
April 20, 2014, 21:40 |
|
#3 | |
Senior Member
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13 |
Quote:
I think the third line should be: cu(q)=c(q)*conj(c(q)) As known, the velocity spectrum tensor is phi[i,j](k)=cu(k),the energy spectrum is integrated to E(k)=1/2*cu(k)*dS(k) where S(k) is the sphere's surface area with radius mag(k) is this means to calculate E(k)=1/2*cu(k)*4*pi*k^2? |
||
April 21, 2014, 03:17 |
|
#4 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,776
Rep Power: 71 |
Quote:
|
||
April 21, 2014, 03:33 |
|
#5 | |
Senior Member
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13 |
Quote:
Thank you for your reply, could you please have a look at my previous reply for the code? Also, I tried another case which only contains 1 line of velocity in z direction.The result is still incorrect Code:
clear all; [z Ux Uy Uz]=textread('Zleft_U.xy','%f%f%f%f'); N=128; Lz=6.28; kz=(1:N)*2*pi/Lz; k=round(kz); c=fft(Uz,128); for q = 1:N, c(q)=c(q)/N; end for q=1:N, cu(q)=c(q)*conj(c(q)); end %up to now, the velocity-spectrum is obtained,however, the q~=k, %how to match them? for q=1:N, E(k)=0.5*cu(q)*4*pi*k.^2; end plot(k,E(k)) |
||
April 21, 2014, 04:13 |
|
#6 |
Senior Member
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13 |
||
April 20, 2014, 22:58 |
|
#7 | |
Senior Member
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13 |
Quote:
Sorry for the second reply.I followed your advice, here is my code in matlab Code:
clear all; [x y z Ux Uy Uz]=textread('U_constantPlane.raw','%f%f%f%f%f%f','headerlines',2); N=32768; Lz=6.28; kz=(2*pi*(1:256)/Lz); kzz=round(kz); w=reshape(Uz,256,128); wk=fft(w); for i = 1:256, for j=1:128, wk(i,j)=wk(i,j)/N; end end for i = 1:256, for j=1:128, R(i,j,kzz)=wk(i,j)*conj(wk(i,j)); end end for j=1:128, E(kzz)=0.5.*R(j,j,kzz(j))*4*pi.*kzz(j)^2; end plot(kzz,E(kzz)) |
||
April 21, 2014, 04:18 |
|
#8 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,776
Rep Power: 71 |
Quote:
w=reshape(Uz,256,128); wk=fft(w) this way, w is a matrix??? |
||
April 21, 2014, 04:31 |
|
#9 |
Senior Member
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13 |
yes,because z values are ranged in a periodic way(256 values one loop), so 32768 values corresponding to 128 loops, representing the whole value on a plane. Is this resonable?
I'm now confused about the wavanumber k, is this write as: (1:N)*2*pi/Lz each one is connected to a cu value in order? |
|
April 21, 2014, 04:40 |
|
#10 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,776
Rep Power: 71 |
Quote:
Anyway, I suggest checking for a simple test: generate a sin(k*x) function (try for some k value) and store in a vector, after doing the fft plot the spectrum and check if the energy density is located at the right frequency |
||
April 21, 2014, 04:56 |
|
#11 | |
Senior Member
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13 |
Quote:
what's definition formula of k? 2*pi*n/Lz? Best reguards |
||
Tags |
energy spectrum, fft |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
turbulent energy spectrum problem | cfd.newbie | Main CFD Forum | 6 | September 24, 2015 16:13 |
turbulent energy spectrum | cfd.newbie | Siemens | 1 | June 19, 2008 23:48 |
turbulent energy spectrum | cfd.newbie | FLUENT | 0 | June 18, 2008 18:34 |
LES correlation and turbulent energy spectrum | Fabian | Main CFD Forum | 4 | October 18, 2005 02:04 |
Energy Spectrum | Emad Khalifa | Main CFD Forum | 3 | June 30, 2003 16:03 |