Assignment #3
Particle Mesh Code -Part I
For Friday March 21, your assignment is to create
the first part of a two dimensional particle mesh code.
This code will convolve a Green's function with a mass
distribution using forward and inverse FFT on a regular
rectangular grid. This is a moderately difficult assignment,
so please pay attention to the hints toward the end of
the problem description.
Problem Description:
- Map the Green's function on the grid.
- Map the Mass on the grid (see the test cases below).
- FFT the Green's function.
- FFT the mass distribution.
- Multiply the fft's components together element by element.
(Make sure to multiple the complex numbers correctly!!!!)
- Take the inverse FFT of the problem.
Easy as cake! Piece of pie! Ok... there are some tricky
details.
Problem Parameters
- You do NOT need to worry about mapping particles to the
grid or to worry about interpolating the potential for this assignment!
These steps come later. For now, manually set the mass
grid for some test cases (see below).
- Solve the problem on a 64 by 64 grid. All the mass
should be in a one 32 by 32 corner of this grid.
- The Green's function should be of the form
1/sqrt(r*r + eps*eps) where eps is a softening length
for the POTENTIAL. This is slightly different from a
softening length for FORCE, but behaves in much the same way.
- You may beg, borrow, or share the FFT routines from
"Numerical Recipes" or other platform independent libraries.
- You can work in a group of two, if you like.
- The final program should be a simple driver routine
with some subroutines. You will NEED to incorporate the
potential solving subroutines into part II of this project.
- Use a set of simple distributions to determine if the routine
is working. I strongly suggest looking at:
a. A single point mass in a random location in the grid.
b. A single point mass at the edge of the grid.
c. A single point mass at the corner of the grid.
d. A single point mass at near the center of the grid.
e. Two points at random locations on the grid.
All of these tests should give you the correct analytical
solutions to the problem. Be sure and check for symmetry and
correctness.
- The most difficult part of this project will be making
a Green's function which will reproduce the potential.
Be sure and use the symmetry properties to test your solution!
- I STRONGLY recommend writing a prototype code in
Mathematica, Matlab, or Maple. FFT routines are simple
calls in all these routines, and can be used to CHECK
your Green's functions and solutions. The final code
must be in C, C++, or Fortran and should be platform
independent. On student prototyped this problem using
Matlab in 14 lines!!!!
- Keep the idea of machine accuracy in mind when you write
this code. It is likely that a purely real FFT is not purely
real when it is done on a machine.
Graphics Output:
You need to produce some graphical output to document
the successfulness of your tests. You don't have to
do all the test cases.
Assignment requirements:
1. You must write this program in C, C++, or Fortran.
It must compile and run on a Sparc 10 workstation with
either the gnu C and g++ compilers or the standard
ANSI Fortran. If it compiles on the SGI machines,
it should compile on my workstation.
2. You should include instructions on how to compile this
code. A "Makefile" would be nice, especially if you
have multiple files and subprograms.
3. Graphics output may be created on any machine using
any graphics package, and turned into a postscript file.
You can also create Web pages and give me the URL.
4. You should write a short 1 page report documenting
the code and your results. This doesn't have to be fancy,
but it should summarize your work.
5. When you have completed the project, use the Unix
tar command to create a single file which contains:
documentation file (postscript, html, or text)
C, C++, or fortran program
Makefile and/or compilation instructions
graphics output file (postscript)
A short README file explaining what each file contains.
Hint: To create the tar file, put all your files into a single
directory on a unix machine. Go one level above this
directory and type:
tar -cvf username.tar directory
The file username.tar is the name of the newly created tar file.
The tar file names should be your email account with a number
indicating the assignment number. To extract the file,
type
tar -xvf username.tar
THE NAME OF YOUR FILE SHOULD BE YOUR USER ID FOLLOWED
BY THE ASSIGNMENT NUMBER!
6. Use anonymous ftp to leave the file in the
pub/nbody directory of
galileo.gmu.edu