sierpinski_foam2#

The sierpinski gasket is a classic example of a fractal image with self-similar properties across all length scales. It has also been extensively analyzed so these properties are well know. The sierpinski_foam2 is a 3D version of the gasket.

import porespy as ps
import matplotlib.pyplot as plt
import numpy as np
import inspect
inspect.signature(ps.generators.sierpinski_foam2)
<Signature (shape, n=5)>

shape#

The original version of this generator did not accept shape, and instead its size was dictated by the number of divisions requested. The new version does except shape and instead it truncates the pattern if the requested number of divisions exceeds the shape.

In the images below, the image of size 100 by 100 is not symmetrical. If the full pattern is desired, then the shape must be set to 3**n in all directions, as shown on the right (n=5 is the default value).

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

im = ps.generators.sierpinski_foam2(shape=[100, 100])
ax[0].imshow(im, interpolation='none')
ax[0].axis(False)

im = ps.generators.sierpinski_foam2(shape=[3**5, 3**5])
ax[1].imshow(im, interpolation='none')
ax[1].axis(False);
../../../_images/5fd66ee54decadf8b62dc287e9f4dcfb3f7dadb9242131a065f83bdeec0f6048.png

n#

The number of times the patter is divided is controlled by the n parameter:

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

n = 3
im = ps.generators.sierpinski_foam2(shape=[3**n, 3**n])
ax[0].imshow(im, interpolation='none')
ax[0].axis(False)

n = 4
im = ps.generators.sierpinski_foam2(shape=[3**n, 3**n])
ax[1].imshow(im, interpolation='none')
ax[1].axis(False);
../../../_images/ebc7093a4371d472d43eb3b29db2b97e22413c9d4e78546591487d34ca192eb0.png