2
$\begingroup$

I am trying to compute the one-dimensional energy spectra for my channel-flow simulation. I have already written a post-processing script to achieve this; however, I need to validate my code before proceeding.

To do so, I am taking the two-point cross-correlation (per given plane) vector from a DNS database. Then, I am trying to apply my code and plot against the 1D energy spectra provided by the same database and in the same (homogeneous) direction.

I am always getting the wrong output, but I cannot figure out what went wrong. I have looked into several reference books and forum posts here and there with no tangible result as of yet.

The steps I am following are:

Given a two-point cross-correlation vector in the streamwise (i.e. x-direction) and homogeneous direction, I am applying the following (e.g. in Matlab form):

% where Ruu is the correlation vector from the DNS database
N = length(Ruu);
Nk = 2^nextpow2(N);

% Fourier transform data
Bx1 = zeros(Nk, 1); 

for k=1:Nk
    for n=1:N
        Bx1(k) = Bx1(k) + (1/N)*Ruu(n)*exp(-2i*pi*(k-1)*(n-1)/N);
    end
end

% wavenumbers initialization
kx = zeros(Nk, 1);
% total distance between correlations used
Lx = (max(x) - min(x));
for n=1:Nk
    % streawise coordinates to wavenumber
    kx(n) = pi*(n-1)/Lx;
end
% calculate 1D streamwise energy spectra
Eu = Bx1.*conj(Bx1); 

% show only first half due to symmetry
loglog(kx(1:end/2), 2*Eu(1:end/2))

The resulting figure, in case you were wondering, is depicted below. 1D energy spectra

The output of such a figure is nowhere near what I am looking for. Can someone shed some insight on the issue?


Reference DNS Data

Moser, Robert D.; Kim, John; Mansour, Nagi N., Direct numerical simulation of turbulent channel flow up to $Re_{\tau} = 590$, Phys. Fluids 11, No. 4, 943-945 (1999). ZBL1147.76463.

$\endgroup$
1
  • $\begingroup$ I am also trying to plot Euu. Your code is really helpful for me. Do you solve this problem? Thanks in advance! Kind regards, Guan $\endgroup$
    – 崔冠哲
    Jun 1, 2021 at 11:40

1 Answer 1

1
$\begingroup$

I think there is something wrong with your program.

First, the fft(u).*conjg(fft(u)) is equal to fft(R), R is 1 dimension the correlation function.

Second, when you do the FFT, there is no necessary to add in the:

Bx1(k) = Bx1(k) + (1/N)*Ruu(n)*exp(-2i*pi*(k-1)*(n-1)/N).
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.