Helical boundary conditions

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: where the modulo operator is used. It is not necessary that N = Ld. Helical boundary conditions make it possible to use only one coordinate to describe arbitrary-dimensional lattices.
 * $$(i \pm 1) \mod N $$
 * $$(i \pm L) \mod N$$
 * $$\ldots$$
 * $$(i \pm L^{d-1}) \mod N$$