CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Phase delay computation (https://www.cfd-online.com/Forums/main/6668-phase-delay-computation.html)

Pratap October 8, 2003 04:59

Phase delay computation
 
Hi I have question ?. I have a curve say input f(t) which is function of time t and this is harmonic.From this input agter processing i get output say g(t) which is periodic and funation of time. When I plot above function in time space.I find same pahse difference between and also there is difference in magnitude. I want to how to compute this phase difference.I know it has something to do with FFT. So anybody who has already done it before and knows of some reference pls reply. Thanks in advance. prasat

Lionel Larcheveque October 8, 2003 06:11

Re: Phase delay computation
 
Hi

To obtain the phase difference between two time series, you can compute their cross-spectrum, or more likely its normalized forms, the coherence and phase spectra. To estimate them, proceed as follow (Welch's method):

1) for each time series f and g with m samples, separates them into n blocks of length m_b, with m_b a power of two, such as consecutive blocks overlaps for about 50 % => n~=int(2*m/m_b-1). You must choose m_b to obtain at least 20 blocks (more is desirable if f and g are really noisy).

2) set value for (squared) coherence Co and phase Ph mean spectra to zero :

Co(j)=0

Ph(j)=0

THEN FOR EACH BLOCK i:

3) Compute the mean fm_i and gm_i of f_i and g_i over the block i, and perform subtractions of the means for all the samples j=1,...,m_b

f_i(j)=f_i(j)-fm_i

g_i(j)=g_i(j)-gm_i,

4) use a windows w(j) to reduce leakage. For instance the Welch one : w(j)=1-( (j-m_b/2) / (m_b/2) )^2

and then

f_i(j)=f_i(j)*w(j)

g_i(j)=...

5) Compute FFTs F_i and G_i of f_i and g_i using your favorite computing library, with F_i and G_i being complex numbers

6) compute A_F and A_G autospectra and C crossspectrum :

A_F_i(j)=F_i(j)*conjugate[F_i(j)] (Real)

A_G_i(j)=G_i(j)*conjugate[G_i(j)] (Real)

C_i(j)=F_i(j)*conjugate[G_i(j)] (Complex)

7) update values for coherence and phase spectra :

Co(j)=Co(j)+[C_i(j)*C_i(j)]/[A_F_i(j)*A_G_i(j)] (Real)

Ph(j)=Ph(j)+atan{Im[C_i(j)]/Re[C_i(j)]} (Real)

END OF THE BLOCK LOOP

8) compute mean values of coherence and phase spectra over the n blocks

Co(j)=Co(j)/n

Ph(j)=Ph(j)/n

The coherence spectra gives you the spectral normalized correlation (from 0 to 1) between f and g for each frequency.

If coherence largely differs from 0 for a given frequency, then look at the phase spectrum : it corresponds to the phase shift between f and g for this frequency.

Note that you have to read the FFT library documentation in order to determine the relation between the index j and the corresponding frequency .

If further informations are needed, look for instance at :

Numerical recipes, chapter 13 for Welch's periodogram method (autospectra only) http://www.numerical-recipes.com/nronline_switcher.html

or

S.L. Marple, Digital spectral analysis, Prentice-Hall, 1987

Hope this help

Pratap October 8, 2003 08:20

Re: Phase delay computation
 
Thanks alot I will try to do understand that. Pratap


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