userguide-en

galaxy user guide v. 1.7
Introduction
galaxy is a free Linux computer program which simulates the motion of stars under the influence of gravity. Create a random field of stars to begin with, then watch the stars move as they are accelerated by their mutual gravitational attractions. You may vary the number of stars and the strength of the attractive force between them. Observe how the attractive forces accelerate individual stars and send them careening in new directions. Observe how large groups of stars develop into patterns over time: clusters and spiral arms.
galaxy is not for serious physics, but for amusement. It could serve as a teaching aid for young students of science.
License and Warranty
galaxy is licensed under the GNU General Public License, version 2 (Free Software Foundation). galaxy is not warranted for any purpose whatsoever, but if you find a bug, I will try to fix it.
Origin and Contact
galaxy originates from the author's web site: http://kornelix.squarespace.com/galaxy
Other web sites may offer it for download. Modifications could have been made.
If you have questions, suggestions or a bug to report: kornelix@yahoo.de
Compiz Warning
If Compiz special effects are enabled, galaxy may cause the screen and keyboard to become totally unresponsive, forcing a reboot of the computer. To run large models, you should disable all Compiz special effects. UPDATE: Compiz 0.7.8 (in Ubuntu 8.10) no longer has this problem.
Primer
When the program is started, you will see a black window and some buttons along the top.
Press [init] to display a built-in model of a few stars. They are stationary. Each use of [init] will generate a new group of stars with random positions. Press [run] to set them in motion. Watch for a while to get a feel for what is happening. Press [pause] and [run] to pause and resume the simulation. Drag a window corner to change its size (the internal simulation is not affected, only how it is scaled for display). Press [help] to view the user guide (this file). Press [quit] to end the program.
The [God] button allows you to redesign your universe using the following dialog:
Change the parameters as desired and use the [ apply ] button to apply the new values, which do not take effect until the next [ init ]. The [ load file ] and [ save file ] buttons load the parameters from a file or save them to a file.
A few parameter files are supplied with the software, named parameters-xxxx.txt, where xxxx is the number of stars in the model. Start playing with one of these files. The ones with 4000 or more stars may need 10 minutes or more before spiral arms start to form. A pattern of concentric circles often preceeds spiral arm formation.
The parameter table below gives some guidance about parameter values, and the technical notes give more explanation of how galaxy works and how the parameters influence the results.
Parameter Table

name | range | explanation
thread count | 1-4 | Program threads used for continuously recomputing attractive forces between stars. Sensible value is CPU count - 1.
star count | 1-100K | Values over 20K are too slow: recomputing the forces takes several seconds per cycle on a fast CPU.
pixels | 1-3 | Star pixel size: 1x1 or 2x2 or 3x3. Use 1 for >1000 stars.
gravity | 1-10000 | Attractive force multiplier. Normally use values >1000 for a few stars, and values <100 for thousands of stars.
R flatband | 5-100 | Value added to the distance between stars before the attractive force is calculated. See technical notes for details.
black hole mass | 0-10K | Mass of central black hole, in units of stars.
black hole capture | 0-100 | Stars getting within this distance are consummed by the black hole and added to its mass.
initial velocity | 0.8-1.1 | 1.0 is the equilibrium value. Values <1 will cause contraction, and values >1 will cause expansion.

Technical Notes
Calculations
The attractive force between each pair of stars is calculated using Isaac Newton's formula first published in 1684:
F = G m1 m2 / R2
For each star, the program computes this attractive force (x and y components) from every other star, and adds them together to compute the total force and acceleration. Each pair of stars requires about 20 calculations. For 1000 stars (1 million pairs), about 20 million calculations are needed to compute all the accelerations one time (one update cycle). These calculations are repeated continuously as the stars move and the attractive forces change. Each star's velocity is updated from it's acceleration, and it's position is updated from it's velocity.
Threads
There are two main execution threads. Thread 0 updates star velocities and positions and updates the display, once per interval. Thread 1 computes the acceleration of each star, once per interval. If the number of stars is large (1000+), the interval for thread 1 increases because of the computation time required. You can see this in the CPS (cycles per second) number shown in the lower-right corner of the window: this is the rate at which accelerations are recalculated for all stars. You can use the "thread count" parameter to create multiple instances of thread 1, which share the calculation burden. If you have a computer with multiple CPUs, increasing this number enables you to run larger models at higher accuracies. Note that the star velocity on the screen is not increased, only the rate that accelerations are recalculated is increased, and therefore the accuracy of the model. Use one thread if your computer has 1 or 2 processors. Use 3 threads if you have 4 processors. Keeping one processor available for running the screen updates results in a smoother appearance.
CPS
The update rate in cycles per second is displayed in the lower right corner. For a small number of stars (<200), CPS is dominated by the sleep interval of 0.02 seconds per cycle (compile time constant). For a large number (1000+) CPS is dominated by the processing time required to calculate all the accelerations.
Star Replacement
Stars that move off-screen are replaced with new stars distributed randomly (clustered more in the middle). The same goes for stars falling into the black hole.
Black Hole
This parameter allows you to put a black hole with some large mass at the center of the galaxy. Stars coming within the capture distance are devoured and re-created somewhere else. The capture distance is in units, where the entire simulation space is 1000 x 1000 units.
R flatband
This parameter is added to the distance between each pair of stars for calculating their attractive force. It has the effect of reducing the forces between nearby stars and allowing them to be more influenced by the greater number of distant stars. If flatband is very small (10 units or less), stars will accelerate each-other strongly when they get close together. If you run a model with thousands of stars, and you see many local collapses taking place, increasing this parameter will reduce this effect.
Initial Velocity
When a model with a large number of stars is initialized, the force on each star will be mainly pulling to the middle, since the initial distribution of stars is symmetric and the black hole is in the middle. The initial velocity assigned to each star is calculated to balance this force, i.e. the centrifugal force will be equal and opposite, and the stars will tend to rotate around the middle without expanding outward or collapsing inward. This condition will persist until the stars undergo regional collapses and the symmetry breaks down. The parameter allows you to bias the initial velocity to make the stars tend to fall inward (values < 1) or expand outward (values > 1). A slight bias to fall inward (e.g. 0.95) seems to give good results.
Speed vs Precision
The speed of galactic evolution can be accelerated by using higher values for gravity and/or a bigger black hole. This will result in higher initial angular velocities to balance the greater pull to the center, and the whole system will evolve faster. This reduces precision, since the stars will move greater distances between each recalculation of acceleration. Less precision results in more chaos and less interesting patterns. For good precision, the stars should not move more than a few pixels per update cycle (see CPS).
Angle of View
Internally, the simulation takes place in a square region, which is projected on the rectangular display window. If you make the window very wide in comparison to its height, it is the same as viewing the galaxy from an oblique angle.
2-body and 3-body problem
When two stars are simulated, a stable orbital pattern of rotation can persist for a long time (not forever, due to computational imprecision). When three or more stars are simulated, various orbital patterns come and go with varying degrees of persistence or stability. This "three-body problem" has no analytic solution and is inherently chaotic. The semi-persistent and recurring patterns that may be seen are called “strange attractors” in chaos theory.
Pixels
If the pixel parameter is 1, only one pixel is used to display a star's position, and the motion is "jerky" (movement is one pixel at a time). If the pixel parameter is 2 or 3, a 2x2 or 3x3 group of pixels is used, and the motion is made smoother by anti-aliasing the pixels: star position is calculated to the nearest 0.1 pixel, and shades of gray are used to make it appear as though the motion is finer than one pixel.
3x3 star, moving up
time →