
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A problem set for astr 5540, a graduate-level astrophysics course, which involves writing a 1-dimensional gravitational particle-mesh (pm) code using functions such as a cloud-in-cell (cic) smoothing window, wavenumber of a fourier mode, mesh density given particle positions, fft of mesh density, potential given density in fourier space, acceleration given potential in fourier space, fft acceleration back on to the mesh, and acceleration at particle positions given mesh acceleration. The problem set also requires implementing a leap-frog integrator for the positions and velocities of particles and integrating and plotting the positions as a function of time.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

ASTR 5540 Math Meth Fall 2008. Problem Set 9. Due Mon Nov 3
In the language of your choice (IDL, Mathematica, c, ...), write a 1-dimensional gravita- tional Particle-Mesh (PM) code. Choose whatever units of length, mass, and time make programming easiest.
(a) Functions
Your code should contain functions that implement the following:
wavenumbers are { 0 , 1 , 2 , ..., [N 2 ], [N 2 ]+1−N, ..., − 2 , − 1 }. FFTs that input a real array typi- cally return {˜a 0 , Re ˜a 1 , Im ˜a 1 , ..., Re ˜a[ N 2 ]}, in which case the wavenumbers are { 0 , 1 , 1 , ..., [N 2 ]}.
Function 5 should set the zero’th Fourier mode of the potential to zero, φ˜ 0 = 0. Function 6 should set the zero’th and [N 2 ]’th (for even N ) Fourier mode of the acceleration to zero, ˜g 0 = ˜g[ N 2 ] = 0. The sign of the acceleration ˜g in Fourier space depends on the phase con-
vention of the FFT; for example mathematica’s phase convention is minus the convention adopted in class.]
(b) Leap-frog integrator
Implement a leap-frog integrator for the positions x and velocities v of particles:
vi+ 1 2 = vi− 1 2
where ∆t is a suitable time step.
(c) Integrate and plot
Choose a reasonable mesh-size N. Choose a small number of particles, say 2 to 4. Give the particles random initial positions, and zero initial velocities. Choose a time step ∆t. Integrate for a sufficient number of steps, at least 100. Plot the positions of the particles as a function of time t.