Ionic lattice simulator
The simulation above shows the behaviour of a tank of spherical balls which feel electrostatic forces with one another according to an inverse square law. There is also some light damping (i.e. friction) applied to the movement of the balls, which encourages them to slow down as the simulation progresses.
You can set the charges and relative sizes of the red and blue balls using the controls at the top.
The case where the two colors of ion have charges of -1 and +1 is similar to the case of sodium and chlorine ions in a salt crystal (NaCl). Soon, the ions settle into a square lattice of alternating ions.
Pressing the button to simulate instead caesium chloride (CsCl) makes the positive (caesium) ions larger than the negative (chloride) ions, so that the large caesium ions now form a square lattice with the smaller chloride ions fitting into the holes between them. This is not quite an accurate representation of a true CsCl crystal, since this simulation is 2D, while real crystals have 3D structures.
Increasing the charge ratio so that, for example, the red ions have a charge of +4 while the blue ions have a charge of -1, makes them more likely to form separate molecules rather than a monolithic crystal structure.
When running such a simulation, click the "Randomize positions" button to adjust the ratio of the number of ions in the simulation, such that there are four times more blue ions than red ions, and the overall mixture is electrostatically neutral.
You can also click and drag individual ions, if you'd like move them around.