NetLogo banner

 Home
 Download
 Help
 Resources
 Extensions
 FAQ
 References
 Contact Us
 Donate

 Models:
 Library
 Community
 Modeling Commons

 User Manuals:
 Web
 Printable
 Chinese
 Czech
 Japanese

  Donate

NetLogo User Community Models

(back to the NetLogo User Community Models)

SolarSystem

by Jerry James (Submitted: 02/18/2003)

[screen shot]

Download SolarSystem
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

(You can also run this model in your browser, but we don't recommend it; details here.)

This model mimics the solar system. Setup creates the sun, five planets, and a "comet". Unlike in the real solar system,
these orbiting bodies are in the same plane, and setup distributes the planets randomly. However, the planets are at the
correct relative distances from the sun and have correct relative masses. The comet can be placed up to 100 AU (an AU is
the distance from earth to sun, or Astronomical Unit) from the sun and assigned an "ellipticity" which adjusts its initial
velocity to result in a orbit that can range from a circle to an extreme ellipse.

As the model is run, the ratio of the current distance from the sun to the initial distance can be plotted for earth and
the comet. If the gravitational effects of all planets, in addition to the sun, are computed, earth's orbit can be seen to
vary slightly in ellipticity. If only the sun's gravity is considered, earth's orbit is still elliptical, but does not vary.
The orbit of the comet can vary greatly, depending upon how close and at what speed it approaches other planets or the sun.
Depending upon the initial positions of the planets and comet, and the comet's ellipticity, the comet could orbit indefinitely,
immediately be ejected from the solar system, or be knocked around into other orbits before being ejected.

The third plot, "Comet - Closest Planet Distance" plots the distance from the comet to Jupiter and/or Saturn when the distance
between them is within the range set on the sliders "Comet-Jupiter" and "Comet-Saturn" in AU. Whenever the comet comes within
this range of either planet, if a plot for neither planet was already in progress, the previous plot is cleared and a new one
started. This can give a good view of how the comet is moving with respect to these planets, and how close it actually gets,
when within the specified ranges.

To Run the Model

Just press Setup to use the default speed, distance of comet to sun, and comet orbit ellipticity. Other settings can be
changed during the run. Setup resets Zoom to 15, so setting it to another value initially isn't useful.

Press Go

Notes:

If you want a different speed, initial comet position, and/or ellipticity, make these changes before pressing Setup. Changing
these later has no effect.

The speed adjustment actually changes the size of time intervals at which the new planet positions are updated. This affects
the accuracy of the orbits. At a speed setting of 10 there are about 1000 updates of the position of the earth per
revolution of the sun, but only about 250 for Mercury. At a speed setting of 1 there are ten times as many updates per
revolution. The effects of speed settings on the orbit calculations can be seen by setting the Sun_Only switch to "on" and
observing the orbital plots for both earth and comet at different speed settings. The ellipticity of the earth's orbit
decreases as the number of updates per year increases. At higher ellipticity settings for the comet, which bring it closer
to the sun, its orbit should be repetitive if the Sun_Only switch is on, but at higher speed settings it may vary and even
become unstable due to insufficient updates where the comet's orbital path is making sharp turns. Note that when the Sun_Only
switch is "off" so that gravitational effects of the planets as well as the sun on the comet are computed, the comet may
come close enough to any planet, or the sun, to cause sufficiently abrupt changes in orbital direction that the time interval
represented by higher speed settings may be too large to compute its orbit correctly. Also, no provision has been made to
note the "collision" of the comet with a planet or the sun, so the resulting acceleration will almost certainly fling the
comet out of the solar system.

Setting the comet's initial distance from the sun to be near that of Saturn or Jupiter makes it easy to see the effects of these
large planets on the comet's orbit. The farther out the comet starts, the longer it is likely to take to see an obvious
interaction with a planet.

The Earth - Sun Distance plot is scaled according to whether the Sun_Only switch is on and the current Speed setting, so that
the changes are easily visible. The scaling is based on trial and error observation.

While the Model is Running

To increase the speed of execution without affecting computation accuracy, turn the display off by pressing Display On/Off.
This is a toggle which alternately stops the display from showing the changing planet positions, or resumes showing their
positions. When the display is off, you can follow the progress by looking at the "earth years" monitor which tracks the
number of orbits earth has made, and by looking at the plots of the earth's and comet's orbits.

You can change the distance between the comet and Jupiter and the comet and Saturn, with sliders "Comet-Jupiter" and
"Comet-Saturn", which will trigger the following:

If the display is off and the comet approaches within the slider set distances of either Jupiter or Saturn,
the display is turned on and execution is stopped for two seconds to aid in starting to visually track the comet's
orbit from that point.

The "Comet - Closest Planet Distance" plot will show the distance between comet and Jupiter and/or comet and Saturn,
either, or both as long as the distance is less than the slider setting. If the distance to either planet comes
within range and a plot is not already in progress, the previous plot is cleared and a new one started. This is
independent of whether the display was on or off.

To follow a comet's orbit when it goes off-screen, lower the Zoom value. Otherwise, when any orbiting body passes off-
screen, it is hidden until it comes back on-screen. Also, if you increase the Zoom setting so that you view fewer planets,
say only through Mars, execution speed increases.

The Plotting On/Off switch is obvious.

The Labels On/Off switch, can be used to display a label for each object in the solar system. The model then runs much slower.

The Sun_Only switch can be used to observe how the planets' orbits behave when all gravitational interactions are computed, or
when only the sun's gravitational pull is computed. For example, the comet's orbit will not be affected by close encounters
with any of the planets when the Sun_Only switch is "on".

Calculations

Computing the acceleration of object #1 towards object #2 due to gravity:

From F = ma = -GMm/r^2 and solving for the x and y components of acceleration a we get accx = -GMx/r^3 and accy = -GMy/r^3
where accx and accy are the accelerations in the x and y directions, x and y are the distances in x and y directions between
the objects #1 and #2, M is the mass of object #2 (the mass m of object #1 cancels out), G is the gravitational constant, and
r = sqrt(x^2 + y^2). G is expressed in terms of Astronomical Units, AU and earth masses, Me, giving units of AU^3/(Me sec^2).

Computing the inital conditions

After the planets are randomly placed at their proper orbiting distances from the sun, the initial velocities are computed
from the equation v = -sqrt(G*M/r) where v = tangential velocity. The velocities in the x and y directions are then
x-velocity = v * sin (angle) and y-velocity = v * cos (angle) where angle is reported from (towards-nowrap sun - 180).

The initial accelerations are computed as described above, with each planet having the effects of the sun's and all the other
planets' gravity on itself computed.

At each time interval a new x and y position for each planet and the comet is computed based on the x and y velocities for
that time period. Since the velocities at the beginning of the time interval increase by (acceleration * time) the
average velocity for each time period is used. For the first time period this is computed by adding to the initial velocity
the acceleration * time/2.

Updating planets' and comet's positions

This is just a matter of repeating the computations above of new accelerations added to current velocities in x and y
directions.

(back to the NetLogo User Community Models)