CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

FFT to compute Strouhal number under Matlab

Register Blogs Community New Posts Updated Threads Search

Like Tree8Likes
  • 1 Post By pbrady2013
  • 2 Post By LuckyTran
  • 1 Post By pbrady2013
  • 1 Post By FMDenaro
  • 1 Post By LuckyTran
  • 2 Post By FMDenaro

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 22, 2018, 09:40
Post FFT to compute Strouhal number under Matlab
  #1
New Member
 
hraf5
Join Date: Mar 2018
Posts: 8
Rep Power: 8
EL OMARI Achraf is on a distinguished road
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.
EL OMARI Achraf is offline   Reply With Quote

Old   September 23, 2018, 19:59
Default FFT and more
  #2
Member
 
Peter Brady
Join Date: Apr 2014
Location: Sydney, NSW, Australia
Posts: 54
Rep Power: 12
pbrady2013 is on a distinguished road
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
EL OMARI Achraf likes this.
pbrady2013 is offline   Reply With Quote

Old   September 24, 2018, 18:16
Default
  #3
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,761
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
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.
LuckyTran is offline   Reply With Quote

Old   September 25, 2018, 07:08
Default
  #4
New Member
 
hraf5
Join Date: Mar 2018
Posts: 8
Rep Power: 8
EL OMARI Achraf is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
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 is offline   Reply With Quote

Old   September 25, 2018, 07:10
Default
  #5
New Member
 
hraf5
Join Date: Mar 2018
Posts: 8
Rep Power: 8
EL OMARI Achraf is on a distinguished road
Quote:
Originally Posted by pbrady2013 View Post
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
EL OMARI Achraf is offline   Reply With Quote

Old   September 25, 2018, 07:18
Default Fundamental Frequencies
  #6
Member
 
Peter Brady
Join Date: Apr 2014
Location: Sydney, NSW, Australia
Posts: 54
Rep Power: 12
pbrady2013 is on a distinguished road
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
Attached Images
File Type: jpg exampleSR.jpg (73.4 KB, 111 views)
EL OMARI Achraf likes this.
pbrady2013 is offline   Reply With Quote

Old   September 25, 2018, 13:12
Default
  #7
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Being careful to the use of the windowing in the FFT, you have a time-signal that is not periodic in time
EL OMARI Achraf likes this.
FMDenaro is offline   Reply With Quote

Old   September 28, 2018, 10:41
Default
  #8
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,761
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Quote:
Originally Posted by EL OMARI Achraf View Post
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!
EL OMARI Achraf likes this.
LuckyTran is offline   Reply With Quote

Old   September 28, 2018, 12:11
Default
  #9
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
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.
FMDenaro is offline   Reply With Quote

Old   September 20, 2020, 04:14
Default Doubt
  #10
Member
 
Mayank
Join Date: May 2019
Location: India
Posts: 30
Rep Power: 7
May19 is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
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)
May19 is offline   Reply With Quote

Old   September 20, 2020, 05:59
Default
  #11
Senior Member
 
MA
Join Date: Mar 2020
Posts: 163
Rep Power: 6
mazhar16823 is on a distinguished road
Quote:
Originally Posted by May19 View Post
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
mazhar16823 is offline   Reply With Quote

Reply

Tags
fft, lift coefficient, matlab code, spectral analysis, strouhal number


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
decomposePar no field transfert Jeanp OpenFOAM Pre-Processing 3 June 18, 2022 13:01
AMI speed performance danny123 OpenFOAM 21 October 24, 2020 05:13
ERROR #001100279 has occurred in subroutine ErrAction. smnaryal CFX 11 December 20, 2017 17:32
SigFpe when running ANY application in parallel Pj. OpenFOAM Running, Solving & CFD 3 April 23, 2015 15:53
[blockMesh] --> foam fatal error: lillo763 OpenFOAM Meshing & Mesh Conversion 0 March 5, 2014 11:27


All times are GMT -4. The time now is 16:04.