Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For a kinetic Monte Carlo simulation of solids that crystallize in the diamond lattice structure, I need some efficient representation of the diamond lattice as integer(s), to store it in some array-like structure, where each array index can uniquely be mapped to a certain atom in real-space:

$$ array[i] \rightarrow (x,y,z) $$

The diamond lattice consists of two face centered lattices, that are shifted against each other:Diamond lattice

So far, I have not found very suitable solutions. I have some demands to this mapping that must be met:

  • I need to know the nearest and second nearest neighbors of each atom in integer space. If possible, I want to pre-calculate the numbers that I need to add or substract from the array index of my current atom to get to the 4 nearest and 12 second nearest neighbors: $j^k = i+\Delta i^k, k = 1,\dots,4 (12)$
  • I need to fill the system from the bottom (in real space) up, so I would be happy to have some simple relation at least for the $z$ coordinate $z(i)$.
  • The simpler the mapping is, the happier I would be. It would be a big plus if it 'd be somewhat intuitive, so I can imagine it in my head.

What I tried so far:

  • I found this website (and recently also this website, on which a $(i,j,k)$ representation for the diamond lattice is given including the $(\Delta i, \Delta j, \Delta k)$ for the nearest neighbors. However, I couldn't find the mapping to get from there to real space. (Any idea how I could do that?)
  • An option that works is to use an fcc lattice geometry, with basis vectors pointing from the origin to the atoms in the face centers. With that basis, each atom of the lattice can be reached with a set of 3 integers. However, since the diamond lattice consists of two shifted fcc lattices, I would need a fourth index to determine to which lattice each atom belongs to. Also, I didn't succeed in finding a simple mapping $(x,y,z) \rightarrow (i,j,k,l)$ that allows me to determine the $z=0$ plane or so.

I am asking, because this should be a common problem. There exist so many simulations/publications of simulations, in which the diamond lattice was simulated (Si, GaS,...) that it surprises me, I can't find a simple solution to my problem on the internet.

I would be very happy if you could point me into some direction or know any literature on how to do this.

share|improve this question
Maybe OVITO ( is something for you? You should definitely check it. – Thomas W. Dec 10 '12 at 16:03
Hello Thomas, thank you for pointing me to that website. It seems to be a nice tool to visualize my results when I'm done with the simulation. However, I don't see how it solves my index problem. (I really want to write this simulation from scratch myself. It's part of my PhD Thesis.) – janoliver Dec 11 '12 at 8:54
up vote 3 down vote accepted

As far as I can tell, indexing a simple cubic lattice in the way you require should be easy. If we let $i, j, k$ be the indices along the $x, y, z$ directions, we can easily map these to a linear index $n$ like so: $$ n = ((k N_y) + j) N_x + i$$ Next, we need to accomodate 8 atoms per unit cell. The easiest way to do this should be to add a stride of 8 to the equation above and let $l = \{0, 1, ..., 7\}$ be the index describing which atom within the unit cell we are referring to, $$ n = (((k N_y) + j) N_x + i) \times 8 + l.$$

  • To find the $z$ coordinate is relatively easy: First find the $z$ coordinate of the unit cell in question, which is $\lfloor n / (8 N_x N_y) \rfloor$ times the lattice constant, then check $l = n \; \text{mod} \; (8 )$ to find out which atom within the unit cell we are dealing with and adjust $z$ accordingly.
  • Finding the nearest neighbours is somewhat more painful, but on the upside, it should be an efficient computation. Unless you can find a clever way, you may have to code something specifically for each value of $l$...
share|improve this answer
Hi, thank you for the answer. This is almost exactly what I did, however, I thought it would be possible with 3 indices. I did store the nearest neighbor deltas (di,dj,dk,dl) for each l in a static array. The next nearest neighbors are computed using that one. – janoliver May 20 '13 at 12:01
Good to hear that you found a solution! Three or four indices, I'm sure there are many solutions to your problem. – josteinb May 20 '13 at 12:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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