7
$\begingroup$

The minimum image convention (MIC), see for example a short note of W. Smith, is often used in molecular dynamics or monte carlo simulations of periodic systems with an orthorhombic unit cell. For this special case, it is rather trivial to implement the MIC correctly. How does one apply the MIC to systems with a more general triclinic unit cell? The naive idea to simply generalize the algorithm for orthorhomic cells to triclinic cells, does not seem to work.

I could find this document, which provides some clues, such as the importance of the reduced basis of the lattice vectors, but it does not contain enough details to make a computer implementation.

I will implement the answers below in a test code to check which algorithms work (under given assumptions). The Python test program can be found here: https://gist.github.com/3566972. It tests the lammps implementation and one naive attempt of mine. Both fail. If one finds a bug in this test program, please get in touch.

P.S. For those who get worried about MD or MC codes that use a naive algorithm for triclinic cells: please read the note written by W. Smith. It explains a naive algorithm that works as long as the distance cutoff is shorter than half the shortest distance between the opposite faces of the unit cell. For a given cutoff, one may always construct a triclinic supercell for which naive algorithms will work fine.

$\endgroup$
5
$\begingroup$

The key is to take the differences $\Delta x$, $\Delta y$, and $\Delta z$ separately before beginning. Given the edge vectors ${\bf a}$, ${\bf b}$, and ${\bf c}$ that define a unit cell that has one corner at the origin, then your tilt factors are $b_1$, $c_1$, and $c_2$, where $n_m$ defines the $m^{th}$ component of vector ${\bf n}$.

Now, for each component:

  • If $|\Delta x| > 0.5(a_{max} - a_{min})$, then subtract off $a_{max} - a_{min}$ if $\Delta x > 0$, and add it for values less than zero.
  • If $|\Delta y| > 0.5(b_{max} - b_{min})$, then subtract off $b_{max} - b_{min}$ if $\Delta y > 0$, and add it for values less than zero. Also add or subtract $b_1$ from $\Delta x$.
  • If $|\Delta z| > 0.5(c_{max} - c_{min})$, then subtract off $c_{max} - c_{min}$ if $\Delta z > 0$, and add it for values less than zero. Also add or subtract $c_1$ from $\Delta x$ and $c_2$ from $\Delta y$.

My source for this is taken from the code for triclinic domains found in domain.cpp in the LAMMPS molecular dynamics package.

$\endgroup$
  • $\begingroup$ Thanks for the reply. Unfortunately, this algorithms fails for some cases (see test program). I guess it will (also) only work if the cutoff for the relative vectors is smaller than half the distance between two crystal planes. It is still an interesting answer, because it shows that most MD codes do not bother to implemented a more rigorous (and computationally more demanding) solution. $\endgroup$ – Toon Verstraelen Sep 1 '12 at 8:30
  • $\begingroup$ I am not sure I fully understood your answer. Can you clafify what you mean when you say "* If $|\Delta x| > 0.5(a_{max} - a_{min})$, then subtract off $a_{max} - a_{min}$ if $\Delta x > 0$, and add it for values less than zero." The second if statment, is it dependent on the first being true? When you say "and add it" what do you mean by "and" there doesn't seem to be anything to "and" there. $\endgroup$ – Magpie Jan 2 '13 at 17:37
1
$\begingroup$

The easiest way to do this is to use the fractional coordinate. The algorithm looks like this:

  • Transform coordinate from cartesian to fractional;
  • Round fractional coordinates to [0, 1);
  • Transform back rounded coordinates to cartesian.

To transform from cartesian coordinates to fractional, you have to multiply the coordinate vector by the inverted cell matrix: $$ H^{-1} = \begin{pmatrix} a & b \cos \gamma & c \cos \beta\\ 0 & b \sin \gamma & c (\cos\alpha - \cos\beta \cos\gamma)/\sin\gamma\\ 0 & 0 & \sqrt{c^2 - c^2 \cos^2 \beta - c^2 (\cos\alpha - \cos\beta \cos\gamma)^2/\sin^2\gamma} \end{pmatrix}^{-1}$$

And to transform back to cartesian, you have to multiply the vector by the cell matrix $H$.

The good thing is that this also works for orthorombic cells.

$\endgroup$
  • $\begingroup$ This is what I called "the naive implementation" in my tests, and it does not work in general. This is known to fail sometimes for non-orthorhombic cells when the shortest distance between two atoms exceeds half of the distance between two faces of the unit cell. This algorithm may then produce not the shortest possible relative vector, but a longer one. In the orthorhomic case, it does work properly. $\endgroup$ – Toon Verstraelen Jul 11 '17 at 5:45

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.