Practical Implementation: Continuity and The Minimum Image Convention
To implement periodic boundary conditions in practice, at least two steps are needed.
The first is to make an object which leaves the simulation cell on one side enter back on the other. This is of course a simple operation, and could in code be e.g. (for the x dimension, assuming an orthogonal unit cell centered on the origin):
if (periodicx) then if (x < -xsize*0.5) x=x+xsize if (x >= xsize*0.5) x=x-xsize endifThe second is to make sure that every distance between atoms, or other vector calculated from one atom to another, has a length and direction which corresponds to the minimum image criterion. This can be achieved as follows to calculate e.g. the x direction distance component from atom i to atom j:
if (periodicx) then dx = x(j) - x(i) if (abs(dx) > xsize*0.5) dx = dx - sign(xsize,dx) endifNaturally both operations should be repeated in all 3 dimensions.
These operations can be written in much more compact form for orthorhombic cells if the origin is shifted to a corner of the box. Then we have, in one dimension, for positions and distances respectively:
! After x(i) update without regard to PBC: x(i)=x(i)-floor(x(i)/xsize)*xsize !For a box with the origin at the lower left vertex ! Works for xs lying in any image. dx=x(j)-x(i) dx=dx-nint(dx/(0.5*xsize))*xsizeFor non-orthorhombic cells the situation can be considerably more complicated.
In simulations of ionic systems considerably more complicated operations may be needed to handle the long-range Coulomb interactions.
Read more about this topic: Periodic Boundary Conditions
Famous quotes containing the words practical, continuity, minimum, image and/or convention:
“Tried by a New England eye, or the more practical wisdom of modern times, they are the oracles of a race already in its dotage; but held up to the sky, which is the only impartial and incorruptible ordeal, they are of a piece with its depth and serenity, and I am assured that they will have a place and significance as long as there is a sky to test them by.”
—Henry David Thoreau (18171862)
“Every generation rewrites the past. In easy times history is more or less of an ornamental art, but in times of danger we are driven to the written record by a pressing need to find answers to the riddles of today.... In times of change and danger when there is a quicksand of fear under mens reasoning, a sense of continuity with generations gone before can stretch like a lifeline across the scary present and get us past that idiot delusion of the exceptional Now that blocks good thinking.”
—John Dos Passos (18961970)
“There are ... two minimum conditions necessary and sufficient for the existence of a legal system. On the one hand those rules of behavior which are valid according to the systems ultimate criteria of validity must be generally obeyed, and on the other hand, its rules of recognition specifying the criteria of legal validity and its rules of change and adjudication must be effectively accepted as common public standards of official behavior by its officials.”
—H.L.A. (Herbert Lionel Adolphus)
“on the instant clamorous eaves,
A climbing moon upon an empty sky,
And all that lamentation of the leaves,
Could but compose mans image and his cry.”
—William Butler Yeats (18651939)
“By convention there is color, by convention sweetness, by
convention bitterness, but in reality there are atoms and space.”
—Democritus (c. 460400 B.C.)