This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 140 Assignment 3: Simulating the Nbody Problem Assigned January 19, 2010 Due by 11:59 pm Monday, January 31 This assignment is to write an MPI program to simulate a large number of astronomical bodies (stars and planets) moving under the influence of gravity. You will write a parallel routine to generate the initial data in place, already distributed across the processors. For grading purposes, both correctness and performance (speed and scaling) will count. 1 Background Kepler and Newton showed that two bodies orbit around each other in elliptical paths, in the absence of any other influence. For systems with three or more bodies, however, there is in general no closedform equation for the paths they follow. Therefore, cosmologists need to use simulation to understand such phenomena as galactic evolution. (It’s hard to set up a lab experiment with actual galaxies!) We start with n bodies whose masses, positions, and velocities we specify. The basic nbody computation is to compute the force that each body exerts on each other body ( n 2 forces in all); then compute how the sum of the forces on each body accelerates it (that is, changes its velocity); then compute, for each body, where it will move during a single “time step” at its new velocity. We repeat this computation over and over again, simulating one time step per iteration. The simulation isn’t perfect, because we pretend that the velocities don’t change in the middle of a time step; but we can make it more accurate by taking smaller and smaller time steps. Here are the mathematical details. Suppose the n bodies have masses m 1 , m 2 , . . . , m n (in kilograms); the initial position of the ith body in 3dimensional space is ( x i , y i , z i ) (in meters); and that the initial velocity vector of the ith body is vectorv i = ( vx i , vy i , vz i ) (in meters/second). The force between bodies i and j comes from the gravitational law, f = Gm i m j /r 2 , where r is the distance between them (in meters) and...
View
Full
Document
This document was uploaded on 02/22/2011.
 Spring '09

Click to edit the document details