# generate 3D cubic lattice with different atoms in alternate site [duplicate]

I was wondering how to create a 3D cubic lattice and vizualize with A and B atoms in alternate sites?

Regards

• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Dr. belisarius Mar 23 '16 at 6:55

You could generate the coordinates as a list, in the "XYZ" format, and then read it in as such, at which point Mathematica will create a molecular model for you:

coords = Flatten[
Table[
{If[
OddQ@Total@{x, y, z}
, "Na", "Cl"], x bondlength, y bondlength, z bondlength},
{x, 6},
{y, 6},
{z, 6}], 2];
ImportString[
ExportString[
coords, "Table"], "XYZ"]


Then you create an XYZ file as a string and read it in,

ImportString[
ExportString[
coords, "Table"], "XYZ"]


• In crystallography one usually gives coordinates of few atoms in the lattice plus the space group. Typically. What do we do in that case? – Alexei Boulbitch Mar 23 '16 at 8:31
• @AlexeiBoulbitch - yeah, I'm a molecule guy, not much experience with solid state stuff, so I'm looking at that right now. – Jason B. Mar 23 '16 at 8:34
• @AlexeiBoulbitch - really I couldn't do it better than bob, so I'll point to his answer: mathematica.stackexchange.com/a/68904/9490 – Jason B. Mar 23 '16 at 8:36
• Hi JasonB, elegant...thanks a lot. It did solve what i was aiming to. – akonar Mar 23 '16 at 9:18

Straight Outta help:

b = Normal@LatticeData["SimpleCubic", "Basis"];
l2 = Tuples[Range[0, 5], 3].b;
Graphics3D[{{Red, Green}[[Mod[Tr@#, 2, 1]]], Sphere[#, .2]} & /@ l2]


• Thank you Dr. Belisarius. It was a great help. Actually I was aiming to create a list with atoms co-ordinate and atom type like {x,y,z,A}. So the full list will be like { {0,0,0,A},{0,0,1,B},....{0,1,0,B}......}. So on. I am using another function like atom3d[i_, j_, k_] := If[OddQ[i + j + k] == True, A, B] to add the list generated with your one. Is there any other elegant way to do that? thanks a lot – akonar Mar 23 '16 at 8:35
• @Dr. belisarius Please comment (1) on what are you doing with Tuples[Range[0, 5], 3].b and (2) on the following question. One can have a simple cubic lattice (denoted by P from "primitive"), but if there is more than one atom in the cell, the crystallographic group may be still different. Do you have an approach to deal with different crystallographic groups with the primitive cubic lattice? – Alexei Boulbitch Mar 23 '16 at 8:37
• @AlexeiBoulbitch Tuples[ etc].b is replicating the basis vectors b across the crystal. 2) yes, you're right the crystallographic can be different, but I don't have an approach for that – Dr. belisarius Mar 23 '16 at 8:53