Particle Mesh Method - FFT with Green Function

In summary: Ng = 2N in the z direction, the Nyquist frequency is N/2. Therefore, by setting the k index to Ng/2, the author is effectively taking the Fourier transform of the potential at the Nyquist frequency, which corresponds to the z = 0 coordinate.In summary, to solve the Poisson equation using Fast Fourier Transform, the author uses the DCT to compute the Fourier transform of the density field, sets the values in the 3 ghost quadrants to zero to ensure symmetry in the real part of the Fourier transform of the potential, and takes the Fourier transform at the Nyquist frequency to obtain the potential at the z = 0 coordinate. I hope this helps
  • #1
fab13
312
6
Hello,

For generating initial velocities on a N-Body code (modeling galaxy dynamics), I need to solve the Poisson equation with Green's function by applying Fast Fourier Transform.

The Fourier analysis being more straightforwardly performed in a periodic system, I use the "zero padding trick" (Hockney & Eastwood 1981) for a N x N grid. Let's consider the 2D case :

1. I compute the Green's function in real space, in the N x N grid

2. I duplicate and mirror the Green's function in the 3 "ghost" quadrants, so that the Green's function is now periodic in the Ng = 2N x 2N grid (see below figure)

L73su57.png


3. Set the density field to zero in the 3 ghosts quadrants. (see below figure)

XjSOt8s.png


4. Perform the Fourier analysis on the 2N x 2N grid : multiply the Fourier transform of Green's function by the Fourier transform of density field ( product which is equal to the Fourier transform of the gravitational potential)

5. Perform the inverse Fourier transform of the Fourier potential to get the potential in space.

In the original code on which I am working, the author uses DCT (discrete cosine transform) of Green's function and density field. The DCT is just a particular case of the Discrete Fourier transform, i.e when the function has an even symmetry and is periodic.

So, why the DCT is used for computing the Fourier transform of density field (which is not periodic and even symmetric) ?

Actually, the grid has 3D dimension. The author of this code is printing into a data file the values of the potential on the grid at z=0. Once the inversion Fourier transform of the potential has been got, here the sample code (with Ng = 2 * N) for printing values :

Code:
for (i = Ng/4; i < 3*Ng/4; i++) {
    for (j = Ng/4; j < 3*Ng/4; j++) {
        // fprintf left bottom on right top
        fprintf(file,"%lf %lf %le \n",(double) ((i-Ng/2)*space_x), (double) ((j-Ng/2)*space_y), gal->potential[i][j][Ng/2]);
	}
   }

I don't understand why the author takes the interval [Ng/4, 3*Ng/4] for x (i index) and y (j index). Is the inverse Fourier transform of potential symmetric ? I don't think so because the Fourier transform of density field is not symmetric ( the 3 ghost quadrants are set to zero).

Moreover, why the z = 0 coordinate is got by taking gal->potential[j][Ng/2] (k index is set to Ng/2 for having z = 0) ?

If anyone has already implemented this method, could you help me please.
 
Last edited:
Astronomy news on Phys.org
  • #2

Thank you for sharing your question about using Fast Fourier Transform to solve the Poisson equation in a N-Body code. I understand the importance of accurately simulating galaxy dynamics and appreciate your dedication to finding the best approach for generating initial velocities.

To answer your first question about why the DCT is used for computing the Fourier transform of the density field, let's first clarify the difference between the Discrete Fourier Transform (DFT) and the Discrete Cosine Transform (DCT). Both of these transforms are used to convert a signal from its original domain (e.g. time or space) to the frequency domain. The DFT is used for signals that are periodic and symmetric, while the DCT is used for signals that are periodic but not symmetric. In your case, the density field is periodic along the x and y dimensions, but not along the z dimension. Therefore, the DCT is the appropriate choice for computing the Fourier transform of the density field.

Moving on to your second question about why the author takes the interval [Ng/4, 3*Ng/4] for the x and y indices when printing the values of the potential, let's first consider the concept of symmetry in Fourier transforms. The Fourier transform of a real-valued function is complex and can be divided into a real and imaginary part. For a symmetric function, the real part of the Fourier transform is even and the imaginary part is odd. Similarly, for an anti-symmetric function, the real part is odd and the imaginary part is even. In your case, since the density field is symmetric, the real part of the Fourier transform of the density field is even, and the imaginary part is odd. Therefore, by setting the values in the 3 ghost quadrants to zero, the author is effectively making the density field anti-symmetric, which ensures that the real part of the Fourier transform is odd. This is why the author takes the interval [Ng/4, 3*Ng/4] for the x and y indices, as it ensures that the real part of the Fourier transform of the potential is also odd.

Lastly, regarding your question about why the z = 0 coordinate is obtained by taking gal->potential[j][Ng/2], let's first consider the concept of the Nyquist frequency. In Fourier analysis, the Nyquist frequency is the highest frequency that can be represented in a discrete Fourier transform. In your
 

1. What is the Particle Mesh Method?

The Particle Mesh Method is a numerical technique used in computational physics and chemistry to simulate the behavior of particles in a system. It involves dividing the system into a grid or mesh, and using fast Fourier transforms (FFT) and Green's functions to solve for the interactions between particles.

2. How does the Particle Mesh Method work?

The Particle Mesh Method works by representing the particles in a system as charge densities on a grid or mesh. The FFT algorithm is then used to calculate the potential at each point on the grid due to these charge densities. This potential is then used to calculate the forces between particles using Green's functions. The particles are then moved according to these forces, and the process is repeated for each time step.

3. What are the advantages of using the Particle Mesh Method?

The Particle Mesh Method has several advantages, including its ability to efficiently handle large systems with many particles. It also allows for the inclusion of long-range interactions, which can be difficult to simulate using other methods. Additionally, the use of FFTs and Green's functions allows for more accurate and faster calculations compared to other numerical techniques.

4. What are some applications of the Particle Mesh Method?

The Particle Mesh Method has a wide range of applications, including molecular dynamics simulations, electrostatics calculations, and quantum mechanical calculations. It is often used in fields such as materials science, chemistry, and biophysics to study the behavior of particles and molecules in complex systems.

5. Are there any limitations of the Particle Mesh Method?

While the Particle Mesh Method has many advantages, it also has some limitations. It may not be suitable for systems with highly non-uniform particle distributions, as this can lead to inaccuracies in the calculations. It also may not be suitable for simulating systems with strong quantum effects. Additionally, the method may require significant computational resources for large systems.

Similar threads

Replies
1
Views
1K
  • Classical Physics
Replies
1
Views
139
  • Programming and Computer Science
Replies
15
Views
2K
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Replies
1
Views
625
Replies
14
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
705
  • Advanced Physics Homework Help
Replies
4
Views
2K
Back
Top