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:
“Systematic philosophical and practical anti-intellectualism such as we are witnessing appears to be something truly novel in the history of human culture.”
—Johan Huizinga (18721945)
“If you associate enough with older people who do enjoy their lives, who are not stored away in any golden ghettos, you will gain a sense of continuity and of the possibility for a full life.”
—Margaret Mead (19011978)
“After decades of unappreciated drudgery, American women just dont do housework any morethat is, beyond the minimum that is required in order to clear a path from the bedroom to the front door so they can get off to work in the mourning.”
—Barbara Ehrenreich (20th century)
“... the constructive power of an image is not measured in terms of its truth, but of the love it inspires.”
—Sarah Patton Boyle, U.S. civil rights activist and author. The Desegregated Heart, part 1, ch. 15 (1962)
“No convention gets to be a convention at all except by grace of a lot of clever and powerful people first inventing it, and then imposing it on others. You can be pretty sure, if you are strictly conventional, that you are following geniusa long way off. And unless you are a genius yourself, that is a good thing to do.”
—Katharine Fullerton Gerould (18791944)