gravity 4-alpha

something happened: either someone embedded this in an iFrame for some reason (why?!) or you don't have JS enabled

timestep: mouse:
kinematics:
thermodynamics:
rendering mode: heatmap mode:

heatmap gain:
enable links?

preset:
page color: , text color:

This is a gravity simulation with newtonian gravity and repulsion. The particle radius for repulsion increases with heat, because of thermodynamics, and heat is generated by friction. This allows fairly accurate simulation of planets.

The initial conditions are random particles, spread evenly throughout space. Very simple.

Each particle attracts each other, via a force given by F = Gm1m2/r2, where F is the force inwards, G is the gravitational constant, m1 and m2 are masses, and r is the distance. This formula is calculated over every pair of particles.

Whenever two particles are near each other, two things happen. The first is a collision, computed as a force inversely proportional to the distance between them. The second is friction, where particles generate an amount of heat proportional to the square root of the difference in speed. The resulting heat actually makes the particles expand a little, through thermal expansion. You can actually explode a planet by overheating it because of this. Note that the particles don't actually slow down (and nor do they spin).

Related to heat, each particle loses heat over time to space itself, repersenting blackbody radiation. This is why planets don't get infinitley hot, explode, and then break the simulation.

All particles have the ability to link to other particles if they are in the right temperature range. If they get too hot or far, the link breaks, and if they're too cold, they can't form a link. Only at a certian range will links form. Links are disabled by default, as they are not performant at all. Links also increase in stiffness over time, with a stiffening proportional to temperature. Also, each particle can have up to 6 links, and no more. However, 6 should be enough links given a hexagonal arrangement of particles, which is what usually forms. The temperature ranges at which links form and break are expanded based on pressure.

If you want to know exactly how it works, I didn’t minify or obsfucate it, so just use a console (if you're on mobile, use eruda). Please note that if you are using the google sites version, there are a lot of extra layers piled on top of the actual simulation from google sites.

Also, some caveats: this is 2d, meaning some things simply can't be simulated and wave propagation through planets is different, although the law of gravity is still 1/r2 to allow stable orbits. This also uses verlet and not RK4 (aka it's not too stable), and the parameters aren't actually based off any IRL measurments. Actually, gravity here isn't quite 1/r2: it's (by default) 1/r22, where ε is the softening constant (default equal to 0.5), used to avoid particles exploding into infinity. However, this gets close to normal gravity very fast, and so orbits still exist.

Made by Catzcute4.

changelog:

versions 3 and below: physics.interface.bugfix.possibleWithBugfix

versions 4 and above: fundamentalChange.newThing.tweak.bugfix