N-body simulations calculate the motion of the particles that are interacting with each other using physical forces. Most of them directly implement Newton's equation for gravitational force:
F = G (M m)/r^2.
They have a certain size measured in megaparsecs (Mpc). In our case the simulation size is 300 Mpc (1 Mpc = 1.9e+19 miles). This makes it so we can visualize galaxy formations and analyze galaxy clusters.
We used IllustrisTNG’s dark matter simulation to simulate the formation of halos.
Gadget-2 is the software used in many N-body simulations, including the dark matter simulation we used IllustrisTNG-Dark. It uses a tree-structure to compute the gravitational forces acting upon the particles.
The figure below shows a rough sketch of the evolution of a simulation. You start out with a simulation box of some size typically measured in megaparsecs, and you add a certain number of particles to your box (typically on the order of a billion). Then the simulation evolves in time using gravitational equations. As it evolves, the particles clump together forming halos. Those halos are then defined by a halo-finder like FoF or ROCKSTAR.