8 (499) 391-32-03, 8 (499) 394-07-16
125363, г. Москва, ул. Новопоселковая,
д. 6, кор. 217, офис 606
The Galaxy Simulator application was designed to be a small tool that starts animating a universe of 200 stars, which runs in real time.
The name is probably a bit of an exaggeration, but basically it starts with a group of stars placed randomly in a 3D volume of space. Then it computes the gravitational attraction between all the stars and moves them all a little. Then it does it again.
That’s about it, really. I added some extras for fun (like making a movie since it *does* take awhile to compute a large enough number of stars.
And I am considering 2000 to be a large number, which is not really accurate in the ‘galaxy’ sense, of course. But it’s a lot of little dots on your computer monitor.
My ‘scientific goal’ for the program was to establish that given time, a random placement of stars would turn into a rotating disk (my hypothesis) and it more or less seems to be the case.
Since the stars start off at rest (yeah, yeah, I know that would make a nice feature addition to give them initial velocities), they are initially drawn to the center of mass of the universe, and a few encounter each other closely right away and are whipped outwards at high velocity.
The rest pass each other on their way through the center, bound out the far side, and eventually slow down and orbit the center. Eventually one plane becomes dominant (mainly by hurling out the stars which aren’t in it.) and then one direction of rotation dominates (took me over a week of computation to get to this point, and about half the stars had reached what appeared to be escape velocity in the process.)
Basically, this is a tool for building star clusters over time.
There are two modes to use it in:
Add a group of (red) stars into the universe.
Move a set of stars around the 3D volume.
The simulation is run until it stabilizes, allowing you to examine the stars at this stage. The current script is capable of running simulations for between 100 and 20,000 stars.
Add a group of stars into the universe
Use the ‘addGroup’ button to add a group of stars to the simulation. The number of stars in each group can be specified, or you can simply select a uniformly-distributed range of stars.
Once you’ve added a group of stars, a popup window will appear that will allow you to specify where to place each star in the simulation.
You can drag-and-drop the stars around the viewing volume using your mouse.
Move a set of stars around the 3D volume
Use the’moveStars’ button to move a set of stars around the simulation.
To help me debug this application, please report your findings in the comments here or on the Google Groups forum.
Here is the program code:
// Construct the Galaxy Simulator.
var simulator = document.createElement(‘div’);
simulator.innerHTML = ‘Add Group of Stars’;
var groupSelector = document.getElementById(‘groupSelector’);
var addGroup = document.getElementById(‘addGroup’);
var viewport = document.getElementById(‘viewport’);
var moveStars = document.getElementById(‘moveStars’);
var starDeleter = document.getElementById(‘starDeleter’);
var option = document.createElement(‘option’);
var totalStars = 0;
totalStars = document.getElementById(‘totalStars’).value;
// Construct the Galaxy Simulator.
var simulator = document.createElement(‘div’);
simulator.innerHTML = ‘Move Stars’;
This was a lot of work to write and record. Now what I want to share are some of the tools and the code that I used to write and record the simulation, as well as some of the original performance predictions I made when I first had the idea.
It might be interesting to watch the simulator run, and put your own star parameters into it to see what it does. (If the results are unexpected, well, then you have something to work with.)
Technical description of the simulation:
My understanding of physics here is very limited, and I make no attempt to model stellar dynamics (don’t know enough about them). But here is a short description of the algorithm.
Stars are represented by 3D unit vectors (i.e. like a n-sphere, a.k.a. a sphere). The simulation treats them as centers of mass, which makes some sense since it is unlikely that any star is significantly larger than a proton.
The simulation starts with 2000 randomly placed stars. Each star has x, y, z components of velocity drawn from normal distributions of 0, 0 and 1.
Each star has a position, velocity, and acceleration. The acceleration is calculated as the sum of all of the other stars in the universe. The force from each star is calculated as:
a = 0.5 * mass * gravity * G * ((1/distance)^3)
where gravity is the G-matrix (a positive in 3D) and mass is the star’s mass (also a positive).
The stars are free to move at any speed (to jump, their position after a jump is a normal distribution of speeds drawn from the distribution of their current velocities). They tend to travel in the direction in which gravity is strongest.
When a star is closer than 0.1 G-matrices to another star, they begin to interact (a distance of 3 G-matrices is a good choice). The force on one star is calculated as the vector sum of the forces from all other stars.
The direction of a star’s acceleration is calculated as a vector sum of its acceleration and the vector sum of the forces from all other stars. It is this vector sum which determines which direction the star will move in the next timestep.
However, each star has an x, y, and z component of velocity (vector) which is updated in a similar fashion.
The computation of acceleration is done using the matrix
This is a small tool I wrote for myself (really it’s more of a hobby project than anything else).
It is intended to be used as an educational aid to get students familiar with the basics of gravitational dynamics.
The part of the code that computes the forces is very tiny so the simulation is very quick and runs in real time.
The stars are drawn out of a random distribution and it is meant to act as a ‘factory for stars’ that can be easily run with simple parameters.
Once you have some stars in place and in motion, the next stage of the simulation might start off with the stars hitting each other closely (which causes them to fly out with high velocity) or fly off to the periphery of the universe (which then slows them down.) The stars end up orbiting the center of mass of the group for some time and then one of the main planes of the group starts to dominate.
The last stage of the simulation ends when there is just a few stars left orbiting the center of mass of the group.
It should be noted that the application was designed to be run interactively as a single process.
Update 1: All of the simulations completed with each star being ‘born’ with some random velocity (which I have chosen to be about 5 km/s.)
However, by comparing the initial velocities of the stars to the velocities at which they escape the universe, it is possible to work out the escape velocities of each star as a function of the mass (and radius) of the star.
Update 2: I have the Stellar Evolution data tool to study the orbits of the various kinds of stars.
Update 3: I’ve added a movie viewer to the Galaxy Simulator application, which you can find in the ‘Add-On’ tab (if you haven’t yet.)
Update 4: I added in the ‘File Menu’ the ability to export the movie that is being generated in real time, as a new type of file (the.gif files I made from it, as well as the.mpg files are named after the star ID being simulated.)
Update 5: I’ve added the ability to delete the ‘universe’ itself. This is ‘optional’, but can give the user an insight into how different initial stars/splits/settings produce different simulations.
Update 6: I’ve added the ‘File Menu’ to the application so that the.gif movies can be exported.
Update 7: I’ve added the
Simulates the time evolution of a sample of stars in an isolated, centrally condensed galaxy. Stars can be added to the simulation as needed and can be removed from the simulation as needed.
the stars orbit each other without colliding until the mass of the system is a little below 200.
The part in orange is the 3D volume of space. Each star is represented by a sphere of 3D space. When a new star is added, it is placed randomly in that volume and is given an initial velocity and orientation. This is repeated as the simulation runs.
The mass of the system is kept as a number in kilograms, even though it is a computer simulation. It is initialized to a value of about 20kg; I checked early on and it never got below that, although it can get pretty close.
The simulation runs in cycles, and at each time step, the stars are moved a little in all 3 dimensions (in the direction of their initial velocity) and the gravitational attraction between all the stars is computed. Then they are moved a little more and the attraction is computed again, and so on.
By changing the simulation, different physics can be evaluated and applied. For example, if the force is applied in only one dimension, the stars can orbit around a center of mass in a circle. If the force is applied in two dimensions, it makes an airplane or asteroid-like figure.
The simulation can be controlled through command line options, and can be viewed directly or exported into a file.
The user has the option to choose what parameters to use. The current options are set to a default, but they are scriptable so that later they can be modified (useful for making customized simulations and are also scriptable by simple functions.)
I did do some basic error checking on the program and used some very basic internal error checking. I added a few checks to look for uninitialized variables and some libraries that have the same name as the’standard’ libraries. I added the option to read from an output file or directly to the computer screen.
I checked to see that the star numbers and masses stayed correct as the simulation ran and I iterated the code. This is not a scientific simulation, so that isn’t really a concern for me. But I noticed that I didn’t iterate the code when I had originally set out to.
I have only an occasional need for the mass values, but I could add the output to the GUI
Mac OS X 10.7.5 or higher
PS4® system (PS4™ system)
Online play is supported in this title.
Duplicate title Copy included.
No video included.
• If your hardware lacks Blu-ray compatibility
Sorry, comments are closed for this post.