# 2.2 Periodic boundary conditions (PBC) and nearest image convention (NIC)

To avoid wall effects''we surround the basic cell containing the particles by periodic images of itself.

Spin lattices: In each coordinate direction the last (rightmost'') spin in a row interacts also with a right neighbor, which is taken to be identical to the first (leftmost) spin in that row, and vice versa (see Figure).

Fluid: Apply the following rule:
For each particle store, instead of any coordinate , the quantity

(with the side length of the cell). When a particle leaves the cell to the right, it is automatically replaced by a particle entering from the left, etc.

Nearest Image Convention: In computing pair vectors between two particles and one needs only differences of coordinate values. If this coordinate difference is larger than , then the particle will not be regarded as an interaction partner of ; instead, its left periodic image with coordinate interacts with .

The NIC rule may be implemented by a sequence of IF commands or by the more compact code line

where nint() denotes the rounded value of , i.e. the integer nearest to . This formulation of NIC is also better suited for vectorising compilers.
F. J. Vesely / University of Vienna