I managed to implement the Nearest-Neighboor Ising Model with periodic boundary conditions, it was doable. I also made a modified version of it, where the interaction would go further than the nearest neighbors. In this case the implementation of periodic boundary conditions got more complicated (matrices instead of single variables).
Another example would be simulation software which does not have an implementation of periodic boundaries. The implementation of them on my own would be possible (for sure if it is open source). It would maybe even be possible to hack together some scripts that do this, depending on the scripting possibilities of the tool.
My question is therefore: What would be a the general route for implementing periodic boundary conditions? What is considered quick and dirty, and what the proper way? What could people who try to implement them be missing to do/notice? (I know it depends on the problem)
Are there creative enumeration techniques or other smart tricks that can help to create a periodic boundary. What general principles should be adhered to when doing it for FEM, FDM or others?