I am trying to find first nearest neighbour distributions of randomly dispersed point-like objects in an infinite system. To do this I make a finite sized box unit cell with a chosen concentration of points which are allocated X and Y coordinates, however it is clear that any points along the edge of the box do not see neighbours on the "outside" of the unit cell, skewing their nearest neighbour data.
To avoid this I can repeat the box 8 times around the edges, artificially inducing a boundary condition whereby the top points on the box can "see" the bottom ones. As the system is randomly generated and can be made quite large, this seems to work well.
The only drawback with my method is that it seems to take a long time to run, I would think as 9N*N, as the nearest neighbour search function in mathematica must run through the list of ALL points in the system, that is the X and Y coordinates of all points in the original cell plus the 8 neighbouring cells.
Is it possible to introduce a boundary condition more directly (so without repeating the unit cell box), thereby reducing the computation to N*N?