title: FCC 100 and 111 lattice C code
body: <p>I am trying to make FCC 100 and FCC 111 crystal lattice using C code. 
  I have configured FCC 100 lattice and I made it correctly. However, when I tried to make FCC 111 lattice and it looks different from what I expect. 
  I use the reference FCC 111 lattice (built by another GUI program “Amsterdam Density Functional”) to compare my FCC 111 lattice (using C code).
  My question is, 
  The parameters that I used to make FCC (111) in my code are correct? If they are not correct, please help me to build FCC 111 lattice. Thanks in advance</p>
  
  <pre><code>/**** To create FCC 100 lattice*********/
  for(i=0; i&lt;Xatom; i++){            // Number of Atoms in the X direction
  for(j=0; j&lt;Yatom; j++){        // Number of Atoms in the Y direction
      for(k=0; k&lt;nL; k++) {       // Number of layers in the Z direction
  
  x[i]= I * a_lattice;   y[j]= j * a_lattice;   z[k]= k * a_lattice;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  
  x[i]= I * a_lattice;   y[j]= 0.5 * a_lattice +  j * a_lattice;    z[k]= 0.5 * a_lattice + k * a_lattice;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  
  x[i]= 0.5 * a_lattice + I * a_lattice;  y[j]= j * a_lattice;   z[k]= 0.5 * a_lattice + k *a_lattice;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  
  x[i]= 0.5 * a_lattice + i*a_lattice;  y[j] = 0.5 * a_lattice + j * a_lattice;   z[k]= k * a_lattice;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
          }   
      }
  }
  
  /**** To create FCC 111 lattice*********/
  ax = a_lattice * sqrt(2)/2;
  ay = a_lattice * sqrt(6)/2;
  az = a_lattice * sqrt(3);
  
  x2 = sqrt(2)/4 * a_lattice;
  y2 = sqrt(6)/4 * a_lattice;
  y3 = sqrt(6)/6 * a_lattice;
  y4 = sqrt(6)*5/12 * a_lattice;
  y5 = sqrt(6)*2/6 * a_lattice;
  y6 = sqrt(6)/12 * a_lattice;
  
  for(i=0; i&lt;Xatom; i++){
  for(j=0; j&lt;Yatom; j++){
    layer = 0;
  for(k=0; k&lt;nL; k++){
  
  x[i] = I * ax;  y[j] = j * ay;  z[k]= layer/ 3.0 * az;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  
  
  x[i] = x2 + I * ax;   y[j] = y2 + j * ay;   z[k] = layer/3.0 * az;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  
  layer = layer + 1;
  
  x[i] = I * ax;  y[j] = y3 + j*ay;  z[k] = layer/3.0 * az;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  
  x[i] = x2 + I * ax;   y[j] = y4 + j * ay;   z[k]=layer/3.0 * az;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  
  layer = layer + 1;
  
  x[i] = I * ax;  y[j] = y5 + j * ay;     z[k] = layer/3.0 * az;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  
  x[i] = x2 + I * ax;   y[j] = y6 + j * ay;   z[k] = layer/3.0 * az;
  fprintf(fpo," %s\t %lf\t %lf\t %lf\n", AtomName, x[i], y[j], z[k]);
  layer = layer + 1; 
          }
      }
  }
  </code></pre>
  
  <p>Here I have also shown the reference structure and my output structure from  my code</p>
  
  <p><a href="https://i.stack.imgur.com/UyEjI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UyEjI.png" alt="enter image description here"></a></p>