1
$\begingroup$

I am having trouble understanding how to set up the grid in the Fourier domain, while performing Discrete Fourier Transforms. This might be a very trivial question, but I'd appreciate any help understanding this problem.

I am trying use Fourier transforms to model the propagation of an electric field through space. The steps that I need to perform are:

  • Take the Fourier transform of $f(x, z = 0)$ to obtain $f(k, z=0)$
  • Multiply $f(k)$ by $\exp[i\,k_z\,d]$ for some propagation distance $d$ with $i = \sqrt{-1}$. Here k_z is defined as:

$$ k_z = \sqrt{k^2 - k_x^2} $$ where $k$ is the known wavenumber.

  • Inverse Fourier Transform back to obtain $f(x, z=d)$

I have set-up my grid for the x-dimension but I do not understand how I should go about setting up the grid for the k-dimension.

My approach (as obtained from the section on FFT in Computational Methods in Physics by Joel Franklin):

My $x$-grid is defined as $x_i = i\,\,dx$ for $i \in [0,N-1]$ for some number $N$. Now, I define the $k$ space with $k_j = j \times dk$ such that $dk=\frac{1}{dx \,\,N}$. This grid was created to obtain the max value of k allowed by Nyquist's theorem. Then, I execute the following:

(*fields is a list of the values of the field on the x-grid*)    
klist = Table[n*dk, {n, -NN/2 , NN/2}];   
four = Fourier[fields];
final= InverseFourier[
   Table[four[[i]]*Exp[-I*d*Sqrt[k^2 - kxlist[[i]]^2]], {i, 1, 
     Length[four]}]];

The output of the above code does not give me expected results for the what the field looks like at various distances. I would appreciate any explanation about where the definitions of setting up the k-grid come from and also if someone can point out mistakes in my implementation.

Thanks

$\endgroup$

marked as duplicate by Simon Woods, Michael E2, RunnyKine, Öskå, m_goldberg Aug 6 '14 at 1:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Minor note: N is a protected symbol (used for numerical conversion), so use n instead. $\endgroup$ – DumpsterDoofus Aug 5 '14 at 21:12
  • $\begingroup$ The FFT outputs positive frequencies first, from zero up to Nyquist, then negative frequencies. See the linked question for more details. $\endgroup$ – Simon Woods Aug 5 '14 at 21:49
  • $\begingroup$ This one may also help. $\endgroup$ – Simon Woods Aug 5 '14 at 21:51
  • $\begingroup$ One question: You say you multiply by $\exp(i k d)$, but then in your code you multiply by Exp[-I*d*Sqrt[k^2 - klist[[i]]^2]]. Which one is correct? $\endgroup$ – DumpsterDoofus Aug 5 '14 at 22:25
  • $\begingroup$ @DumpsterDoofus Sorry about the confusion. I should have been more clear about my definition of k. I want to multiply by exp(i(kz)d) such that kz = Sqrt[k^2 - kxlist[[i]]^2]]. Here, kxlist and kz represent the x and z components of the wavenumber k. I have made the edits to the question. $\endgroup$ – Sandesh Aug 6 '14 at 13:49
0
$\begingroup$

In Mathematica, given a list of datapoints $\mathbf{f}$ whose spatial axis has separation $\Delta$ (or whose temporal axis has time-step $\tau$), $\mathbf{\tilde{f}}=\text{Fourier}[\mathbf{f}]$ is a list of datapoints whose $j^\text{th}$ datapoint corresponds to angular spatial frequency $$k_j=\frac{2\pi(j-1)}{N\Delta}.$$

So for example, the first element of $\mathbf{\tilde{f}}$ corresponds to the zero-frequency (or DC) component, the second corresponds to the component with spatial frequency $2\pi/(N\Delta)$ (in effect, one oscillation per the entire length-$N\Delta$ interval), etc.

$\endgroup$
  • $\begingroup$ Thanks. This makes things clearer. But the list that I created using you're definition keeps growing well beyond the Nyquist limit (1/(2 dx) = 5 for this case). Here is my definition klist = Table[(2 [Pi] (i - 1))/(NN dx), {i, 1,NN}]. When I ListPlot klist, I get a straight line growing with increasing n values and reaching values upto 30. I thought the max value given by the Nyquist limit should have been. $\endgroup$ – Sandesh Aug 6 '14 at 14:54

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