Downward gravity: Cooling: Cooling on walls: Heating: Heating on walls: Wall Width (pixels): Wall Force Constant: Closed Top: Attractive Forces:
Setup Setup Type:
Time Step per cycle: Cycles per frame:
A little HTML 5 experiment with some 2D physics, using Verlet integration to track the motions of particles.
In this version, particles can be influenced various forces. Particles can be attracted downwards by gravity, particles can interact with each other by local attractive or repulsive forces (a bit like van der Waals forces, but using different equations, so that the force goes to zero at long range), and can be connected by springs and/or "angle-springs", or clamped in position. The angle-springs connect three particles, trying to keep the angle between the lines from the central particle to the other two particles fixed - they produce a torque proportional to the deviation from that angle. The particles also bounce off the walls, as if the walls were covered in perfectly bouncy springs.
This has been tested on Internet Explorer 11, Firefox 26, Chrome 31. I have got this working on Internet Explorer 11 on my Windows 8 machine, but not on my Windows 7 machine. It occasionally gets slow on Firefox - with some effort I have been able to stop it doing this most of the time, but not always.
Note the at the simulation is not always "numerically stable" - sometimes the calculations get wild, the error snowball at each step and particles fly out of the arena. There are various things you can do to avoid this, these will be explained with the parameters.
Various parameters can be tweaked. The time step per cycle and cycles per frame control how fast the simulation runs. Lower values of the time step make the simulation more accurate, and less prone to numerical instability - try turning this down if the simulation explodes. Cycles per frame affects how often the display updates.
You can adjust the overall strength of the various forces - stronger forces make numerical instability more likely. Also, you can add "heating" and "cooling", which can apply in general, or just to particles that are bouncing off the walls. "Cooling" removes a little bit of the velocity from each particle during each cycle - this gradually removes energy from the simulation, allowing structures to form. This generally should be kept low (e.g. 0.01 is considered "high"), although cooling on the walls can be higher - 0.5 is a good value. Heating makes a random tweak to the velocity on each cycle, simulating the addition of random thermal motion to each particle. Heating often requires higher values than cooling - 1.0 is a good value - it's often worth setting this after the simulation has come to rest. Another way to cool the simulation is to allow "evaporation" - turn "closed top" off, and high-energy particles will be able to fly out of the arena, reducing the amount of energy in the simulation.
When you change a runtime parameter, click away to another parameter, or press enter, and the change will take effect immediately.
Setup: There are different setup types (currently two) each with a different set of parameters. The number of particles per type is important, as the simulation slows down if there are too many. Try running in Google Chrome if you find it painfully slow. If there are far too many particles, the simulation might not start - try making the arena larger. "Forces" affects the strength of the attractive and repulsive forces between particles - the higher, the stronger.
You can also tell the setup to generate particles at the bottom of the arena - this is useful if you're trying to start a simulation without too much energy in it. This will only have an effect in setup types that place particles in random places.
Setup Type Description
Peter Corbett, 2013-2014
Back to ptc24 labs.