Welcome to XGrav


XGrav v1.0.0
- download now
- documentation

- more software by Mathias

X-Grav is a simple physics simulation for a large number of particles. It simulates
the effect of gravity, collisions, heat dissipation and a simple chemical reaction.
The simulation is in no way meant to be realistic but rather a toy with which you
can create stars, planets and even simple solar systems.

The best way to understand the behaviour of X-grav is by a demonstration. Start by
compiling xgrav and then start it by doing:

xgrav < example1.g


This will start a simulation containing 2000 particles which are all cold from the
begining. After a while these particles will have collapsed into a few clouds which
are warmed up by the friction of the particles. When the temperature and density of
these clouds have raised enough some of the colliding particles will ignite in a
burst of fusion. This will lead to a chain reaction igniting a large number of the
combustible particles, raising the temperature of the cloud so rapidly that the
particles are blown appart from the increased pressure. Under most circumstances this
sudden reaction will blow out the initial flames.

However if you wait a while and if the conditions are right you this will not happen
the second or third time the particles form dense clouds again. The chain reaction will
be a little calmer due to less combustible material and will rather live on. You will now
have a small star which is fueled by continous reactions of colliding particles.

If you let the simulation run for a while you will see that there are less and less  material left in the stars which can react. As the stars are cooling down you can note
that they are shrinking until they are cold and dark dwarfs.

As the first clouds of interstellar dust is forming the friction is slowly building up the heat.


During the simulation you can use the 'a' and 's' keys to zoom in and out of the center
of the simulation. When you are satisfied with the demonstration you can use the
escape key to quit the program.

Hopefully this small demonstration will have made you interested in the simulation.
When we ran this simulation we only used 1000 interacting particles in order to get
the results somewhat in real time. If you are a little more patient you can instead run xgrav with the 'record' and the 'play' settings. By doing 'xgrav -r foo.dat < example2.g' you instruct xgrav to save all the simulated particles continously in the datafile 'foo.dat'. After quiting xgrav you can later playback and resume the simulation with 'xgrav -p foo.dat'.
When the heat is high enough the first chain reactions can start. Finally leading to the creation of a stable star.


Have fun with xgrav and please let me know if you find any use in it.

Mathias Broxvall, matbr at home dot se