It might seem obvious that a gas will expand to fill its container, but this simulation aims to show why this happens at a molecular level. The 'molecules' in this container are set up to bounce off each other and the walls elastically (so there is no change in total kinetic energy) and don't interact unless they collide (they don't attract each other or have any long range repulsion). The molecules have a range of sizes and start with random position, speed and direction.
When the container grows or shrinks, the molecules will adjust to fill the new area available because they are continuously moving.
The 400 molecules will start moving as soon as the page loads.
You can adjust the width and height of their container using the sliders towards the top of the page.
Try quickly increasing the size of the box and watch what happens to the molecules as they fill the new space.
If the molecules are pushed close together (by making the box very small) they may stick together, but should break apart again when they are left to equilibrate in a larger container.