sierpinski_foam
¶
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_foam
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_foam)
<Signature (dmin, n, ndim=2, max_size=1000000000.0)>
dmin
and n
¶
This generator does not accept size. Instead you specify the smallest hole to add with dmin
and the number of scales to create with n
:
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
dmin = 5
n = 3
im = ps.generators.sierpinski_foam(dmin=dmin, n=n)
ax[0].imshow(im, interpolation='none')
ax[0].axis(False)
dmin = 3
n = 5
im = ps.generators.sierpinski_foam(dmin=dmin, n=n)
ax[1].imshow(im, interpolation='none')
ax[1].axis(False);
ndim
¶
The dimensionality of the image, either 2 or 3. A value of 2 (as above) technically makes a gasket while 3 makes a foam:
ndim = 3
dmin = 5
n = 3
im = ps.generators.sierpinski_foam(dmin=dmin, n=n, ndim=3)
ax = plt.figure().add_subplot(projection='3d')
ax.voxels(1-im[30:60, 30:60, 30:60]);
max_size
¶
This puts a cap on the maximum number of voxel in the generated image so that it doesn’t get too large. The function will stop iterating if the image size exceeds this value.
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
max_size=1e4
im = ps.generators.sierpinski_foam(dmin=dmin, n=100, max_size=max_size)
ax[0].imshow(im, interpolation='none')
ax[0].axis(False)
ax[0].set_title(f'actual size = {im.size}')
max_size=1e6
im = ps.generators.sierpinski_foam(dmin=dmin, n=100, max_size=max_size)
ax[1].imshow(im, interpolation='none')
ax[1].axis(False)
ax[1].set_title(f'actual size = {im.size}');