title>CS267/Sp1995 Assignment 2

U.C. Berkeley Department of Electrical Engineering and Computer Science
CS267 Sp95
Assignment 2: Due Thursday, February 9, 1994

Your assignment is to solve the Sharks and Fish 1 & 2 problem, i.e. fish swimming around in an ocean subject both to external current and gravity. You should modify existing matlab and CM Fortran code on rodin in /usr/castle/share/proj/shortcourse/wator. You should not run the matlab code on rodin, but on your own workstation, so rodin does not get loaded (matlab should run everywhere). There are pointers to the code that you can click on in Lecture 4.

It is harder to test your implementation to see if you answers are accurate in a simulation of this kind, because it is less clear what the "right" answer is supposed to be, unlike matrix multiplication. You should try 2 test cases:

  • Case 1. Choose the "current" function so that it points directly away from the origin at every point in the plane (as though there were a big faucet at the origin). Arrange several equally heavy fish so they are initially equally spaced on a circle around the origin, and at rest. If the magnitude of the current exactly matches the gravitational attraction to the origin, the fish should stand still. Do they?
  • Case 2. In the absence of a current but presence of gravity, several fish held equally spaced on a circle and at rest will starting falling straight towards the center, pass through one another (no collisions yet in this simple version of Sharks and Fish), and decelerate until they come to rest exactly as far apart as they started (conservation of energy). Then the process repeats. Now add a current which is constant everywhere (i.e. same direction and magnitude everywhere). The simple periodic picture of falling together and moving apart should now just move with the current, but not otherwise change. Is this true? Note that the numerical approximation we use to follow the fish paths (Euler's method) may also distort the fish paths, so you can't expect them to follow their ideal trajectories.
  • In addition to looking at nice pictures produced by the code, and turning in a picture of the fish after several "together and apart" cycles from Case 2, you should time the CMF code, and compute the speedup and efficiency. For this, remove the I/O, and time only the main loop of the program. Is the speedup what you expect?

    Assignment 3 will be exactly the same, but using the CMMD library and the Split-C language.