Stellar+Dynamics+-+N+body+Sims

= Stellar Dynamics -- Introducing Students to N-body Simulations = **Author:** Meagan & Andy, 2011 **Purpose:** Introduce students to the necessity of computational thinking in astronomy. **Materials:** [|Handout] vpython - The simulation of stars interacting is an example that comes with Vpython when you download it - it is called stars.py. Vpython can be downloaded here: @http://vpython.org/index.html. **Plan:** **Part I.** First, after stressing the point that all things with mass are affected by gravity, we gave them a handout with a diagram showing 6 stars. We discussed the idea that every star has a gravitational interaction with every other star, and they had to figure out how many such interactions there are among the six stars. They made a prediction, then drew lines connecting all stars to represent each interaction. We discussed student predictions, and the thinking behind their predictions. Then there was a second diagram, where those 6 stars had moved a bit due to gravity, and we added a 7th star. Many students picked up on the pattern fairly quickly, but students had different ways of arriving at the correct answer (e.g. for 7 stars, Add 6+5+4+3+2+1 = 21, or 7*6/2 = 21, etc.) It was fun to see their thinking process. We got to the point where we had a formula that we could apply to calculate the gravitational interactions for N stars: N*(N-1)/2. I estimated for them how long it would take to do all these calculations by hand, for a smallish cluster of 1000 stars (just under a year's worth of time) and for a large cluster of a million stars (almost a million years of time!). This led nicely into the idea of using computers to help...

**Part II.** I found a Vpython simulation (Visual Python) of stars interacting gravitationally (it is one of the examples that comes with Vpython when you download it). It provides a visualization of the interacting stars as it runs...it is very nice, and was a great tool for teaching this topic! I started off by asking the students what they knew about programming - who knows what a computer program is? who has done any computer programming? Answers varied. In one or two classes, a student was able to give a simple explanation of what a program was. There were a few students who had done some programming. In some classes, nobody could give a definition of a computer program. After having motivated the need for computers when there are many calculations to be done, too many to be done by hand, I showed them the actual code and ran through it briefly. There was an "Initialization" section, where the number of stars was set (I made them explain that line to me), the coordinate axes were set up, numbers that would be used often were designated variable names, etc. In the "Setup" section, they could kind of see how the stars were place on the screen initially - randomly - because they could see the word random written repeatedly (we had explained this as we ran the simulation a few times...each time was a little different, and some simulations turned out to be much more interesting than others). Finally, in the "Interactions" section, the gravitational forces between all the objects in calculated, and the stars are moved one step accordingly. I tried to explain that the seemingly continuous animation they saw was really more like a bunch of snapshots of the stars, strung together, by linking it back to the first activity - two consecutive snapshots of the positions of all the stars. In one class, they asked me to change the number of stars to 1000...this was great, because the simulation slowed down significantly with the huge jump in the number of calculations per timestep - it didn't look so smooth anymore. **Part III (this was done much later in the year)** As part of the gravity deforms space-time and black hole session:

Stretch the rubber sheet, place a heavy mass on the sheet, and see how smaller objects are deflected when they go near the BH. It's a good demonstration for visualizing how masses deform spacetime, and how other masses respond.

Then, we used magnets underneath the sheet to position about 6 masses in random positions. We released a smaller ball and watched how it interacted with the stationary masses. We got some cool stuff to happen - the ball would orbit around one mass, then move on to another, then slingshot to another mass, then finally get trapped in a final resting place next to one of the masses. The trajectory would be very different every time. Sometimes, it would just get caught with one ball and get trapped, other times it would encounter 2-5 masses before getting trapped.

The students would comment (if asked) that this was like a star cluster. The star is affected by the gravity from all the other stars, and it moves around because of them. This was a lot of fun!