Motion in the gravity field. Start a system of planets and feel free to modify it!
Javaseminar of the Department of Physics at University of Kaiserslautern (Summer1999)
Led by Prof. Dr. H. J. Korsch and Dr. Martin Menzel
Project of Christian Anders and Markus Kupich

Opening Simulation in seperate window.
Don't worry about empty space, applet needs loading-time!

Powered by Runge-Kutta-algorithm of the 4th order.
German Version+++Detailed Instructions +++German Instructions+++Exercises, Links & Literature+++Presentation

[Reset] helps if the applet is dead.
[ESC] Aborts any procedure you did not want. Alternatively you can press ESC on the Keyboard.
[Scrollbars Speed/WfR] The upper one it to fit amination speed to CPU-performance. [>]faster [<] slower. The lower one controls waiting-time for adaptive computation. s. below.
[-][<->][+] Remove, modify or add an object of the selected planetary system. [+P] has direct acces to orbit parameters.
Zoom by  [In] and [Out] around [Rescale] in the lower panel.

Menue of Motion: Select from list                                  The applet will also run on LINUX-Systems if Java is installed correctly!!!
[Inner Solar System] Sets the parameters of the inner solar system: Sun, Mercury, Venus, Earth and Moon. (visible in detail by selecting Earth as Center by [CE] and zooming in by [F3]. The Moon's orbit suffers from too large integrating steps. You can construct the entire solar system adding the further planets by [+] and accepting all default parameters with [Input]. Zoom out to see them all. Remove the Moon and Mercury by [-] to be able to make greater steps by key [F1] ( = faster Animation)
[Sun & One] One planet flying around the Sun in an elliptical orbit. Zoom down to Sun by [F3] to see that it is also moving, mirroring the ellipse of the planet.
[Mars Mission] Shows the Hohmann orbit to Mars.
[Sun Jupiter Comet] A Comet on a hyperbolic trace being transferred into an elliptical orbit by the gravity-force of Jupiter.
[Swingby] How the Voyager spaceprobe left the Solar System, gaining gravitational Energy by Jupiter and Saturn.
[Trojans] Jupiter, the Trojans and the Greeks at the Lagrangian-points L4/L5 moving synchronously around the Sun. You can change the mass-ratio between 'Jupiter' (Secondary) and 'Sun' (Primary) to see that Trojan traces are only stable if MJ<3.85%(M J+MS). MJ: Jupiter's mass, MS: Sun's mass. By pressing the Button [B] and selecting Secondary as target of the "baseline" you switch to a coordinata-frame rotating with the Secondary. The Trojans keep their location in this frame.
[Double Star System] set the configuration of the fictional double-star-system 'Wadejia' . The star Fliurea has 2.58 *Sun-mass and the star Wetron has 0.08*Sun-mass. (The lower limit to be a shining star). The displayed planets Wirgon, Skorpion and Wischa have stable orbits. Remove Wirgon's Moon Lunarion by [-] to be allowed to use greater integrating steps (by key F1). If you want to add objects by pressing [+] the predefined positions of the inner planets Arda, Agnesia, Taura and Lea are designed for the yellow star Wetron in the 9 o' clock position (initial position, western of the origin.) You may add them at any other configuration anyway, but than you won't get the planed configuration. They are not activated altogether at initialization since 12 objects would make the Applet terribly slow! (If you're not an owner of a Pentium-III with more than 500 MHz....).
[Two equal Masses] creates two stars with Sun's mass orbiting at Sun-Mercury distance. Place the planets yourself by using [+] and the Mouse. Orbits will by stable if the planet is initially placed close to one of the stars or far to both. Try other start configuration, too! You have to add planets yourself, since in nature planets would not "condense" in such systems. Pay attention to inegrating stepsize: Close orbits cause high speeds, so it may be useful to make the integrating steps finer by key [F2]. The best you switch to addaptive stepsize by button [A]
[Alpha Centauri] Creates the configuration of Alpha Centauri's two main components orbiting in ~81 years at 12-36 AU around each other. Planetal orbits up to Mars-distance from one of the stars are stable. Just try it!
[Earth's companions] A few objects coming close to our planet...
[Start]/[Run!] Starts the Simulation.
[Stop] stops the simulation and returns actual values of positions, speeds, accelerations, energy and semi axis of the planets. If there are more than 2 objects the semi axes are only approximations. Press [Stop] before selecting a new menu item to avoid garbage on the screen. Alternatively you can type [PAUSE] or [F9] on the Keyboard. After pausing you can continue by pressing [Run!] or by typing [F12] on the keyboard

[<->] is to change orbiting parameters [+] adds objects. [+P] has direct acces to orbit parameters.
[Scalar Scrollbar] in the right upper corner sets the scalar values used in parameter setting procedure or for example to [Rescale] the current extension (see at the coordinata frame) by. A "well formated" number in the white field beside will be taken as scaling factor instead. Alternatively zoom in by the Key [F3] and zoom out by [F4] by a factor 2. (Pressing the key [F5] enters the set scaling factor for the white field, too)

You can [Run]/[Start] the simulation when the status "Ready" is displayed in the right corner of the lower panel. Do not press [Stop] (Alternatively [PAUSE] or [F9]) to often, numerical miracles might occur.
Pressing [C] at the right edge of the screen clears screen to remove obsolete traces. Or Press the [F6] Key.
To get back the picture when it disappears by some reason click somewhere into the applet-Window.

If you do not believe in what Galileo Galilei said you can return to the geocentrical frame by selecting Earth as Center after pressing [CE]. Have fun watching the Epicycles:-)
To return to the center of mass frame, select the number of obejects n as center number c (that comes from c-convention: the system-array is filled while i<n, so c >= n is used for centers that are not stars/planets). After pressing [Input] the accepted center number c will also be shown on the Status-field in right lower corner.

Zoom by  [In] and [Out] around [Rescale] in the lower panel.
The [exterior X/Y Scrollbars] at the applet's bottom, allow to move the displaycenter across the system, to see areas out of the range as in every text- and graphic-application. The inner ones [Py/Px] push the object selected with [Push_!] to the clicked direction. (see detailed instructions )

In the right lower corner is a blue field showing the status of the Simulation. If you do not know what to do press [Input] or [ESC] untlil Ready apperars here. You may start the simulation than by pressing [Start] or [RUN!] if a system is loaded.

The last label in the right lower corner shows the current Version of Programm.

Energy Window (at the right edge)
upper panel:
[Plot] Deaktivates/Activates the energy window may be usefull to speed up the simulation on slow machines (it needs much performance)
[D-][D+] Change the scale of the light blue line (Distance betwen the by [Dist] selected couple of objects e.g. earth and moon)
The Times axis is in down direktion die current time is marked by the violet bar. The values as distance are displayed in X-Direktion
If the window is full it starts at the top again. To see longer timeranges it may be usefull to scale the time in the lower panel

lower panel:
[T-][T+]    double/half the timescale
[Adjust]     brings the actual time to the bottom of the window, only the past is displayed
[k-][k+]    double/half  the scale of the kinetik Energy (red)
[p-][p+]    double/half  the scale of the potential Energy (green)
[t-][t+]      double/half  the scale of the total Energy (dark blue)
Since the total Energy has to be conserved the dark blue line should be a straigt line paralell to the zero line if not the intergration stepzie is too large.
The white field below shows the current values of time, distance and energy per unit.

Functional Keys
[F1] Increse time between two animated positions (faster animation)
[F2] Reduce time between two animated positions (slower animation)
[F3] Zoom in by Factor 1/2
[F4] Zoom out by factor 2

[F5] Scale with factor from white field
[F6] Clear screen
[F7] Reduce waiting time for adaptive computation of new position (s. Controling of adaptive Computation)
[F8] Increase waiting time for computation of new position

[F9] Stop
[F10] Browsermenu not used by the applet
[F11] like Button [Input]
[F12] Continue animation

[Page UP] Speed up Animation
[Page Down] Slow down Animation (some browsers will scroll, so better use the [S/WfR] regulator to control speed.

Animation Speed Control

If the Applet is generally too fast/slow you can control it's speed by the upper Scrollbar [Speed/Wfr] in the Top-Panel: to the left: slower, to the right faster.
But since the computer needs time to do the simulation you cannot speed it up infinitly.
The Keys [Page Up]/[Page down] or [F7]/[F8] control only the displaying speed.These keys and switches have no effect on the numerical computation, they are just to fit the animation to the CPU processing speed.

The motion of the planets is computed numerically in discrete timesteps and that takes time, the faster the computer the better. The integration stepsize is set by default so that the computation is "stable". If the computer is slow it slows down the animation. If the simulation runs too slow for you, you can manually enlarge integration stepsize, to make less steps, so that the animation runs faster. You can do that by the buttons around [Sc. Stepsize]: [>] greater stepsize  => faster; [<] finer stepsize => slower. The stepzize is multiplied or divided by 2 if you press these buttons or type the key [F1] or [F2] on the Keybord. To multiply the stepsize by a defined factor enter this factor into the white text field [Scalar] in the upper panel (you can also change the value by the scrollbar besides) and press [Sc. Steps].
Warning: Enlarging stepsize causes a loss of numerical precision. You may do that for Jupiter and the Comet after the encounter or the Trojans without significant consequences. Applied to 'Sun and One', 'Inner Solar System' or Wadejia this will make the Earth or Wirgon lose their moons. And if the stepsize is more large even a fast inner planets flies away... This is a numerical effect: If an object comes close to another it is accelerated by the gravity-force. So it gets faster and faster 'falling down' in the gravity-well. The distance ds it moves during an integrating step dt increases since ds=v*dt. If the object starts to climb up the opposite side of the gravity-well it has during an integrating step the high speed is had at the beginning of step. In reality it would have been slowed down again by the gravity-force pulling it continuously back to the center. But due to the discrete computation it is already at a position where the gravity force is weaker. If the integration steps are too large, the speed can get so high that the object can't be slowed down to an orbiting speed and therefore it escapes. In this case "Error" is displayed as status in the right lower corner.
You can see that effect, if you direct orbits close to the sun. To define orbiting-parameters yourself see Detailed Instructions
Due to this numerical effect do not place object too close to others by [+] or [<->] without shortening integrating stepsize.

Controling of adaptive Computation
To avoid the excaping effect by numerical errors the applet has been completed by a new feature: In the [Lower Pannel] is the new Buttom [A] for Adaptive compuation.
The adaption decreases the integration-timesstep until the error is below a threshold, so the threshold controls accurancy. You can control this threshold by buttons besides [A]: [^] for coarser adaption and [v] for finer adaption.
After pressing the [A] button the integrating-stepzize is computed adaptively but the animation is still displayed in fix real time steps. You can change this animation stepsize by [<][>] and [Sc. Speps] as before.
In the adaptive case enlarging the stepsize for the display can speed up the animation only in a certain range. If the adaptive computation takes time you cannot speed it up by enlarging the timesteps between new frames displayed. If the animation time step between displayed frames is too large that even slows down the display since there are much adapted timesteps to compute between the new frames. So the best is to make the animation stepsize not to large relative to the adapted stepsize. (I did not implement to do that automatically since the adapted stepsize is not constant and that would destroy the effect of  "real time animation" which is only possible if the animation stepsize is constant).
The animation-stepsize is normaly the "real" time between two displayed points. But, if the adapted stepsize is much larger than the animation stepsize, there are only new points drawn for the position computed with adapted stepsize, since the applet hasn't got an interpolation algorithm.
The animation runs like "real time" unless close encounters make too much numerical effort caused by higher gravity-force and speed. In this case the "Real" in the yellow "Animation-Stepsize row" dissappears. Your computer is too slow. So you should make displaying stepsize finer (so that there are less computing steps between two displayed points) or give more time to wait for the computing result by the lower Scrollbar [Speed/Wfr] in the Top-Panel: to the left: wait longer, to the right sleep shorter (speeds up simulation but it may loose the real time effekt). (Below Version 2.7 the direction is inverted).
The Key [F8] (increases waiting time in milliseconds. [F7] decreases waiting time) have the same controling function.
To return to a the fixed animation integrating-stepsize press[/A].

Orbit Transfers
The Pushmode [Push_!] is useful to change orbits. You can scale Pushforce by setting the factor with the [Scalar scrollbar] in the right corner of the Top panel and Pressing the [S] beside the black text field. Pushing an object along its motion direction at any point of its orbit gives more energy to it so that the semiaxis becomes longer.
Take an object in a circular orbit. Pushing along the motion direction at any point of the trace enlarges the semiaxis bringing the object to an elliptical orbit with the same Perihel (shortest distance to center = the point where you pushed at the old circle distance form center) This new orbit is elliptical. You can transform it into a circular 'higher' orbit pushing at the Aphel (greatest distance from center) along the direction of motion.
Pushing against the direction of motion brakes the object taking energy from it and therefore forcing it to an orbit with a shorter semi axis. If you brake at any point of a circular orbit the result is an elliptical orbit coming closer to the center but with the same Aphel (The point where you pushed at the old circle distance from center. To create a new circular orbit nearer to the center you've to push against the direction of motion at the Perihel. How much you have to push you've get to the feeling for, if you do not want to crash into Mars with your spacecraft :-)

And now have a nice time playing around.... with the planets. Q

Send bugs and comments to

To use the applet offline you can download all necessary files in a zip-File. If you habe a Java-interpreter that is in the Path of GFrame you can run "java GFrame" as every program. The frame-Application GFrame is necessary for saving and loading self generated constellations and saving the development of orbital parameter over longer times to files for plotting. (The java-applet inside Gravitation.html is as every applet forbidden to operate on files).

Known bugs:
The applet does not run on LINUX-Systems if Java is not installed correctly!!!
On Gates' W-Internetexplorer it works mostly properly:-)
Using Internet Explorer some Buttons have to be pressed twice before they react.
If Linux/Unix-Netscape does not react, click to another window and than back to the applet or return to previous site by pressing the Browser-Button [<=] and return by pressing [=>]. It may be enough to move one of the Browsers Scrollbars to provoke a reaction, too. That problem won't occur if you press the Applet-Button [Stop] before each other action.
The listing of the systemparmeters if there are more than 5 objects being stopped before pressing [V] should disappear if you start another system. But sometimes it doesn't. So press always [V] if there is an uncompleted listing.
Sometime the planets stop without pressing [Stop] and the animation can't be continued by pressing [Run]. The applet is not completely failed you can select the desired system anew, but you have to start from the very beginning.
If you zoom close to an object which is selected as center objects near to it may be displayed displaced after pressing [Stop]. Normally their positions are OK but it can happen that the Stop interrupts the current actualization of the center so that the relative position is incorrect. -> Let the animation continue and press [Stop] again. The same can happen after pressing [<->]. Press [ESC] and try again.