I'd like a FaceCenteredCubic image as in the in LatticeData docs, but space packed, and cropped on all the boundaries, so that it illustrates the geometry of the calculation that leads to the $\pi/\sqrt{18}$ density result.

The call that produces the plot is

LatticeData["FaceCenteredCubic", "Image"]

but this has small spheres, and probably doesn't have a way to crop on the boundaries. I see that there's a PackingRadius listed in the documentation. I thought it might be possible to use the PackingRadius property, to display the spheres in the lattice in a space packed fashion (so that they touch), but that wouldn't handle the cropping part of the problem.

Is there any easy way to do this, perhaps using the lattice data to draw spheres using the Graphics drawing options, and then using the various ViewAngle type options to crop that appropriately?


1 Answer 1


All the information is there, but to adjust the sphere radius I had to do a replacement as follows:

spaceFilledPlot[latticeType_] := 
 LatticeData[latticeType, "Image"] /. 
  Sphere[pt_, r_] :> {Opacity[.5], 
    Sphere[pt, LatticeData[latticeType, "PackingRadius"]]}


close packed

I added the opacity for better visibility of the underlying lattice.

Oh, and you wanted to crop at the boundaries:

 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]



In response to the comment, here is how one could replace the spheres in the default plot by RegionPlot so that the cut surfaces show up in a cropped display, giving a more solid appearance:

volumetricPlot[latticeType_] := Module[
   img = LatticeData[latticeType, "Image"],
   r = LatticeData[latticeType, "PackingRadius"]
   img /. Sphere[pt_, r_] :> {},
    RegionPlot3D[(EuclideanDistance[{x, y, z}, #] < r),
      {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
      Mesh -> False,
      PlotStyle -> Opacity[.5]
      ] &, Cases[img, Sphere[pos_, _] :> pos, Infinity]]


solid filling

Edit 2

There is at least one bug in LatticeData. I just found this when thinking about how to crop a unit cell for a non-cubic lattice. So I tried the hexagonal close-packed structure, which is closely related to the previous example. But here is the plot:



This is clearly not very closely packed! The error is in the "Image" data for this lattice. It's very easy to spot this when you use my function because it expands the spheres to where they should touch. So I'd recommend being very careful when using these data. A somewhat better-working notebook for this case can be downloaded from Mathworld.

As a temporary fix for the issue with the hcp lattice, you could use the following modification of the plotting function in the question:

volumetricPlot[latticeType_] := Module[
   img = LatticeData[latticeType, "Image"],
   r = LatticeData[latticeType, "PackingRadius"]},      
  If[latticeType == "HexagonalClosePacking", 
   pts = {{-1, 0, Sqrt[2/3]}, {-(1/2), Sqrt[3]/2, Sqrt[2/
      3]}, {-(1/2), -(Sqrt[3]/2), Sqrt[2/3]}, {0, 0, Sqrt[2/3]}, {1/2,
       Sqrt[3]/2, Sqrt[2/3]}, {1/2, -(Sqrt[3]/2), Sqrt[2/3]}, {1, 0, 
      Sqrt[2/3]}, {-(1/2), 1/(2 Sqrt[3]), 0}, {0, 
      1/(2 Sqrt[3]) - Sqrt[3]/2, 0}, {1/2, 1/(2 Sqrt[3]), 0}, {-1, 
      0, -Sqrt[(2/3)]}, {-(1/2), Sqrt[3]/
      2, -Sqrt[(2/3)]}, {-(1/2), -(Sqrt[3]/2), -Sqrt[(2/3)]}, {0, 
      0, -Sqrt[(2/3)]}, {1/2, Sqrt[3]/2, -Sqrt[(2/3)]}, {1/
      2, -(Sqrt[3]/2), -Sqrt[(2/3)]}, {1, 0, -Sqrt[(2/3)]}},
   pts = Cases[img, Sphere[pos_, _] :> pos, Infinity]]; 
  Show[img /. Sphere[pt_, r_] :> {}, 
   Map[RegionPlot3D[(EuclideanDistance[{x, y, z}, #] < r), {x, -1, 
       1}, {y, -1, 1}, {z, -1, 1}, Mesh -> False, 
      PlotStyle -> Opacity[.5]] &, pts]]]


hcp corrected

This has the gaps corrected by shifting the z coordinates appropriately to make the center lie at the origin. The function handles the hcp case separately.

  • $\begingroup$ Very cool. I didn't realize what LatticeData was actually returning here. To understand what you did, running LatticeData["FaceCenteredCubic", "Image"] // InputForm is very helpful. Is there a way to draw the spheres as solids instead of shells? I tried Opacity[1], but that still renders the spheres as shells. $\endgroup$ Jan 31, 2013 at 16:38
  • $\begingroup$ Yes, you can create a volumetric appearance, but then I have to replace the spheres by something else. I'll edit the post. $\endgroup$
    – Jens
    Jan 31, 2013 at 19:20
  • $\begingroup$ fyi. I've submitted a bug report through the wolfram support site for the HCP LatticeData bug (using a notebook containing your volumetricPlot function to illustrate). $\endgroup$ Nov 16, 2013 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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