next up previous
Next: Starting configuration Up: Tricks of the trade Previous: Units

Boundary conditions

Figure 7: Example of periodic boundary conditions in 2D. Note that particle 1 is about to leave the left face of the central cell and to enter the center cell trhough the right face. The minimum image distance convention inplies that the separation between particles 1 and 2 is given by the bold line
\begin{figure}\begin{center}
\epsfig{file=pbc.eps,width = 12cm}\end{center}\end{figure}

Since the size of our system is typically 10-100 molecular diameters, this is certainly not a good representation for a macroscopic sample because most of the particles will be situated near a ``wall'' or ``boundary''. To minimize the effects of the boundaries and to simulate more closely the properties of the macroscopic system, it is convenient to choose ``periodic boundary conditions''. These means that our basic box containing $N$ particles is surrounded by images (or replicas) of itself. This is equivalent to wrap the coordinates around the boundaries: when one particles hits a wall, instead of bouncing pack, it reappears on the other side of the box. This means that the system has the topology of a torus. If the linear size of the box is $L$, the maximum separation between particles is $L/2$.

The rule can be summarized as follows: instead of the coordinate $x_{i}$ of some particle, we have to adopt

\begin{displaymath}
(x_{i}+2L)\mathrm{mod}L.
\end{displaymath} (43)

In this way the number of particles in a given box is always conserved. A particle crossing the right boundary is automatically replaced by a particle entering the left, and vice versa.. (Adding $2L$ before the modulo operation is to catch any runaway particles with $x_{i}<-L$)

To compute the potential energy or the force between two particles $i$ and $j
$ one augments the periodic boundary conditions we have to adopt the so-called ``nearest image convention''. Imagine that the two particles on opposite sides of the box. The convention dictates that we have to adopt the minimum distance across the walls, or between images in the neighboring replicas. If $\Delta x_{ij}=x_{j}-x_{i}$ is larger than $L/2$, then the particle $j
$ will be disregarded as an interaction partner of $i$, with its left image, having coordinate $x_{j}-L$ in its place. In practice this means simply that when calculating $V(r_{ij})$ we have to use the quantity $\Delta
x_{ij}-L$ instead of $\Delta x_{ij}$. An analogous rule holds for $\Delta
x_{ij}\leq -L/2$ and for the other coordinates.

The rule can be expressed by

\begin{displaymath}
\Delta x=\Delta x-L\mathrm{int}\left( \frac{\Delta x}{L}\right) .
\end{displaymath} (44)

Expressions (44) and (43) can be replaced by ifs expressions. In a parallel code this is counter productive, but in a serial code may be preferable. The optimal choice should be base on benchmarks.


next up previous
Next: Starting configuration Up: Tricks of the trade Previous: Units
Adrian E. Feiguin 2004-06-01