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

correlation function vs tensor

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 2 Post By LuckyTran
  • 1 Post By LuckyTran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 26, 2022, 20:18
Unhappy correlation function vs tensor
  #1
New Member
 
Join Date: Mar 2022
Posts: 17
Rep Power: 2
loesung is on a distinguished road
* 1. Quick Problem Description:

My papers describe a 'correlation matrix', how can I get that, since matlab's xcorr gives a correlation in vector form? This is causing issues, because I have to multiply by the parameters r and r', as described below, and these parameters are the correlation's spatial value and spatial offset.

* 2. Full Background of Problem and Notation

I am doing a proper orthogonal decomposition (POD) of streamwise velocity data. For that, I compute

S_{i, j}\left(x, x^{\prime} ; r, r^{\prime} ; m ; f\right)

In other words, I find the correlation R_{i,j} then take the fft in both azimuthal and time directions. I found the correlation R_{i,j} in matlab using the built-in function xcorr.

matlab's xcorr is a function, but papers (1) indicate that is a matrix. Am I supposed to organize the correlation function in a matrix, for different spatial offset values?
In particular, the (r,r') notation is a bit confusing to me; later, I must calculate


S_{ij} = \frac{1}{2 \pi} \int_{-\infty}^{\infty} \sum_{0}^{2 \pi} R_{i, j}\left(x, x^{\prime} ; r, r^{\prime} ; \Delta \theta ; \tau\right) e^{-i(2 \pi f \tau+i m \Delta \theta)} \, d \tau \Delta \theta


where S_{ij} is used in,


\int r^{1 / 2} S_{i, j}\left(r, r^{\prime} ; m ; f\right) r^{1 / 2} \phi_{j}^{*(n)}\left(r^{\prime} ; m ; f\right) r^{1 / 2} d r^{\prime}


I guess r' is merely used as a dummy integration varaible, but it's throwing me off (because r' is the second variable in the correlation matrix).
Again, S_{ij}, for say i=j=3 \Leftrightarrow \text{streamwise direction} is a function only (after all, xcorr is a function of twice the length, plus one, of the origional vectors); how are you going to get a matrix out of that? Are the different lag-positions the different matrix elements? Still, this seems like not a matrix, just a vector.

* 3. Possible Solution:

I've read elsewhere that for a statistically stationary signal, the cross-correlation of a signal is given by a Toeplitz matrix (basically, a highly specific symmetric matrix), whose entries are the correlation fucntions at different points.


* Possible Solution 2


wikipedia gives for cross-correlation the matrix,

\mathrm{R}_{\mathbf{X Y}}=\left[\begin{array}{cccc}\mathrm{E}\left[X_{1} Y_{1}\right] & \mathrm{E}\left[X_{1} Y_{2}\right] & \cdots & \mathrm{E}\left[X_{1} Y_{n}\right] \\ \mathrm{E}\left[X_{2} Y_{1}\right] & \mathrm{E}\left[X_{2} Y_{2}\right] & \cdots & \mathrm{E}\left[X_{2} Y_{n}\right] \\ \vdots & \vdots & \ddots & \vdots \\ \mathrm{E}\left[X_{m} Y_{1}\right] & \mathrm{E}\left[X_{m} Y_{2}\right] & \cdots & \mathrm{E}\left[X_{m} Y_{n}\right]\end{array}\right]

What is this matrix in terms of xcorr? My guess is that, in terms of autocorrelation on the streamwise variable in the radial direction,

\mathrm{R}_{\mathbf{w w (streamwise)}}=\left[\begin{array}{cccc}\mathrm{xcorr}\left[r_{1} r_{1}\right] & \mathrm{xcorr}\left[r_{1} r_{2}\right] & \cdots & \mathrm{xcorr}\left[r_{1} r_{m}\right] \\ \mathrm{xcorr}\left[r_{2} r_{1}\right] & \mathrm{xcorr}\left[r_{2} r_{2}\right] & \cdots & \mathrm{xcorr}\left[r_{2} r_{m}\right] \\ \vdots & \vdots & \ddots & \vdots \\ \mathrm{xcorr}\left[r_{m} r_{1}\right] & \mathrm{xcorr}\left[r_{m} r_{2}\right] & \cdots & \mathrm{xcorr}\left[r_{m} r_{m}\right]\end{array}\right]


so, basically just rearrange each of the 2*m -1 entries of the vector given by xcorr(), is this the correct approach?



But, Should I be using matlab's xcorr2() ? I don't think so, but just dont know how to express the matrix by using xcorr ! Since i've been considering only the streamwise vector component w, then i have a vector, but if i consider the full components (u,v,w), then xcorr is a matrix, right? If i want to correlate in the radial direction only, over all 3 vector fields, will this still use xcorr2(), or just xcorr() ?



* Link to Source Material


* Image of paper page: https://i.imgur.com/rZpBM7R.png
* Paper (1) url (publicly available): https://arc.aiaa.org/doi/pdf/10.2514/1.31074
* matlab xcorr documentation https://www.mathworks.com/help/matlab/ref/xcorr.html
loesung is offline   Reply With Quote

Old   April 26, 2022, 21:44
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 4,850
Rep Power: 57
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Velocity is a vector. In 3D it has 3 components x,y,z (or u,v,w). The correlation tensor consists of 9 pairwise correlations: Ruu,Ruv,Ruw,Rvu,Rvv,Rvw,Rwu,Rwv,Rww. Of course only 6 of them are independent. If you have a 2D or 1D vector then you get subsets of these.

When you read material that discusses cross-correlation for fluid problems, pay attention to whether they are define cross-correlation as between scalars or between vectors. The notation has to change accordingly.


Matlab's xcorr operates on pairs of scalar variable. But to add to the confusion.... the default memory structure of a ranged variable in matlab is a vector. This is a memory vector, not a physical velocity vector. It's two different kinds of vectors. xcorr2 also takes correlations between two scalars except it allows for 2D memory structures.
LuckyTran is online now   Reply With Quote

Old   April 28, 2022, 11:46
Smile
  #3
New Member
 
Join Date: Mar 2022
Posts: 17
Rep Power: 2
loesung is on a distinguished road
Thanks for your reply, that part is clear now!

Does it matter what order I take fft and xcorr in? Meaning, if i take fft in x, and then xcorr in r, that is , exactly the same as taking first xcorr in r, then taking fft in x?


Also, if the flow direction is in x-dir, then I should get almost the same POD modes (eigenvectors) if I just use S_{rr}, instead of the full correlation components?
loesung is offline   Reply With Quote

Old   April 28, 2022, 13:12
Default
  #4
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 4,850
Rep Power: 57
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
The convolution theorem gives you the relationship between the cross-correlation and fourier transoform.


Also the subscript and index for the correlation tensor and shape function (i,j,k) is x,y,z or u,v,w; it is not r. r is an argument.

If velocity is in x,y,z and you close your eyes and pretend there is no y or z velocity and do the POD, then you calculate a subspace of POD modes, you calculate only one of the eigensubspaces.
LuckyTran is online now   Reply With Quote

Old   April 28, 2022, 19:36
Default
  #5
New Member
 
Join Date: Mar 2022
Posts: 17
Rep Power: 2
loesung is on a distinguished road
Okay, so can I even use xcorr here (in radial direction), along with two applications of fft in x and \theta, in order to get S_{ij}? where

S_{i j}=\frac{1}{2 \pi} \int_{-\infty}^{\infty} \sum_{0}^{2 \pi} R_{i, j}\left(x, x^{\prime} ; r, r^{\prime} ; \Delta \theta ; \tau\right) e^{-i(2 \pi f \tau+i m \Delta \theta)} d \tau \Delta \theta

Or must I multiply the twice fourier-transformed signals by each other, one of them being complex conjugated (and therefore using matlab's xcorr would be invalid)?

Currently, it seems that I can use either xcorr, or if one alternately wishes, multiply the twice fft'd signals by each other (one of them being * conjugated)..

Last edited by loesung; April 28, 2022 at 22:01.
loesung is offline   Reply With Quote

Old   April 29, 2022, 07:54
Default
  #6
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 4,850
Rep Power: 57
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
I recommend you to look at the user manual at what xcorr actually does... It takes the fft and....

Almost nobody brute forces the cross correlation calculation using a sliding inner product because it's operationally very very very slow.


Following this, I also recommend you to read up on POD instead of blindly following the method proposed in one single paper which is described for a very specific scenario where the system is homogeneous about theta. In particular, you need to understand how to set up the eigenvalue problem.
aero_head and loesung like this.
LuckyTran is online now   Reply With Quote

Old   April 29, 2022, 14:57
Default
  #7
New Member
 
Join Date: Mar 2022
Posts: 17
Rep Power: 2
loesung is on a distinguished road
Yes, I printed out matlab's xcorr code and stepped though it as well. Actually, I had to modify it, multiplying each signal x_i and y_i by \sqrt{r_i}.




Note also, this book suggest I do not have to calculate xcorr at all, in order to get the cross power spectral, that is done instead via circulant convolution/correlation:



Also, I agree with not myopically reading one paper. So in my case i have read 80+ POD papers so far (the paper I posted was one of the ancillary papers), and several signal processing books

I posted here to completely remove my FUD, after compiling and reading about 30 POD and xcorr related posts on the cfd-online forum! Thanks

Last edited by loesung; April 29, 2022 at 17:23.
loesung is offline   Reply With Quote

Old   April 29, 2022, 19:15
Default
  #8
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 4,850
Rep Power: 57
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
You say you have read 80+ POD papers. Cool, so you are well-versed in POD. You say you have read the documentation for xcorr. Cool, so you know how xcorr works. You're asking if it is okay to not use xcorr and instead just take the Fourier transforms... But xcorr does exactly that!

It's like saying given f(a,b)=a*b, instead of calculating f can I just multiply a and b instead? I don't know what to tell you.

Now if you're wondering why xcorr does not actually calculate any correlation... it's because the Convolution Theorem tells you they are equivalent + the first F in FFT means fast.
loesung likes this.
LuckyTran is online now   Reply With Quote

Old   April 29, 2022, 20:00
Default
  #9
New Member
 
Join Date: Mar 2022
Posts: 17
Rep Power: 2
loesung is on a distinguished road
you are perfectly right. f= a*b , I like that Even though this is quite elementary, there's still a lot of moving parts, but I think I have it now. Thanks for your helps
loesung is offline   Reply With Quote

Reply

Tags
correlation, matrices, turbulence

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Tensor - function error Tushar@cfd OpenFOAM Bugs 0 January 17, 2015 23:19
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 05:42
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 04:37
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10:23
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


All times are GMT -4. The time now is 03:48.