Friday, August 21, 2009

Simulating Gravity -- Part I: Some Basics

There are many canned programs out there in the marketplace that teachers can download and use to illustrate physics problems or principles, such as projectile motion. But what do the students learn from this? They play games all day long and never realize that the reason that their "characters" move about and jump over canyons along (hopefully) parabolic trajectories is because someone programmed in that detail of the motion into the software. So, let's have the students do that themselves!

Many programming environments are freely (or easily) available in which examples can be built up using first principles learned in the classroom; let the students “see for themselves” the laws of physics in use. For example, spreadsheet programs, like Excel, Numbers, Lotus, etc. (and their variants), make it easy for values of one 'cell' to be computed based upon the numbers input into previous cells. Editing features, like copying formulas from a line of cells into the cells in the line directly below, are easy and ideal for generating iterative calculations.

Let's look at an example...

Consider the motion of a particle undergoing free fall. Make a table, such as shown here. Starting with some "initial conditions" (x,y, etc. at time t=0), compute the values at subsequent times by calculating x, vx, etc. after a time dt, as indicated.















Next, create such a table in Excel (say) and let the program do the work...

An example Excel spreadsheet can be found here ( FreeFall.xls ).

By selecting the horizontal (x) and vertical (y) position numbers you want to plot, one can typically have the program make a grap, and voila!:


Here is a picture of what one would see in Excel:



So, the students not only see the result (hopefully, a parabolic trajectory!), but they see that it's simply the application of some simple relationships that they learned in class and can easily remember -- dv = a dt, dx = v dt, and so forth. One can explain how "dt" needs to be chosen to be small enough to make it a smooth, "continuous" variable, and so forth. (In fact, make dt too large, and see what happens!)

There is so much that can be learned and discussed from this simple exercise; plus, the students will learn a basic skill -- how to use a spreadsheet program to do more than balance a checkbook (do students even do THAT anymore?); a skill that they can use in college and beyond.

Once you get this far, it's a simple matter to extend the concept to a more complicated situation, but one which is still easily performed by the student -- let's try a planetary orbit around the sun! We're actually most of the way to being able to do this calculation using the spreadsheet we developed above. All we need to do is to modify the cells that contain the acceleration -- that is, modify our description of the force acting on the particle (planet, or satellite in this case).

The figure below provides a way of seeing the relationships, and the x and y accelerations can be easily computed from Newton's Universal Law of Gravitation:

Rather than using MKS units (meters, kilograms, seconds), it might be easiest to use units of "astronomical units" (average distance from earth to the sun), solar mass, and years (AU, Msol, yr). In this case, Newton's constant becomes:

G = (2 pi)^2 (AU^3)/(yr^2 Msol) = 39.4784 (AU^3)/(yr^2 Msol)

[It's easiest to see this if you consider purely circular motion of a planet around the sun.]

So, we input these relations into our "cells" that describe particle acceleration, and -- instantly -- the spreadsheet gives a plot of the result (see the file: PlanetOrb.xls ):

To start with, have the particle begin on a circular path. (This is the default condition in the spreadsheet.) How did we guess our initial conditions? By our choice of units they're simply:
  • x0 = 1 AU, y0 = 0 AU; vx0 = 0 AU/yr, vy0 = 2 pi AU/yr -- try it out!
Next, try the following:
  • x0 = 2 AU, y0 = 0 AU; vx0 = 0 AU/yr, vy0 = 1 pi AU/yr -- did you get an ellipse?
How about:
  • x0 = -25 AU, y0 = 3 AU; vx0 = 5 AU/yr, vy0 = 0 pi AU/yr -- did you get a hyperbola?

Lastly (for today), can you use the spreadsheet to estimate the escape velocity from the earth's orbit?

ANS: "Launch" a particle from a distance of 1 AU. Start out with a speed of 2 AU/yr, and plot x vs. t. Do you see the particle "turn around"? Gradually try increasing initial speeds until the particle appears to fly off "forever" (always increase x with time). What minimum speed is required to "escape"?
Try:
  • x0 = 1 AU, y0 = 0 AU; vx0 = 2 AU/yr, vy0 = 0 AU/yr
  • how far does the particle get before it "turns around"?
  • next, increase vx0 to 3 AU/yr, 4 AU/yr, etc.; how far now?
  • what should the answer be?
  • ... compare with v_esc = sqrt( 2GM/R)!
The above exercises could easily be broken up into about 2 class periods or more, depending upon how far the teacher wants to take this, what questions are answered, etc. But next time we'll take what we've learned and try to analyze a more specific problem.

Coming up: Let's program our computer to calculate a "trip to Mars"!
We can do this!

[Speaking of Mars: what's up with these emails about Mars' closest approach, and being "as big as a full moon," and not happening again for "5000, maybe 17,000 years"?? I see these posts every year (since the real "closest approach" that happened in 2003, and won't happen again until 2020). And the latest one says that Mars will appear as big "as the full moon"! What bunk!]