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?

  • 1
    $\begingroup$ Welcome to SciComp.SE. Maybe you want to explain a little bit the definition of your problem and your approach so far (so, people can tell you if your approach is good enough or not). Imposing PBC in FEM is just a particular case of multipoint constraints (that are common). Then, you just express your conditions as matrices that impose the DOF. Another option is to redefine the shape function to take into account the periodicity. See this paper, where they use FEM for these BCs. $\endgroup$ – nicoguaro Jul 16 '15 at 19:36
  • $\begingroup$ Thanks for the comment, nice paper. I currently don't want to solve a problem regarding the implementation of boundary conditions (but I may in the future). I was interested what the approach is, what the keywords are, what to think about when working with it. I came up with this question because of the thought I probably could have done it in a smarter way (for the spin model) as well as what is common and what are the differences when implementing it for other numerical calculations. So yes, I guess the question could be too broad. :-) $\endgroup$ – WalyKu Jul 17 '15 at 11:54

In the specific case of the Ising model and its generalizations, imagine you enumerate the spins, and then you create a matrix $H$ where the $ij$th entry $H_{ij}$ indicates the coupling strength between spins $i$ and $j$. You can obviously implement the dynamics of the Ising system using only this matrix. In particular, the energy is simply the product $\mathbf s^T H \mathbf s$ where $\mathbf s$ is the vector that contains plus or minus ones, depending on whether a spin is up or down.

The one-dimensional Ising model then corresponds to a matrix $H$ where only the diagonal and the immediate off-diagonals are nonzero. If you have interactions with spins further away, then there are also nonzero entries further away. In the case of the one-dimensional, nearest-neighbor, periodic Ising model, you would get a matrix $H$ where the diagonal, the immediate upper and lower off-diagonal entries, as well as the bottom left and the top right entry of the matrix are nonzero, and all other entries are zero.

Using this connection between matrix and system, you can pretty easily generalize the original Ising model: just write your algorithm in terms of $H$, and then choose the $H$ that corresponds to the situation you care about.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.