3D fourier transform of vector field - ifft properties

조회 수: 14 (최근 30일)
Alexander T
Alexander T 2020년 3월 9일
답변: Tejaswini Veduruvada 2020년 3월 27일
The build-in ifft function is not doing what I'm expecting and I can't seem to figure out why. If I do my own ifft, it works but the problem is that it takes half an hour for 1 set and I would need to do it NxN more times (N=192).
My fourier modes are ordered as follows: 0,1,2.. N/2-1, -N/2, -N/2+1,...-2,-1
My physical coordinates are linearly spaced over [0, 2pi (1-1/N)] (physical box size is 2pi x 2pi x 2pi)
Does matlab use the same order of fourier modes?
How are the physical dimensions "x(n)" defined in matlab for the (i)fft? My own ifft knows it goes from 0 to 2pi (1-1/N), this seems unclear to me
I would expect that ifft(uk) would yield the same results as my own u_ifft but unfortuneatly it does not, hope my question is clear and thank you!
load('velo_physical.mat'); %loads the matrix u(x,y,z) which are velocities in 3D physical space(x,y,z)
load('velo_fourier.mat'); %loads the matrix uk(xi_x,xi_y,xi_z) which are the corresponding fourier modes
N=192; %size of matrices N x N x N
xi_x=[0:N/2-1,-N/2:-1]; %order of Fourier modes
xi_y=xi_x;
xi_z=xi_x;
x=linspace(0,2*pi*(1-1/N),N); %linear spaced physical coordiantes (L=2pi)
y=x;
z=x;
u_ifft=zeros(1,N);
Q=96; %Random number to check 1D velocity (in x-direction) at intersection xy-plane(z=Q) and xz-plane(y=Q)
tic
for m=1:N
for i=1:N
for j=1:N
for k=1:N
u_ifft(m)=u_ifft(m)+uk(i,j,k)*exp(sqrt(-1)*xi_x(i)*x(m))*exp(sqrt(-1)*xi_y(j)*y(Q))*exp(sqrt(-1)*xi_z(k)*z(Q));
end
end
end
end
toc
%% Check if correct %%
figure
plot(u(:,Q,Q))
hold on
plot(real(u_ifft),'r+')
u_2=ifft(uk);
figure
plot(u(:,Q,Q))
hold on
plot(real(u_2(:,Q,Q)),'r+')

답변 (1개)

Tejaswini Veduruvada
Tejaswini Veduruvada 2020년 3월 27일
Try using ifftn function
You can refer to the below link on how to use ifftn function.

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by