\(vol := 
      a1 . Cross[a2, 
          a3]\  (*volume\ of\ an\ elementary\ cell*) 
\)
hcp := {a1 = {1, 0, 0}; 
        a2 = {1, 0, 0}/2 + (Sqrt[3]*{0, 1, 0})/2; 
a3 = 
          Sqrt[8/3]*{0, 0, 1};}   
sc:={a1 = {1, 0, 0}; a2 = {0, 1, 0}; 
        a3 = {0, 0, 1};}

b1 := (2*Pi*Cross[a2, a3])/
        vol   
b2 := (2*Pi*Cross[a3, a1])/vol

hMax := 
      Floor[(2*Kin)/
          Sqrt[b1 . b1]]   
kMax := Floor[(2*Kin)/Sqrt[b2 . b2]]
Kin = 22.    ;

\(\(\(d[1] = {0, 0, 0}; 
    d[2] = {1/2, 1/2, 
        0};  (*vectors\ which\ locate\ atoms\ in\ an\ elementary\ cell\ if\ natoms\ is\ larger\ than\ 1*) natoms = 
      1\)\(\ \)\( (*number\ of\ atoms\ in\ an\ elementary\ cell*) \)\(
\)
    \)\)

Q[h_, k_] := 
      h*b1 + k*b2

\(\(\(S[h_, k_] := 
      ComplexExpand[Sum[Exp[I*Q[h, k] . d[m]], {m, natoms}], 
        TargetFunctions -> {Re, 
            Im}]\)\(\ \ \ \ \)\( (*geometric\ structure\ factor; 
      ComplexExpand\ and\ TargetFunctions -> {Re, 
            Im}\ –\ equivalent\ to\ Simplify, 
      but\ for\ complex\ numbers*) \)\(
\)\(
\)
    \)\)

\(\(\(Q2d[h_, 
        k_] := {\(Q[h, k]\)[\([1]\)], \(Q[h, k]\)[\([2]\)]}\)\(\ \)\( (*2  
        D\ version\ of\ vector\ Q\ –\ for\ graphics\ \((to\ use\ “Disk”)\)*) \)\(
\)
    \)\)

circPlot := 
      Graphics[{green, 
          Circle[{0, 0}, 
            2*Kin]}]   

green = RGBColor[0, 1, 0]; red = RGBColor[1, 0, 0];
scale = 
      200 ; (*selects size of spots – for graphics*)

spotsPlot := 
      Graphics[Table[
          r = Abs[S[h, k]/scale]; 
If[
            Q[h, k] . Q[h, k] ≤ 4*Kin^2, {red, 
              Disk[Q2d[h, k], r]}, Disk[Q2d[h, k], 0]], {h, -hMax, 
            hMax}, {k, -kMax, kMax}]]

\(fig := 
      disp[Show[spotsPlot, circPlot, PlotLabel -> natoms, 
          AspectRatio -> Automatic]]
\)
disp := Display["t.ps", #1, "EPS"] &

scale = 1.5; hcp; fig

sc;  fig

natoms = 2; scale = 2;  fig

\(\( (*Scattering\ of\ X - 
          rays\ with\ atomic\ form\ factor*) \)\(
\)\)

\(\(rad[1]\  = \ 0.5\)\(;\)\(\ \)\(rad[2]\  = \ 
        0.25\)\(\ \)\(;\)\( (*the\ radii\ of\ the\ 2\ atoms\ in\ the\ elementary\ cell*) \)\(
\)\)

F[aa_,  
            G_]  :=  (4*
                  Pi*(-(aa*G*Cos[aa*G])  +  Sin[aa*G]))/
              G^3  /;  G  >  0.0001   

F[aa_,  G_]  :=  1. *scale  /;  G  <  0.0001   

SF[h_, k_] := 
        ComplexExpand[
          Sum[F[rad[m], Sqrt[Q[h, k] . Q[h, k]]]*Exp[I*Q[h, k] . d[m]], {m, 
              natoms}], TargetFunctions -> {Re, Im}]

spotsPlot:=Graphics[Table[r=Abs[SF[h, k]/scale];
If[
                  Q[h, k] . Q[h, k] ≤ 4*Kin^2, {red, 
                    Disk[Q2d[h, k], r]}, Disk[Q2d[h, k], 0]],{h, -hMax, hMax},{k, -kMax, kMax}]]


scale =  .1; 
    fig

rad[1]  =  0.5;  rad[2]  =  0.5 ;

scale =  .05; fig

rad[1]  =  0.05;  rad[2]  =  0.05 ; scale =  .0015;  
    fig