CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   FFT to compute Strouhal number under Matlab (https://www.cfd-online.com/Forums/main/207037-fft-compute-strouhal-number-under-matlab.html)

EL OMARI Achraf September 22, 2018 08:40

FFT to compute Strouhal number under Matlab
 
Hi every one,

I am working on the numerical simulation of the wake around a 2d cylinder.
For now I am trying to calculate the Strouhal number: St = D * f / U.
So, I need to do a FFT spectral analysis under Matlab of the lift coefficient Cl to calculate the fundamental frequency f.
If anyone can help me with a Matlab code to do this task.

Thank you.

pbrady2013 September 23, 2018 18:59

FFT and more
 
Hi,


The following example will walk you through. It is from the signal processing toolbox but the fft command should (I think) be in base MATLAB. I have the SP toolbox.



https://au.mathworks.com/help/signal...using-fft.html


Have taken into account the Nyquist frequency when setting up your transient simulation?



I always do a sanity check on my data first to check for start up transients to see if they've faded and if there are any anomolous points. It can also be good to resample if you are using adaptive timesteps so you data is at non-uniform sample frequencies.



It can also be good to look at decay rates at the higher frequencies as well as cutoff frequencies relative to the grid scale and turbulence model. There are some fundamental physics at these frequencies that, depending on your turbulence model, are either ignored or attempted to be simulated.



Hope that helps,
-pete

LuckyTran September 24, 2018 17:16

If your sampling frequency is fs and x is your lift coefficient. Then the code can be as simple as:

Code:

X=2*fft(x)/length(x);
fl=linspace(0,fs,length(X));
 plot(fl,abs(X));


You can do things like removing the mean also.

EL OMARI Achraf September 25, 2018 06:08

Quote:

Originally Posted by LuckyTran (Post 707314)
If your sampling frequency is fs and x is your lift coefficient. Then the code can be as simple as:

Code:

X=2*fft(x)/length(x);
fl=linspace(0,fs,length(X));
 plot(fl,abs(X));


You can do things like removing the mean also.


Thank you very much LuckyTran.
I still have one question: how can I calculate the fundamental frequency?

EL OMARI Achraf September 25, 2018 06:10

Quote:

Originally Posted by pbrady2013 (Post 707196)
Hi,


The following example will walk you through. It is from the signal processing toolbox but the fft command should (I think) be in base MATLAB. I have the SP toolbox.



https://au.mathworks.com/help/signal...using-fft.html


Have taken into account the Nyquist frequency when setting up your transient simulation?



I always do a sanity check on my data first to check for start up transients to see if they've faded and if there are any anomolous points. It can also be good to resample if you are using adaptive timesteps so you data is at non-uniform sample frequencies.



It can also be good to look at decay rates at the higher frequencies as well as cutoff frequencies relative to the grid scale and turbulence model. There are some fundamental physics at these frequencies that, depending on your turbulence model, are either ignored or attempted to be simulated.



Hope that helps,
-pete

Thank you Peter Brady

pbrady2013 September 25, 2018 06:18

Fundamental Frequencies
 
1 Attachment(s)
Hi,


Both of these methods will generate some form of power spectral density. See attached for an example. The fundamental frequency, and any harmonics, will stand out as an isolated peak realtive to the turbulence noise within the system.


In the example attached we have periodic sheddding off a square cylinder in cross flow.



Cheers,
-pete

FMDenaro September 25, 2018 12:12

Being careful to the use of the windowing in the FFT, you have a time-signal that is not periodic in time

LuckyTran September 28, 2018 09:41

Quote:

Originally Posted by EL OMARI Achraf (Post 707382)
Thank you very much LuckyTran.
I still have one question: how can I calculate the fundamental frequency?


It is mostly an art. You will probably end up with a very messy plot and hopefully you find one or more peaks. Hopefully you have a good guess beforehand what the fundamental frequency is and can correlate it to the peak in the plot. The fft and its plot is more for confirmation rather than a recipe where you bake a fundamental frequency. (un)fortunately that is how real life works.


Just look at peter's example above. It takes some experience to say, ah-hah that is the peak I want!

FMDenaro September 28, 2018 11:11

Understanding the fundamental frequency is somehow related to the coherence of the associated vortical structure that generate it.

If you have a long time-signal, it could be subdiveded in several regions (windows) and you can perform for each the FFT. Of course the problem is encountered with the "exact" periodicity of the windows. Spectral analysis of non-periodical signal requires care. However, you can do an ensemble averaging of the FFT and get a smooth spectra where the peak is highlighted better.

May19 September 20, 2020 03:14

Doubt
 
Quote:

Originally Posted by LuckyTran (Post 707314)
If your sampling frequency is fs and x is your lift coefficient. Then the code can be as simple as:

Code:

X=2*fft(x)/length(x);
fl=linspace(0,fs,length(X));
 plot(fl,abs(X));


You can do things like removing the mean also.

Can you please tell that why you have multipled with 2 in X = 2*fft(x)/length(x)

mazhar16823 September 20, 2020 04:59

Quote:

Originally Posted by May19 (Post 783232)
Can you please tell that why you have multipled with 2 in X = 2*fft(x)/length(x)


https://dsp.stackexchange.com/questi...when-using-fft


All times are GMT -4. The time now is 05:24.