In mathematics, helical boundary conditions are a variation on periodic boundary conditions. Helical boundary conditions provide a method for determining the index of a lattice site's neighbours when each lattice site is indexed by just a single coordinate. On a lattice of dimension d where the lattice sites are numbered from 1 to N and L is the width (i.e. number of elements per row) of the lattice in all but the last dimension, the neighbors of site i are:
(i\pm1)\modN
(i\pmL)\modN
\ldots
(i\pmLd-1)\modN