3
$\begingroup$

I am trying to create a periodic structure from a unit cell figure which I created using RegionPlot3D:

RegionPlot3D[x^2 + y^2 + z^2 < 0.6, {x, -0.5, 0.5}, {y, -0.5, 0.5}, {z, -0.5, 0.5}]

While I can create multiple instances of the unit figure using something like

RegionPlot3D[
   x^2+y^2+z^2 || 
   (x-1)^2+y^2+z^2 ||
   x^2+(y-1)^2+z^2 <0.6, {x,-0.5,0.5}, {y,-0.5,0.5}, {z,-0.5,0.5}
]

I would prefer to have something like a parameter which I can vary to get the multiple instances. Just as an example, I want something like

Graphics3D[
      Table[
         Sphere[{x,y,z},0.6], {x,0,2,1}, {y,0,2,1}, {z,0,2,1}
      ]
 ]

but with my unit figure. Is it possible to achieve it using RegionPlot3D? I am perfectly happy with any other solution - even one which might generate the unit cell with something else. Thanks.

$\endgroup$
  • $\begingroup$ The region you define is a sphere, but with your plot ranges you have a cutoff sphere, is that what you are going for? $\endgroup$ – Jason B. Apr 1 '16 at 10:51
  • $\begingroup$ Exactly. My unit cell is a cut-off sphere, and I want to create a periodic structure using multiple instances of that unit cell. $\endgroup$ – g1joeT Apr 1 '16 at 10:52
4
$\begingroup$

One useful function for generating periodic structures is Mod[]. Consider the following:

RegionPlot3D[Mod[x, 2, -1]^2 + Mod[y, 2, -1]^2 + Mod[z, 2, -1]^2 < 1,
             {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
             PlotPoints -> 95, PlotStyle -> Opacity[3/4]]

a cell


One can fiddle a bit with the scaling so that the spheres intersect instead of just touching. Consider the following:

RegionPlot3D[Mod[2 x, 2, -1]^2 + Mod[2 y, 2, -1]^2 + Mod[2 z, 2, -1]^2 < 12/5,
             {x, -2 Sqrt[3/5], 2 Sqrt[3/5]}, {y, -2 Sqrt[3/5], 2 Sqrt[3/5]},
             {z, -2 Sqrt[3/5], 2 Sqrt[3/5]}, PlotPoints -> 75, 
             PlotStyle -> Opacity[3/4]]

clustered spheres

To get the interstices, just negate the region function:

RegionPlot3D[! (Mod[2 x, 2, -1]^2 + Mod[2 y, 2, -1]^2 + Mod[2 z, 2, -1]^2 < 12/5),
             {x, -2 Sqrt[3/5], 2 Sqrt[3/5]}, {y, -2 Sqrt[3/5], 2 Sqrt[3/5]},
             {z, -2 Sqrt[3/5], 2 Sqrt[3/5]}, PlotPoints -> 95]

interstices

$\endgroup$
  • $\begingroup$ Thanks for pointing out the Mod[] function. I took your code and tried to fiddle around with it. But I couldn't get it to generate the cut-off spheres I want. $\endgroup$ – g1joeT Apr 1 '16 at 11:12
  • $\begingroup$ Thanks for the revision. I will try to understand the Mod function. $\endgroup$ – g1joeT Apr 1 '16 at 14:41
3
$\begingroup$

What I'd try to do would be to create a region object and use TransformRegion[region,TranslationTransform[...]] to create a displaced copy of it.

OP's original unit cell looks like

enter image description here

Now I could create a region using DiscretizeGraphics out of this,

region = DiscretizeGraphics@
  Normal@RegionPlot3D[
    x^2 + y^2 + z^2 < 0.6, {x, -0.5, 0.5}, {y, -0.5, 0.5}, {z, -0.5, 
     0.5}]

This gives an error message, but it works

enter image description here

I create a table of these regions,

regions = Table[
   TransformedRegion[region, TranslationTransform[{x, y, z}]], {x, 
    2}, {y, 2}, {z, 2}];

and combine them into one RegionPlot3D

RegionPlot3D[regions, Mesh -> 10]

enter image description here

And simply by changing the < in the original code to a >, you can get the interstitial regions,

enter image description here

Edit

Here is a method that I like better, since it doesn't give the error above, but it is a bit slower. The unit cells and interstitial regions can be plotted via

region = DiscretizeRegion@
   RegionIntersection[Cuboid[{-.5, -.5, -.5}, {.5, .5, .5}], 
    Ball[{0, 0, 0}, Sqrt[.6]]];
regions = 
  Table[TransformedRegion[region, 
    TranslationTransform[{x, y, z}]], {x, 2}, {y, 2}, {z, 2}];
RegionPlot3D[Flatten@regions, Mesh -> 10]

and

region = DiscretizeRegion@
   RegionDifference[Cuboid[{-.5, -.5, -.5}, {.5, .5, .5}], 
    Ball[{0, 0, 0}, Sqrt[.6]]];
regions = 
  Table[TransformedRegion[region, 
    TranslationTransform[{x, y, z}]], {x, 2}, {y, 2}, {z, 2}];
RegionPlot3D[Flatten@regions, Mesh -> 10]

respectively. I wish that DiscretizeRegion was not necessary, as that is what slows it down, but without it RegionPlot3D gives awful results.

$\endgroup$
  • $\begingroup$ Just tried it out. I think this is exactly what I wanted. Thanks! $\endgroup$ – g1joeT Apr 1 '16 at 11:24
  • $\begingroup$ Glad to help, welcome to the site, don't forget to take the tour. $\endgroup$ – Jason B. Apr 1 '16 at 11:25
  • $\begingroup$ Additionally, is there any way to extract the complement of this structure? Meaning ... the periodic structure made up of the interstitial regions? $\endgroup$ – g1joeT Apr 1 '16 at 11:26
  • $\begingroup$ Yes, but it will take me a second, going to lunch now :-) $\endgroup$ – Jason B. Apr 1 '16 at 11:26
  • 1
    $\begingroup$ Who knows, maybe they'll even skip an integer and go to 12, just like Microsoft did with Windows :) $\endgroup$ – RunnyKine Apr 1 '16 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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