Gravitational attraction formula

December 23, 2015

Keyword Images

Note: This model is unverified. It has not yet been tested and polished as thoroughly as our other models.


This project displays the common natural phenomenon expressed by the inverse-square law. Essentially this displays what happens when the strength of the force between two objects varies inversely with the square of the distance between these two objects. In this case, the formula used is the standard formula for the Law of Gravitational Attraction:

> (m1 * m2 * G) / r2

This particular model demonstrates the effect of gravity upon a system of interdependent particles. You will see each particle in the collection of small masses (each of the n bodies, n being the total number of particles present in the system) exert gravitational pull upon all others, resulting in unpredictable, chaotic behavior.


First select the number of particles with the NUMBER slider.

The SYMMETRICAL-SETUP? switch determines whether or not the particles' initial velocities will sum to zero. If On, they will. Their initial positions will also be randomly, but symmetrically, distributed across the world. If SYMMETRICAL-SETUP? is Off, each particle will have a randomly determined mass, initial velocity, and initial position.

MAX-INITIAL-MASS and MAX-INITIAL-SPEED determine the maximum initial values of each particle's mass and velocity. The actual initial values will be randomly distributed in the range from zero to the values specified.

The FADE-RATE slider controls the percent of color that the paths marked by the particles fade after each cycle. Thus at 100% there won't be any paths as they fade immediately, and at 0% the paths won't fade at all. With this you can see the ellipses and parabolas formed by different particles' travels.

The KEEP-CENTERED? switch controls whether the simulation will re-center itself after each cycle. When On, the system will shift the positions of the particles so that the center of mass is at the origin (0, 0).

If you want to design your own custom system, press SETUP to initialize the model, and then use the CREATE-PARTICLE button to create a particle with the settings set with the INITIAL-VELOCITY-X, INITIAL-VELOCITY-Y, INITIAL-MASS, and PARTICLE-COLOR sliders. Particles are created by clicking in the View where you want to place the particle while the CREATE-PARTICLE button is running. (Note, if KEEP-CENTERED? is On the particles will always move so that the center of mass is at the origin.)

After you have set the sliders to the desired levels, press SETUP to initialize all particles, or SETUP TWO-PLANET to setup a predesigned stable two-planet system. Next, press GO to begin running the simulation. You have two choices: you can either let it run without stopping (the GO forever button), or you can just advance the simulation by one time-step (the GO ONCE button). It may be useful to step through the simulation moment by moment, so that you can carefully watch the interaction of the particles.


The most important thing to observe is the behavior of the particles. Notice how (and to what degree) the initial conditions influence the model.

Compare the two different modes of the model, with SYMMETRICAL-SETUP? On and Off. Observe the initial symmetry of the zero-summed system, and what happens to it. Why do you think this is?

As each particle acts on all the others, the number of particles present directly affects the run of the model. Every additional body changes the center of mass of the system. Watch what happens with 2 bodies, 4 bodies, etc... How is the behavior different?

It may seem strange to think of n discrete particles exerting small forces on one other particle, determining its behavior. However, you can think of it as just one large force emanating from the center of mass of the system. Watch as the center of mass changes over time. In the main procedure, `go`, look at the two lines of code where each body's position (xc, yc) is established- we shift each particle back towards the center of mass. As no other...


Share this Post